5
\$\begingroup\$

I have a simple robot with two DC motors. Using the L298N Dual H-Bridge, what's the minimum number of control pins I can use to give me forward, back and turn?

Here's a typical setup for the chip. It looks like I'll need 6 control lines to control 2 motors.

If I tied Ven high and relied on the "C=D Fast Motor Stop" when idle would this be bad?

http://letsmakerobots.com/files/userpics/u4107/L298N.png http://letsmakerobots.com/files/userpics/u4107/L298N.png

\$\endgroup\$

2 Answers 2

2
\$\begingroup\$

With two pins you have full control. This allows both forward, reverse and stop. if you want to allow coasting, you will need three pins to bring Ven low. If you do not need fast stop, you could use an XOR to control the Ven from the 2 control lines. When they are equal drive t low. Then it has forward reverse and coast.

If you hold Ven High when you decide to stop moving it will full brake. If you use a simple XOR gate to do the Ven signal then you can only coast. It is decided based on what you want the motor to do. If you need the option, use three lines. from a micro this is almost no cost.

\$\endgroup\$
3
  • \$\begingroup\$ I have a radio module with 4 I/O lines. As you say, it's probably easier to control the H-Bridges properly with another micro and wire the radio into the micro \$\endgroup\$ Commented Nov 18, 2010 at 16:06
  • \$\begingroup\$ That would be an easy way to get any feature you want. \$\endgroup\$
    – Kortuk
    Commented Nov 18, 2010 at 18:55
  • \$\begingroup\$ You could also just add the XOR gate and use two pins and always coast. Do you need to be able to both break and stop? If you do, it is only 3 lines. Although, with 4 lines you could do wireless uart to a micro and get any feature you dream of. \$\endgroup\$
    – Kortuk
    Commented Nov 18, 2010 at 19:05
1
\$\begingroup\$

The minimum number of pin you need to control is only 'one' per motor, I use this configuration in most of my robot.

Connect a not gate or a transistor to provide inverted the output between C and D pin and supply a PWM signal as a input.

In this setup you'll have only one input controlling both the speed and direction of the motor and comes in very handy in robotics, you can control it by varying the duty cycle.


Direction V/s Duty cycle

stop ----> 50%

forward ----> 51-100% (forward speed increases with increase in duty cycle where 100% as max forward speed)

reverse ----> 0-49% (reverse speed increases with decrease in duty cycle where 0% is max reverse speed)

\$\endgroup\$
2
  • \$\begingroup\$ This particular technique is called locked anti-phase PWM. The downside is that it does not allow coasting, and a MCU lockup will cause the motors to default to full speed in one direction. \$\endgroup\$ Commented Nov 18, 2010 at 21:35
  • \$\begingroup\$ The alternative control technique, which uses two pins (Direction and PWM) is called Sign-Magnitude. \$\endgroup\$ Commented Nov 18, 2010 at 21:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.