Use of PWMOUT with the AXE408 board

hbl2013

Senior Member
I am using the Axe401 PC Board with the Axe408 Motor Shield to control 2 DC motors, and I have problems using the PWM command. On the Axe408, you are supposed to use S8 and S11 ( C.0 and C.5) as motor direction, and S9 and S10 ( C.1 and C.2) as on/off/PWM (Speed) control for the L293D controller chip used. (The board is hardwired to use these ports). When S9 and S10 are pulled up HIGH the two motors run at full speed. Bringing S8 and S11 HIGH or LOW will control the direction of the rotation of the motors. I tested all that, and that works. So far so good.
The problem is that when the PWMOUT command is applied to S9 or S10, neither motor will turn, whatever I use in the command parameters.
I used the sample in the manual, and used 10000 cycles and a 50% Duty cycle > PWMOUT S9,99,200 (This should run the motor at approx. half speed ). This did not work. I changed the Duty Cycle in the formula from lower to higher, but nothing happens, the motors don't react at all.
Am I missing something? Any comments or suggestions?
 

rq3

Senior Member
I am using the Axe401 PC Board with the Axe408 Motor Shield to control 2 DC motors, and I have problems using the PWM command. On the Axe408, you are supposed to use S8 and S11 ( C.0 and C.5) as motor direction, and S9 and S10 ( C.1 and C.2) as on/off/PWM (Speed) control for the L293D controller chip used. (The board is hardwired to use these ports). When S9 and S10 are pulled up HIGH the two motors run at full speed. Bringing S8 and S11 HIGH or LOW will control the direction of the rotation of the motors. I tested all that, and that works. So far so good.
The problem is that when the PWMOUT command is applied to S9 or S10, neither motor will turn, whatever I use in the command parameters.
I used the sample in the manual, and used 10000 cycles and a 50% Duty cycle > PWMOUT S9,99,200 (This should run the motor at approx. half speed ). This did not work. I changed the Duty Cycle in the formula from lower to higher, but nothing happens, the motors don't react at all.
Am I missing something? Any comments or suggestions?
Try reducing the frequency (cycles per second) from 10000 to something like 100, or even 10. When you get it working, you can "fine tune" from there. This number is the rate (cycles, or times per second) at which the PWM signal turns on and off. 10000 is way high for motor speed control (usually). The other number is basically what percentage of time the signal stays on.

EDIT: After a bit of research, I noticed the AXE408 is designed to be run off of a PICAXE 28X2, so the lowest frequency you can get (at a 4 MHZ clock), is 244 (NOT 100 or 10). For a C.1 output at 50% duty cycle, the command would look like (from the PWM wizard):
pwmout pwmdiv16, C.1, 255, 512

You would change the 512 from 0 to 1023 to go from motor off to motor full speed.
 
Last edited:

hbl2013

Senior Member
Thanks rq3, I will try that. As I understand it, we are aiming at interrupting the power supply of the object much like a dimmer for incandescent lights does at 60Hz. By varying the duty cycle, we control the light output of the device.
As an alternative, I was thinking of using a 555 timer chip to accomplishing much lower frequencies, and just switching the Motor Enable port of the H-Bridge on/off with the output of the 555. But your solution looks more attractive to me, since it does not requires an additional 555 chip.
 

rq3

Senior Member
Thanks rq3, I will try that. As I understand it, we are aiming at interrupting the power supply of the object much like a dimmer for incandescent lights does at 60Hz. By varying the duty cycle, we control the light output of the device.
As an alternative, I was thinking of using a 555 timer chip to accomplishing much lower frequencies, and just switching the Motor Enable port of the H-Bridge on/off with the output of the 555. But your solution looks more attractive to me, since it does not requires an additional 555 chip.
Your understanding is exactly correct. A light dimmer turns the power on and off 60 times per second, and varies how much of the ON time is applied to the bulb. The beauty of the picaxe is that you can change the 60 times per second over a huge range, and THEN decide how much of the ON time will be applied to the bulb (or motor, in your case). And don't forget that the PWM frequency of the Picaxe is dependant upon its own clock rate. I've never used the 28X2 picaxe (I'm a 20M2 man myself). I believe that the 28X2 defaults to an 8 MHz clock, which you can change with the "setfreq" directive in your program. The lower the clock rate, the lower the PWM frequency can be.

So you have three things that you can play with:
1) The 28X2 clock (32 KHz to 64 MHz!!!).........
2) Which will affect the PWM FREQUENCY (pulses per second, or 60 times per second in your example)
3) The WIDTH of those pulses (from 0% [always low], to 100%[always high]

A DC motor needs a relatively low FREQUENCY, because its own copper winding inductance won't allow it to respond to really fast ON-OFF pulses (PWM FREQUENCY), no matter how narrow or wide they are. Well, they WILL respond to 100%, since that is really just ON all the time, but getting speed control? No. Give it a shot.
 

hbl2013

Senior Member
@rq3 --I tried what you suggested, and it worked.... to some degree. The H-bridge behaved rather oddly when it was used with the PWD command, the motors did not run at the same speed and the motor that was slower, refused to reverse. The bridge seemed only to behave as it should when running at full or close to full power.
I ordered some MOSFETS and will try to control the motor speed with a 555 as I proposed. The PWD Command might be OK for some bridges, but not for the ones I have.
I can always also drop the use of the IC altogether and use 5 small relays (the size of an IC) which I have to control the motors. That method is less sophisticated, but full-proof and as easy to control as a bridge IC.
 
Last edited:
Top