I know i have asked this before, but jus for clarification, i wonder if some of you could clear my doubts.
according to robologist, i need to use this coding and connections
- PWMA to +5 volts
- AIN2 to P4
- AIN1 to P5
- STBY to +5 volts (can be wired to Stamp pin to disable/enable driver)
- BIN1 to P6
- BIN2 to P7
- PWMB to +5 volts
- GND to ground
- GND to ground
- VMOT to motor positive supply (+6 volts for above motor)
- BO1 to left motor terminal
- BO2 to other left motor terminal
- AO2 to right motor terminal
- AO1 to other right motor terminal
- VCC to +5 volts
- GND to ground
To make the right motor turn one direction, make the BS2 pin P4 high and pin P5 low. To have it reverse direction, make P4 low, and P5 high. To make the right motor stop, make both P4 and P5 low.
To make the left motor turn one direction, make the BS2 pin P6 high and pin P7 low. To have it reverse direction, make P6 low, and P7 high. To make the left motor stop, make both P6 and P7 low.
but just to control the speed
i use this
' pin8 to pwmA
' pin9 to pwmB
reps VAR BYTE ' up to 255 for BYTE
tmr VAR NIB ' for adding off time for sim PWM, PAUSE in milliseconds
INIT:
LOW 8 ' make sure pin 8 and 9 are low so pulsout is high
LOW 9
tmr = 0 ' change this value to try different PWM "speeds" to 0, 1, 2, or 3
' 0 => 100% duty, 1 => 66% duty, 2 => 50% duty, 3=> 33% duty cycle
MAIN:
FOR reps = 1 to 100 ' pulses lasts 0.2 seconds, pause adds 0, 0.1, 0.2, 0.3 seconds
pulsout 8,1000 ' produces 2 ms pulse
pulsout 9,1000 ' produces 2 ms pulse
pause tmr ' gives the off time for each cycle
NEXT
but if i want to use pwm, do i still need to use the high and low for pins 4,5,6, and 7?
is there a better way to control the speed of my motor?