2
\$\begingroup\$

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

\$\endgroup\$
  • \$\begingroup\$ To ask the obvious questions: When you had the pull-up from the L293D's enable line to Vcc did you also have in1 and in2 configured properly? And have you taken a DMM and tested the output to ensure it's driving the enable line? \$\endgroup\$ – sherrellbc Jul 20 '14 at 17:10
  • \$\begingroup\$ sherrellbc: in1 and 2 were configured correctly when using the pull-up - if I replace the pull-up with a wire to vcc, it works, but with the pull-up nothing happens. Testing the output shows it's at -5v, which is why I thought I could use it with a pull-up resistor so that the enable pin would be driven when the TLC5940 isn't driving the output, in the same way as in1 and in2. \$\endgroup\$ – Nevermore Jul 20 '14 at 18:34
  • \$\begingroup\$ -5V output from the TLC5940? What is the power supply voltage at Vcc of the TLC5940? \$\endgroup\$ – sherrellbc Jul 20 '14 at 23:41
  • \$\begingroup\$ You will get more useful answers if your schematic is more legible and accurate. There are some obvious errors and omissions right now, for example, what is the L293D powered by? What is the (-) terminal of the battery connected to? Are there really only 3 pins of the TLC5940 connected? \$\endgroup\$ – Zuofu Jul 21 '14 at 3:21
  • \$\begingroup\$ Zuofu: Thanks for your comment. I've tried to make the schematic more complete - hopefully it is clear. I don't have much experience with drawing circuit diagrams. \$\endgroup\$ – Nevermore Jul 21 '14 at 19:42
1
\$\begingroup\$

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.

\$\endgroup\$
0
\$\begingroup\$

Is V motor to the L293D +5V? Where is that +5V coming from -- the Arduino? You should not (and often cannot) put a significant load such as a motor piggybacked onto the regulator of the Arduino, it is only rated for <400mA if you are using a USB port. See How much current can I draw from the Arduino's pins? for a good explanation. Also, the L293 is a poor component choice for low voltage motor control, due to the high internal voltage drop, see:

L293D overheating

and

What H-bridge drivers are preferred for applications controlling a low-voltage motor?

for alternatives.

\$\endgroup\$
  • \$\begingroup\$ Zuofu: I've actually got lower voltage drop H-bridges on order for exactly this reason (and will be driving the motors from a separate supply). However, I don't think that this is the problem here . If EN1 is connected directly to +5v, or to a PWM pin on the Arduino itself, it can drive the motor. I can even control the speed using PWM directly from the Arduino. It's only when trying to control it by PWM through the TLC5940 that I can't get it to work. Any ideas? \$\endgroup\$ – Nevermore Jul 22 '14 at 8:25
  • \$\begingroup\$ Oh, the TLC5940 is not the ideal part for this. If you look at the datasheet, you will see that it is a constant current sink, it cannot actually drive a 'hi' logic level; it can only sink current or become high impedance, which is fine for LEDs, but not so great for logic. You can try pulling up the output of the TLC5940 to +5V using a 1K or larger resistor. \$\endgroup\$ – Zuofu Jul 22 '14 at 19:13
  • \$\begingroup\$ Zuofu: that's what I tried to do, but nothing happens. In fact, even if I don't use the TLC5940 at all and just connect a resistor (I've tried a variety of values from 560 ohms to 2.2k ohms), I get no response from the motor. Any idea what's going on? If not, is there a chip that you would recommend to replace the TLC5940? \$\endgroup\$ – Nevermore Jul 22 '14 at 19:51
  • \$\begingroup\$ How are you verifying that you are actually talking to the TLC5940? Do you have an oscilloscope to probe the input to the L293? \$\endgroup\$ – Zuofu Jul 22 '14 at 20:44
  • \$\begingroup\$ I don't have an oscilloscope. However I can connect LEDs to the pins and vary the brightness by talking to the TLC5940, and I can turn the motor on and off by changing the output to In1 and In2, so I think I'm controlling the TLC5940 correctly - it's just controlling En1 that I can't work out. \$\endgroup\$ – Nevermore Jul 22 '14 at 21:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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