i have just recently received a picaxe 20x2, picaxe 20x2 project board, 2 geared dc motors and a bunch of ldr's!
my plan is to make a line following robot. I have worked out how to sense the line with the ldr's but cannot get the picaxe to run two motors simultaneously!!
I am using the L293D Motor driver and i can control the speed and direction of one motor but when it comes to controlling two motors they both either don’t move or one moves really slowly.
Make sure your 5v PS can source enough current for everything and also your motors will work with only about 3v. Also try seperating the logic and motor power supplies once youve checked those things.
You will need to know how PWM and a H-bridge works. With 4 PWM signals, you will have fwd, rev and brake depending on how they are implemented. I think Picaxe has a HPWM command as well but so far, no one has been able to figure it out --you would be the first.
I was just having a look at the pinout diagram of the 20x2 in the PICAXE manual and it showed that it had only 1 pwm output pin, but 4 or 5 hpwm outputs. is this a mistake and is there more pwm pins or do i just have to use hpwm??
Everything else looks ok. I maybe just give you a quick tutorial here --might speed things up.
I would skip the 4-PWM thing and instead go with 2 PWM’s and 2 regular outputs. Each side of the motor driver gets one PWM and one regular pin. Forward is PWM + pin low. Reverse is PWM + pin high. Done. That’s it.
I am not familiar with the 20m2’s --I would need to see the manual. What page was the HPWM stuff on again? I can’t seem to find it. I really can’t help much, I’m afraid, without that page number. --Again, the page number from the manual that deals with the HPWM command, I need it.
Well, this is indeed what you need and again, no one has gotten it to work. I did some googleing and came up with at least a command… (I don’t know why this command has no code snippit with it in the manual!!)
For ‘four line control’ of an H-Bridge you will need to use Full Bridge mode. You should be able to drive an H-Bridge controlled motor forwards and backwards with -
Hpwm PWMFULL_F, PWMHHHH, 0, period, duty
and
Hpwm PWMFULL_R, PWMHHHH, 0, period, duty
Change “PWMHHHH” to match the polarity required for the H-Bridge module and set ‘period’ and ‘duty’ for the PWM speed control.
In the 16F684 (14M) datasheet I have this configuration is described on page 91 onwards and Figure 11-10 is very relevant. Microchip’s AN893 Application Note also provides additional information; Figure 1 and Figure 2 showing how the Full Bridge mode controls current flow through the H-Bridge.
Full Bridge mode appears to work as I would expect it to; each line controls one of the four FETs at each corner of the H-Bridge circuit. Enabling ( close circuiting ) the two FETs at opposite corners of the H-Bridge while disabling ( open circuiting ) the others and vice-versa to control the direction of current flow and thus motor direction. By PWM pulsing one of the enabled FETs the speed can be controlled.
Any H-Bridge module which accepts logic level ‘four line control’ with the polarities output by HPWM should be usable with the 14M without any additional components. If a module does not accept logic level control or needs alternative polarities then additional buffers, inverters and voltage level shifters may be necessary.
It may be possible to drive four FETs directly from the logic lines of the 14M but I do not know for sure as I have very little knowledge or experience of FET electrical operation.
If you could post the full circuit of your H-Bridge module and PICAXE-14M interface others may have more specific or additional advice.