DC motor control - BS2

dude, you rock! haha. i’m
dude, you rock! haha. i’m determined to make my own wheels though i am in a delienma. i want the length of the wheels to be 3cm. maybe if i get this http://www.solarbotics.com/products/rw2/ and attach my own “tire (moulded + pvc)” with super glue ? about the making of urethane tires, i read something about it not sticking to the wheels, is that true?

could you also help me by
could you also help me by showing me a sample of how to control a motor with the TB6612FNG. thanks alot man, you helped me alot :smiley:

or should i get this?? what

or should i get this?? what is the length of the set screw?

edit

'THIS" = http://www.solarbotics.com/products/rw2/

Don’t know the length of the
Don’t know the length of the set screw, but they do recommend a wrench for it.

Connections for TB6612FNG

Connections for TB6612FNG Dual motor carrier interfaced with a Basic Stamp 2, from this picture going clockwise from top right:

1st TB6612FNG, then Basic Stamp, power, or motor connection
  • 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.

 

 

how about variation of speed?
how about variation of speed?

Turn the inputs on and off

Turn the inputs on and off quickly in a loop to simulate a PWM cycle. If you loop quick enough, it can probably work, maybe stuttery, but maybe passable.

can i connect PWMB/A to a
can i connect PWMB/A to a pin in the bs2?

Speed regulation with PWM
OK, i overlooked the fact, that the BS2 doesn’t have hardware PWM pins. Software PWM (toggling the PWM Pins) as robologist mentioned, is one possibility. If its on your budget , the Qik 2s9v1 that ericski mentioned is a good alternative. It uses the same motor controller and has a microcontroller onboard. You only need a serial connection (RX, TX) and a reset pin for connection it.

would using the pulsout
would using the pulsout command be possible???

The BS2 can do 1 and only 1

The BS2 can do 1 and only 1 PWM output at a time, and do nothing else while that is running.

Pulsout is a single pulse, so no, it would not work any better than simply toggling through a loop, as suggested.

Alternatively you could try the serial h-bridge mentioned, as it generates it’s own PWM based on commands.

sighs, u got a sample of how

sighs, u got a sample of how to do the PWM?

can i use this? :

’ pin8 = pwmA

’pin9 = pwnB

counter VAR WORD

for counter = 1 to 150

pulsout 8, 750

pulsout 9,750

also, is this motor
also, is this motor feasible? http://www.pololu.com/catalog/product/1091

’ pin8 to pwmA’ pin9 to


’ 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

 

if im right i also need to

if im right i also need to use this

  • 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

Very similar to the other
Very similar to the other motor, so should work electrically, and torque. May be a little bit too long dimensionally to fit in a minisumo footprint with wide wheels.

Yes, the wiring is the same,
Yes, the wiring is the same, jsut with the added part for a pseudo-PWM speed control added. That code will give anywhere from 0.2 to 0.5 second of running the motor every time it is called, and so must be called constantly to keep the motor turning. Your actual program might have a few other things going on, and call the MAIN part periodically (probably best to call it another name, for good programming technique).

can i pulsout more than
can i pulsout more than 1000? i cant seem to get max speed.

What does the Basic Stamp

What does the Basic Stamp manual say on page 351?

Making pulsout longer does tie up the Basic Stamp for a longer period of time, til eventually it can do nothing else.

At any rate, if you want max speed, simply make the PWM pins high.

how to “high” the motor
how to “high” the motor for a period of time