I want to be able to forward/reverse control the motors in a Tamiya Dual Gearbox and be able to adjust the speed with a Picaxe-40x2. How would I go about doing that?
It says in the second Picaxe manual that you can't use hpwm and pwm at the same time, but when I tried it in the simulator, They both worked at the same time. Was that just not included in the simulator?
hpwm cannot be used on pin 2 when using pwmout. But it can be used on pin 1. Here's quote from the manual: "hpwm can be used instead of, not at the same time as, the pwmout command on 2 (28/40 pin). However pwmout on 1 can be used simultaneously if desired."
In single mode hpwm works just like pwmout. It just uses different pins. Here's a small example of pwm'ing 2 leds with hpwm: http://letsmakerobots.com/node/20374#comment-46560
Like Chris said hpwm can (or should be able to) also control H-bridges in either half or full mode. I haven't tied this and "the hpwm motor driver datasheet" which the hpwm documentation in manual 2 refers seems to be (still) non-existent. See, for example, this post on Picaxe forums. That post also says that Pic (not Picaxe) datasheet may provide some help with helf and full modes.
When searching for the missing hpwm motor driver datasheet I happened to find this post about hpwm on Picaxe forums. You may find that helpful too.
I have no idea why I put the % in front of the number. --That's weird.
Welcome my friend to the ol' HPWM routine...
I should start off with the fact that not a single person on LMR has ever figured out the HPWM system. In therory, it should allow you to control 2 motors, with PWM speed control, forward and reverse in the standard "H-bridge motor driver" way. No one has done it --If you figure it out, you would be first.
Now, what I have done in the past... PWM controls the speed of your motors by changing the length of pulses of electricity going to your motors. In a 50% duty rate, the pulses are on 1/2 the time and off 1/2 the time. This would be %50 of top speed (in theory). At %25 they are on 1/4 of the time and off 3/4 of the time --1/4 speed. All this is figuring only one direction of the motor. If that same motor goes in reverse, the PWM is inverted. Let's say you have 2 wires going to a motor. One is attached to a PWM output and the other goes to a pin that is set low. The duty rate is set at 75% so %75 of the time, you will have a high on one motor lead and low on the other. %25 of the time you will have low/low. This is your 3/4 power. Now lets set that other pin to high. The PWM has not changed, you simple "reversed" the motor. Now lets look at the pins. The "other" wire is now high so %75 of the time you will have a high/high situation (which is the off part of the cycle --high/high is off) and %25 of the time you will have a low/high situation --the motor is indeed reversed, but it is now at %25 power even though the PWM is set to %75.
To sum this up, one wire from each motor goes to the 2 PWM outputs. The other 2 wires go to 2 general outputs. You get this:
This is Forward PWM - Low PWM = PWM
This is Reverse PWM - High PWM = The inverse of the PWM
What's the difference between the hpwm outputs, and the pwm outputs? Can I use them both for controlling motor speed through the L293D?