Electronic – Controlling speed of motor through L293D using TLC5940NT

motorpwm

I am trying to control a DC motor through an L293D. Ultimately I am controlling it with an Arduino, but I am trying to use a TLC5940NT chip as an intermediary to increase the number of outputs that I have.

I have hooked up three of the pins on the TLC5940 to the input 1, input 2 and enable pins of the L293D, using 2.2k ohm pull-up resistors on the two input pins (I've tried to diagram it below – apologies if it isn't clear. Full-size version):

Diagram of TLC5940NT hooked up to L293D:
Diagram of TLC5940NT hooked up to L293D

When I hook the enable pin up to +5v, the motor works and I can control the direction using In 1 and In 2. However, I want to control the speed by PWM. When I hook the Enable pin up to the TLC5940 (as in the diagram) I can't get the motor to spin at all. I tried using a pull-up resistor as well on the enable pin, but it still didn't spin – and when I connect it to +5v DC using just a 2.2k ohm or 560 ohm resistor nothing happens. The only thing that has made it spin so far is constant 5v DC with no resistor.

Can anyone explain what's wrong and how I can get it working?

Edit: I've tried to add a more complete schematic

Best Answer

The core issue here is that you have misunderstood how the TLC5940NT outputs actually work. They do not operate the same way as the Arduino's push-pull output drivers, the TLC5940NT uses current sinks (called open Drain outputs, which really act more like inputs! Freaky right? I explain more at the end) to pull that pin "LOW". This is why you connect LEDs to them, sometimes with a current limiting resistor (depending on if they are actually current-controlled sinks or not) from VCC through the LED and then into the pin of the TLC5940NT and similar devices (I used the TLC59116F before, which is similar).

I actually made the same mistake as you back in the day, as I did not know what an open drain/sink input was, and assumed exactly like you did, that it would work similar to the way my Arduino did. What you need to do to make this work is invert the logic with external components and some pull up resistors. When the "outputs" of the TLC5940NT are "off" the value on the pin is pulled high. This "high" signal can be inverted easily with either two methods - an NPN transistor logic inverter circuit, or an inverting buffer/line driver logic IC or even op-amps if you have to. Below is a quick sketch of each of these methods.

Figure 1: Transistor logic inverter using a cheapo NPN BJT. Transistor logic inverter

Figure 2: Using an inverting buffer IC, such as a 7404 Hex (means 8 inputs/outputs) Inverting buffer. hex inverting buffer

You might want a pull down resistor or two on the buffer output to avoid floating pins but I think it will be okay without them. Always follow the guidance of the manufacturer's datasheet.

Notice how in both pictures I show the TLC5940's "output" pins as actually the top side of an N channel MOSFET? This pin is going to the "drain" of the FET, which when turned off is basically an open circuit, so they call it an "open drain" output. Even though it acts as a low side current sink switch.. Terribly confusing, and I understand why you made this mistake. It is important that you learn this now, as early as you can, and always remember in the future to check these datasheets and go through the logic to be sure this doesn't happen again.

The next thing to do is wire the outputs of these inverting stages to the inputs of your motor driver, as if they were Arduino style output signals.

Your system should work as intended now! The external components are a necessary evil because of the way the outputs of the TLC5940NT work. I agree though (and why I used the TLC59116F) they have awesome features and using their ability to PWM each channel and let your microcontroller do other things is worth the effort.