Speed Control on PICAXE 8 Pin Motor Driver Board

I understand the basic hook up and command structure for controlling on/off and direction for two motors, but is there a way to also control the speed?

 
 

goom

Senior Member
To control motor speed you need to pulse the power to the motor with a variable width pulse. The PICAXE has a very convenient command for this, pwmout. It runs in the background once executed, so will permit you to execute other code whilst continuing to output the pulses.
I'm not familiar with the particular board, but I assume that it uses an L293D dual bridge. In that case the pulses from the PICAXE can be fed into the two enable lines (legs 1 and 9).
The command pwmout Pin,255,N will give a variable pulse duty cycle (on to off time), with N=0 stopping the motor, N=1023 giving full speed, and anything in between giving part speed. "Pin" is the PICAXE output pin connected to the L293D enable pins, so:
pwmout 2,255,512 will give half speed (roughly) with PICAXE pin 2 (leg 5) connected to the L293D enable pins.
The frequency of the pulses will be about 3.9 kHz. Other (higher) frequencies are possible by using different values in the pwmout command (try the PWM Wizard in the Program Editor).
Hope this helps.
 
I think I understand... so if I wanted to create a mobile robot with two drive motors, I would use 2 08M's (since I can only have one PWM per 08M) going into a single L293D Driver Chip? This way, I could control the speed of each motor (using the 08M's) and the direction (using the L293D)? Do I have it correct?
 

Wrenow

Senior Member
Steve,

Depending on budget, etc., and how heavy duty of a motor you want to control, you can also use 2 ESCs (Electronic Speed Controllers) dommon in the radio control and robotics arenas. These plug in like a servo, and get the same controls you use tocontrol a serfo, except you get speed instead of position. The Radio Shack (soon to be Revell) Vex Robotics "motors" are a motor, gearbox (gears it down to about 100RPM max as best I recall), clutch, and ESC in a servo case. Pretty handy little buggers.

Just another way to skin that cat.

Wreno
 

Technical

Technical Support
Staff member
If you want both motors to be able to run at two different speeds, you need two different pwm outputs. You can do this with 2 x 08Ms or one 28X1 (as it has 2 pwmout channels), with the pulsing going onto two of the four direction pins of the L293D (one for each motor).

However if you can get away with both motors going at the same speed as each other, you can use one pwmout to control the speed of both motors as described above (pulsing the enable pin rather than the direction pin). This however needs 5 outputs, not 4, from the PICAXE and so you would need a 14M or 18X.
 
Top