L293D H bridge wierdness

Hey there!

I think I'm missing something very fundamental about H bridges but I'm a total electronics newb so some help would be really, really appreciated.

So I've set up an L293D on a breadboard exactly as Tom Igoe shows in his excellent "Physical Computing" book. It's also actually on his stepper motor web page...can't post the link as this is my first post and the forum won't let you post links on your first post, to stop spam I guess.

My setup is as per the 3rd diagram down (for bipolar steppers). I got the motor spinning, thought "great!" but then went to disconnect the motor power supply and guess what?...the stepper carried on spinning. Now I can only assume this is because it's somehow taking power from the Arduino...but I really don't get it. I thought the whole point was that the Arduino can't supply much in the way of current and the H bridge acts like a switch for the higher current supply. It makes no difference to the motor if the motor power is connected or not. For motor power, I'm using a 3x1.5V AA battery pack. If anyone can explain what's going on here and what I actually should be doing then I'd be very grateful!

Cheers! sCam

Go on post the link now.

It sounds like you don't have a stepping motor but a DC one.

It makes no difference to the motor if the motor power is connected or not.

I really don't believe you, have you invented a motor that will turn without power? :o

sCam,

I am having a similar issue with the L293, so I thought I would post up to see if the answer to your question ends up being the same answer to mine. I am something of a newbie for posting on forums, so I apologize if it is bad form (sorry!) on my part for tagging on to your post. (By the way, Merry Christmas!)

I am attempting to figure out how the L293 works before even connecting it to a microcontroller. For this I plugged it into a bread board and wired the pins as follows:

1 5V+ 16 5V+ 2 ground 15 10k resistor to ground 3 to motor 14 4 ground 5 ground 6 to motor 7 5V+ 8 5V+

Sorry about that. Let's try again.

Before attempting what I layout below, I spent several hours looking at datasheets for the L293, as well as reading as much as I could on the web, including a number of forums. I am attempting to figure out how the L293 works before even connecting it to a microcontroller. For this I plugged it into a bread board and wired the pins as follows:

1 5V+ 16 5V+ 2 ground 15 10k resistor to ground 3 to motor 14 no connection 4 ground 13 ground 5 ground 12 ground 6 to motor 11 no connection 7 5V+ 10 10k resistor to ground 8 5V+ 9 10k resistor to ground

The DC motor I am testing with is the one of the two which comes in the Tamiya Twin-Motor Gearbox kit.

When I power up the circuit, the motor turns just fine.

If I disconnect pin 1 (5V+), the motor continues to turn.

If I disconnect pin 7 (5V+) , the motor continues to turn.

If I disconnect any one, or all, of the resistors at pins 9, 10, and 15 (all at ground), the motor continues to spin.

It is only when I disconnect pin 2 (at ground) that the motor stops turning.

If I switch pin 2 to 5V+ (or disconnect) and switch pin 7 to ground, the motor does turn in the opposite direction.

This clearly is not working the way I think it should. If I were to bring the microcontroller into the picture then I believe pins 1, 8, and 9 should go to 5V+ from the Arduino, and pins 2 and 7 should be receiving high and low from the Arduino as well for motor direction. Am I understanding this much correctly? Or if I did have this connected to the Arduino, is it the case that the high and low signals should be coming to pins 2 and 7 for motor direction and the PWM signal should be coming to pin 1 (which is variously referred to as 'inhibit' or 'enable')?

Can anyone help shed some light on reasoning errors or misconceptions that are apparent from what I have posted above? Is my glitch and sCam's the same?

Thanks in advance, and Merry Christmas

Tech Student

7 5V+
16 5V+

Your power supply won’t last very long…

I hope you are using an L293D and not a plain L293.

Power for the chip goes to pin 20 (VSS) and power for the motor goes to pin 10 (VS). Don’t forget about connecting the negative side of your power supply to one of the GND pins.

The motor should go between pins 3 and 8.

Pin 1 (Enable) should be pulled high with a 10K resistor to VSS.

To test your motor you should also pull pins 2 and 9 high with 10 K resistors. Now by connecting pin 2 to GND the motor will turn one way and by connecting pin 9 to GND the motor will turn the other way.

If this works you can use your arduino to control pins 2 and 9.

Don

Don

Thanks for your post.

The power supply I am currently using is a bench supply, so no problem with it running out (unless of course the grid goes down).

I am actually using the L293 and not the L293D. Did you say you hoped I wasn't because you were worried about current draw, or because (now I realize this) that I am actually asking about a different componen than sCam? The current draw is around 400 mA, well below the 600 mA max (I was just running the motor on my test bench without any extra load).

I did manage to get the motor functioning with the Arduino connected to the L293, however my initial setup for this used input 1 (pin 2) and input 2 (pin 7) on the L293, but with no resistors. I then rewired the circuit with the 2N3904 and two resistors (as shown at http://www.arduino.cc/en/Reference/StepperBipolarCircuit). One critical mistake I had made was not connecting my grounds (from teh Arduino and bench supply) together.

One thing I am not really clear about though, that you mention, is the use of 'pull-up resistors'. I have heard about pull-up and pull-down resistors with a few circuits I have done in the past, but I don't totally understand the purpose. Connecting an input to 5V+ with a 10k resistor will make the input in question less positive than high, correct? Does this push it all the way down to low status or into the grey region between low and high? If it is less positive than high, why is it called a 'pull-up' resistor? I have a vague general sense but am obviously sketchy on the details.

Getting there ...

Tech Student

I am actually using the L293 and not the L293D. Did you say you hoped I wasn't because you were worried about current draw

No, I'm worried about the lack of protection diodes. You need two on each output and they are internal to the L293D (D for 'diode') but you have to add them for the L293.

Connecting an input to 5V+ with a 10k resistor will make the input in question less positive than high, correct?

Not really. The input impedance of the IC is so high that the current drawn through the 10K resistor is negligible, hence the voltage drop across the resistor is also negligible.

Think about the enable pin with it's pullup resistor. Normally the resistor provides nearly 5v on the enable pin thus enabling the chip. If you want to disable the chip you can connect the enable pin to GND and you won't short the power supply. If you had enabled the chip by connecting the pin directly to the +5 volts you would first have to remove that connection before connecting the pin to GND, otherwise the power supply would be shorted. Using this technique there is a short period of time when the pin would be 'floating', connected neither to +5 or to GND, its state would be indeterminate and it would possibly oscillate back and forth between enabled and disabled.

Tech Student

Where?

Don

the L293 has just 2 gnd pins in the middle. so i think
7 5V+
16 5V+
should be fine.

one think i read in the datasheet is that vs should be higher then vss.
you put them both on 5V, so this could be an issue.

floresta:

Thanks for your follow up reply. I will add those diodes.

I am a student at BCIT, which is a post-secondary technical institute in a suburb of Vancouver, BC, Canada.

ipp:

Thanks for your response.

My interpretation of the datasheet is that not that vs must be higher, but rather that it must not be lower. In other words vs >= vss, so vs is allowed to be the same. I hope I am using the terms correctly - the datasheets I am used to looking at use vcc1 and vcc2. Anyways I believe the principle is that one needs to be equal to or greater than the other and I don't believe I mixed them up when connecting things.

Regards,

Tech Student