I have the SN754410NE quad half h-bridge controller and was messing with it last night to drive a motor.
If we look at the inputs of only one side, using 2 half bridges to make one complete h-bridge there are 3 pins of interest.
EN = Enable
1A = Logic controler 1 of output 1Y
2A = Logic controler 2 of output 2Y
We connect the DC motor to 1Y and 2Y
The grid is such
EN
A
Y
H
H
H
H
L
L
L
X
Z
where :-
H=High
L=Low
X=dont care/does not matter
Z=off (high impedimence) (whatever that means)
Anyway - to drive the motor you pull EN high and set 1A and 2A High and Low (or Low and High for the other direction) respectively. That is clear using digital write and full speed.
Now, there are 2 approaches for PWM control.
Set 1A and 2A as above using digitalWrite and PWM the EN pin
Set 1A with PWM and 2A Low (or 1A Low and 2A PWM for the other direction) and pull EN high.
Which of these two approaches is preferred?
I know the first one could simply pull EN high with a resistor and not use an arduino pin, but assuming you have more than enough pins available which would be the favoured method and why?
That depends. The enable being off gives a high-impedance state on the output which means the motor current will flow through the free-wheel diodes and this causes a rapid fall in current between on-pulses since the voltage across the winding reverses on the off pulses. I suspect this mode will perform poorly when PWM duty cycle is low.
With PWM on A rather than EN the motor is short-circuited during the off-pulses and current will fall much more slowly - this is likely to be a much more linear response to the PWM duty-cycle. This mode uses the free-wheel diodes less.
So the later should behave better, but needs 2 PWM pins for bidirectional control whereas the first mode only needs 1 PWM pin (but 3 in total).
Hmm... I am afraid I do not have any way of quantitively measuring the effectiveness of one method over another Im afraid.
My current rig is a breadboarded ATMega328 and the SN754410 with a motor extracted from an old CD player.
I must admit the talk about freewheel diodes is way over my head...
I did not think about the need for 2 PWM pins though, which would climb to 4 if you are driving 2 motors which is what I am thinking of doing on my first robot - probably a tracked woblybot
You could also try this configuration, put a pull-up on enable and then run your arduino's output pin into an inverter, then send the non-inverted signal to pin 1 on the h bridge and the inverted signal to pin 2.
When you output pin goes high, the motor runs one way, when the pin goes low it runs the other.
PWM at 50% duty cycle holds the motor in place, lower duty cycles go one way, higher duty cycles turn the other. That's right, direction and speed control from one pin.