PDA

View Full Version : Weird L293D problem

unimatrix
12-30-2005, 04:43 PM
Hello

I'm trying to build a simple robot using PIC16F874A and a L293D (actually it's L293DNE) motor driver. I'm using 4 1.2V accumulators (which makes 4.8V when near empty, and about 5.7V when recharged, so I also added a 1N4007 diode - prevents short circuits and reduces voltage about 0.4-0.7V)
PIC works perfectly, but not L293D. I've programmed PIC to switch 2 pins between 1/0 every 3 seconds, and it's doing so.
But when I measure L293D's outputs, i'm getting this:
Input1=5V,Input2=0V --> Output1=5V,Output2=0V
Input1=0V,Input2=5V --> Output1=0V,Output2=0.56V
(*the 5V are not actually 5V, but 4.40V, because my accumulators are almost empty and i'm still using the diode :P)

The strange thing is, I have 2 L293DNE chips and one L293NE... and it's the same with all of them.

Help?

unimatrix
12-30-2005, 04:56 PM
Okay, I've tried sth else...
Before I didn't connect the Enable pins to 5V... I just left them blank.
Now I'm getting readings as following:
Input1=5V,Input2=0V --> Output1=5V,Output2=0.56V
Input1=0V,Input2=5V --> Output1=0.56V,Output2=5V

How in the world can this happen?
Where did the 0.56V come from? It should be a damn 0V! :)

I thank you in anticipation.

devpriya
12-30-2005, 05:52 PM
Have you grounded all the Ground pins......there are four ground pins, so please ground them all. What is the input you are giving on Pin 8 ?

unimatrix
12-30-2005, 06:03 PM
All the GND pins are grounded (on neg. side of accumulator).
The inputs are 5V theoretically (but at the moment 4.4V, because I need to recharge the batteries).

EDIT: And I'm actually getting 3.69V on L293D outputs (3.7V+0.56V = voltage in my circuit (also considering the voltage use of the diode).

Oh, and since I'm already asking I might aswell ask what the difference between L293D and L293DNE and L293NE is?

devpriya
12-30-2005, 06:14 PM
Well first of all I dont think you need any external diodes with L293D, it comes with built in protection mechanisms. Infact giving Logic 0 to both the input pins corresponding to one motor gives you regenerative braking instead of normal breaking.

So try removing the diodes and charge up your batteries a bit and then tell me the stats....

unimatrix
12-30-2005, 06:21 PM
OK I'll do that... but can I still use the diode to protect PIC? (I'm not such an expert in electronics, I'm better at programming microprocessors :P)

If I recharge the batteries and plug them to PIC without the diode, it's gonna hit it with 5.7V... and PIC can only take up to 5.5V. :S

12-30-2005, 06:52 PM
use a buffer{74244 or 74245} in between pic and l293dne....
and as dev said, there's no need for tat diode.....
connect pin 1,9, and 16 to +5v directly.
connect 4,5,12,13 to gnd.
now connect the motor to pin 3 and 6 and give logic inputs to pin 2 and 7.
connect pin 8 to watever voltage u want across motors....

But when I measure L293D's outputs, i'm getting this:
Input1=5V,Input2=0V --> Output1=5V,Output2=0V .
under this state the motor should run, after all u r getting the 5v and 0v across the motors. r u sure tat ur motor runs at 5v?

unimatrix
12-30-2005, 06:59 PM
Okay, I've put pins 8 and 16 directly to 5V (no diode)... and now I'm getting 4.4V on L293D outputs, which is lots better than before (3.7V).
So I should also put Enable pins on +5V without a diode?

12-30-2005, 07:08 PM
ya, conect pin 1 to 5v without a diode...
if u getting 0 and 5v across the motors, then it shud move.....
wat is the current ratings of ur motors????

unimatrix
12-30-2005, 07:34 PM
I haven't actually plugged the motor yet as it didn't work before on 3.7V, I only have 2 diodes to show the dirrection of the current. I also haven't bypassed the diode for Enable pins yet (my solder got fried, and I'm about to go buy a new one).
Though now the current rating is 1.35A (The accumulators have 5A alltogether).

12-30-2005, 07:49 PM
hello!!!!!!!!!!
tat driver supports a max. current of .5amps only.
if ur motor is driving more than tat, it simply wont respond.

1.35amps is too much to even connect two channels in parallel.

go for l298, it supports 2 amps of current.

check the soldering properly and verify the voltages in all the pins in run time.

and test everything after connecting the motor and post ur observations....

unimatrix
12-30-2005, 08:27 PM
Woops, sorry.. I didn't measure it correctly (n00b :oops:)
I have 2 motors, one has 0.1amps and the other is 0.05amps.
Then that shouldn't be a problem for L293D.

unimatrix
12-30-2005, 09:04 PM
Okay I finaly soldered the Enable pins directly to +5V (no diode), and it now the output on L293D is almost identical to the voltage of the accumulators. That's good. But there's still the other problem. Instead of 0V there's still 0.56V. Where does that come from? The motor doesn't start because of this.

unimatrix
12-30-2005, 10:12 PM
Status update:
This is driving me nuts... it won't work.
Well, it works if I connect 2 LEDs to L293D's outputs. It shows the current dirrection perfectly. But when I plug up a motor everything just "crashes". It doesn't start, or does, but then doesn't stop, etc.. PIC has strange voltages on output pins (like 1.6V or 2.4V - ??).
I'm probably being cursed, how can this not work??

devpriya
12-30-2005, 11:02 PM
Dont worry its all happening due to loading effect of the motors which may be resetting the PIC.

So do one thing, drive the L293D with a different accumulator and PIC with a different one but donot forget to make their Grounds common(both accumulators).

12-30-2005, 11:30 PM
do a few things..
first as dev said, check common gnd...
if ur gnd is at 0v, there is no question of getting .5v at the gnd terminals of l293dne.
2nd thing, i said u tat connect a buffer{74244} between ur mic and l293dne...
this ll give u clear logic with gud current drives.

Well, it works if I connect 2 LEDs to L293D's outputs. It shows the current dirrection perfectly. But when I plug up a motor everything just "crashes"
tat means the motor is oading the ckt.
check the values of vcc and gnd after u connect the motors.
i think it ll fall way below 5v.
and check the voltages at all the relevant pins of l293dne.

unimatrix
12-30-2005, 11:44 PM
check the values of vcc and gnd after u connect the motors.
i think it ll fall way below 5v.
As you said addy, the Vcc voltage really did fall to about 3.7V.
I'll try with the buffer, but I have to get (and find) it first.

So do one thing, drive the L293D with a different accumulator and PIC with a different one but donot forget to make their Grounds common(both accumulators).
I'll try that too. And by the way... can I do that even if the accumulators' voltages are different (for example 5V and 12V) ?

Thanks for helping me so far guys, u're the best! :)

12-30-2005, 11:54 PM
the Vcc voltage really did fall to about 3.7V

r u using 7805 regulator for 5v???
becoz there r certain 7805 whose voltages falls on loading and u cant do anything about it.

i encountered this prob a few days back ..
using a buffer wont solve ur this prob{i feel}.
anyway try and give a feedback.
if u have a smps, then do one thing, use 5v directly from smps so tat it doesn reduces....

unimatrix
12-31-2005, 12:06 AM
Well, as stupid as it may sound, I'm not using a battery regulator at all. It might not be a bad idea. Which one do you suggest? (I'm guessing it's not 7805).

12-31-2005, 12:24 AM
if u r not using a regulator...
then r u using 5v battery directly????
it may be discharged to some extent which may cause fall in voltage.
so try the 5v supply of a smps....
by the way, does ur motor runs freely at 5v directly supply without any driver?? and if yes, then how much current is it drawing???

unimatrix
12-31-2005, 12:33 AM
Yeah I'm not using a regulator, that's why I used the diode.
And yes the motor runs freely, and it draws 0.1amps of current (pulled it out of a 4.8V servo).

devpriya
12-31-2005, 12:40 AM
Hey regarding your query that whether you can use two different batteries or not? Yes you can , just make the grounds common.

Seperating the batteries for driving the motor and the PIC board will definetly help you.

Moreover , as Addy said , try SMPS output as it will not fall down even on loading. But still a .1 Amp motor shouldn't pull your battery output to such an extent. This means your batteries are severely dischared and need to be recharged .

Try with some fully charged battery........well whats the Ampere Hour rating of the batteries which you are using ?

12-31-2005, 12:46 AM
hey then all ur connections r proper....
just recheck ur connections and tell me wat output u r getting at the pin 3 and 6 of l293dne....
one more thing, don load ur motors at the first place..
drive them freely.
and try another spare l293dne{if u hav one}.

unimatrix
12-31-2005, 12:56 AM
just recheck ur connections and tell me wat output u r getting at the pin 3 and 6 of l293dne....
I'm getting 3.38V (when the motor is running, otherwise it's around 0.05V). If I unplug the motor, I'm getting +4.45V or -4.45V (depending on the Input values).

and try another spare l293dne{if u hav one}
Yup, I have another one.. and the result is the same.

I'm using 4 serially wired 1.2V accumulators. 2 of them are 1400mAh and 2 of them are 1600mAh. And I don't think they're empty yet because there's still 4.99V in them. They should be empty at 4.8V.

I will try seperating the 2 circuits, but just to test it. I will need it to run on one circuit though. I'm trying to build a simple robot which can't really contain infinite packs of batteries if u know what I mean :)

12-31-2005, 01:07 AM
oh!!!!!!!!
ur prob. is really gettin thicker....

anyway i ll revise the pin connections jus for the sake of assurance..
pin 1,16 and 9 t0 vcc{5v}.
pin 8 to the motors supply....
2 and 7 to inputs{coming from mic via a buffer}
3 and 6 to motors...
and 4,5,to gnd.
this works for me pretty well.

don use two different batteries..... there might not be impedance matching which ll result in loss of power. use batteries of same kind or still better, use a smps.

u don need to separate the supplies.... it works with the same supply nicely.

jus cool ur head and try once again from the begining and see wat happens.

unimatrix
12-31-2005, 01:30 AM
You only grounded 2 out of 4 GND pins of the L293D(NE)? I've grounded all 4 of them, even though i'm only using one side of the chip. Could that be a problem?

Okay now I've tried 4 same accumulators (4x2100mAh), and I don't think this was it. It's the same as on my previous batteries.

And about the SMPS, I don't really own one, so I'll have to borrow it from a friend tomorrow.

12-31-2005, 01:42 AM
no, absolutely no probs if u have grounded all 4 terminals....and r using only one channel.{gud tat u noticed it}

and i would still suggest using a smps, get it from ur friend tomrw.
becoz i still don rely on those batteries.otherwise it has to work.
do one more thing, get one more small tape motor and try running it too..
try now only if u have one, or else buy one tomrw and try.

so give it a try tomrw and lets hope a new day brings some untold solutions to ur problems....

docel
12-31-2005, 02:58 AM
Okay, I've tried sth else...
Before I didn't connect the Enable pins to 5V... I just left them blank.
Now I'm getting readings as following:
Input1=5V,Input2=0V --> Output1=5V,Output2=0.56V
Input1=0V,Input2=5V --> Output1=0.56V,Output2=5V

How in the world can this happen?
Where did the 0.56V come from? It should be a damn 0V! :)

I thank you in anticipation.

Hi folks!
You CANNOT expect "0V" as a logic level or as Output.
Unless you measure between -ve and gnd!! :wink:
The 293's are working fine, leave it at that.
To explain, you are measuring voltage between -ve or gnd and output. This can never be "0" as you are actually measuring between O/P transistor grounded emitter and its collector.
The true lo will be ~.6v.
Another thing: never connect +5 v and "0" to enable and 'in". there should be a pull-up resistance of 10kohms. Then the correct V at enable will be 3.6v.
+5v will degrade the L293 over time. It will also oscillate at times leading to motor "chatter".

unimatrix
12-31-2005, 02:43 PM
Latest update:
I've tried the SMPS. I never expected this, but the SMPS was not it either.

You CANNOT expect "0V" as a logic level or as Output.
Unless you measure between -ve and gnd!! Wink
The 293's are working fine, leave it at that.
To explain, you are measuring voltage between -ve or gnd and output. This can never be "0" as you are actually measuring between O/P transistor grounded emitter and its collector.
The true lo will be ~.6v.
Okay, I can understand that. I just didn't expect the low state to be so ... high :) I thought it would be dunno, 0.1V maybe... Well OK at least that's not a problem then.

Another thing: never connect +5 v and "0" to enable and 'in". there should be a pull-up resistance of 10kohms. Then the correct V at enable will be 3.6v. +5v will degrade the L293 over time. It will also oscillate at times leading to motor "chatter".
I hear that for the first time. Nobody I know ever puts a resistor betweeen those pins.

I have another idea... My PIC has 2 GND pins and 2 +5V pins... I wired the pairs serially... could this have sth to do with the prob? Well I'm going to try re-wiring them parallel anyway. EDIT: Tried it. Not it.
And I've tried the tape motor too (it's 12V and uses 20mA). It didn't move and the voltages on PIC were very strange (for example signal lines were 1.6V on one and 3.2V on the other).

And I think I've just found a problem. I was so eager to simplify things that I didn't wire the oscillator correctly. I just connected it dirrectly to the pins (no capacitors and grounding). The motor is probably causing great disturbence to the oscillator. This is gonna be my next step :)

docel
12-31-2005, 07:18 PM
hi uni..,
First thing youy must do is maintain a clean Pwr supply lines. Certain principles of bypassing should be followed, to keep signal lines and power lines separate. The idea is to keep the signals lines as signal lines. Especially so with inductive loads, which will 'produce' all kinds of unwanted,unplanned and unthought of currents (signals). Simply put, Back emf. Also, these currents are AC and will act like a 'broadband' transmitter!.... with f+n harmonics. As they are AC, they are EM Radiations and will wirelessly couple back or 'feed back' into the S input line.
These spurious signals should be eliminated with careful bypassing.
Simplke rules:
1. Capacitors for low and high freq. AT THE IC power PINS. Values of 10ufd for low F and .o1 to .1ufd for hi freq bypass.
2. Logic inputs should "see" some voltage , which is greater than the signal voltage. I said Logic. This means 0v or +Vcc. This will depend upon the logic gate : active Hi or active Lo. We call this 'pull-up" or 'pull-down'.
This will ensure that the input is a pure logic gate and will not respond in an analog manner, unless the input is <1.25v or >3.6V.
3. Always put a non-polarised cap of some 1ufd accross the motor terminals. This will reduce the back emf finding its way everywhere through the power lines.
4. Logic circuits will misbehave <4.5v and >5.5V, the ideal being +5V regulated. They might work, but will be erratic.
5. Power leads must be 'twisted' together, as also motor feed lines. This will reduce the EMR.
6. Most electronic circuits 'work' through sheer luck. This is OK. But if it does'nt...? This will need real trouble-shooting, which may be quite frustrating to a begginer or hobbyist with minimal test facilities.

These are the reasons which bother the hobbyist. Reliability of a circuit will be and can be guaranteed by following these simple rules.
:x These........unfortunately, are not taught in Colleges... :cry:

unimatrix
12-31-2005, 09:48 PM
Hello everyone!

I can't thank you enough for your efford!
But let's take a break now. :)
I wan't to wish you all a Happy New Year !!! :D

01-01-2006, 12:28 AM
sorry unimatrix....
couldn come online today....

anyway, did ur problems got over..???
and one thing tat i ll like to assert u is tat as docel said, do have a cap between vcc and gnd and also across the motors... they r imp.

unimatrix
01-01-2006, 08:46 PM
OK, I've put the caps on the oscillator and wired it to GND... no difference.
So if I understand correctly, now I have to put a 100nF cap on my battery's positive and negative side (Vcc and GND)... Just like it says on a scheme I found. Well I tried that, but there is no voltage coming through that capacitor. And the capacitor is not broken because it's brand new... in fact I have a dozen of them and they're all the same.

01-01-2006, 09:13 PM
try giving 12v in the pin no.8 of l293dne.....
drive the motor from 12v supply and see the response..

unimatrix
01-05-2006, 11:45 PM
OK, I've had little time lately, but I just can't quit doing this... it's really bothering me why the damn thing isn't working :)

I've put caps on the circuit everywhere I could think of... Still no change.
I understand now that the motor (the LEDs work fine) is producing some disturbance in the circuit, which makes PIC work incorrectly. The moment I unplug the motor, everything works fine.
The motor though, instead of changing dirrection, just jumps a little and continues rotating in the same dirrection. The voltages on L293D's outputs are constant (cca 4.8V on one and 0.55V on the other), and so are the voltages on PIC's signal lines (even though the dirrection should change). It's like PIC resets every time it should change the motor dirrection.

01-06-2006, 02:53 AM
ahhhhh!!!!!!!!
now i think i got wat ur problems r....
jus check the vcc whenever u turn on the motor or whenever u change the direction of rotation{i m assuming tat u r giving a small delay in the forward and backward turn }...
if it falls below the rated value{consult the datasheets of pic}, it ll reset ur mic everytime....

The voltages on L293D's outputs are constant (cca 4.8V on one and 0.55V on the other),
check if the inputs coming to l293dne is corret or not{ i mean they should be reversed for opposite directions}... if they r not changing, then remove the mics outputs from l293dne and measure the floating value of the output {without disturbing the setup}. i want to know whether the pic's output is getting loaded{less pobability} or not.....

docel
01-06-2006, 11:01 AM
hi,
unimatrix, it will save a lot of effort if you can post your circuit diag. with the exact values. It will make it easier.

01-06-2006, 03:29 PM
gud move docel.....
will save a lot of time and misconceptions...
do it unimatrix........

unimatrix
01-06-2006, 10:08 PM
Heureka! It finaly works! :D
It was the Brown Out Detect! I never thought of disabling it (never before needed to anyway). Of course the motor caused some disturbance and PIC reset itself because of the smallest voltage drop.

Oh, about the circuit diagram... Would've posted it long ago... If I had one :roll:

Anyway I'm very gateful for your help. I've learned a lot here :)

docel
01-06-2006, 11:47 PM
.
:wink: :!: :!: :lol: :D :D :D

Oh, about the circuit diagram... Would've posted it long ago... If I had one

01-07-2006, 12:20 AM
'''EUREKA'''
finally after three pages of inside out discussions ur thing got going....
nothing is sweeter than success....

Oh, about the circuit diagram... Would've posted it long ago... If I had one

wat u mean by tat dude?????//
make one in ur comp. and post it...

best wishes......

devpriya
01-07-2006, 12:42 AM
Hey Unimatrix , if you are a beginner then start making circuit diagrams because once you catch this habit like me then you may also waste one month just because of missing one pin connection.

I just didn't pull up my uC reset pin in my programmer and it took me 1 month to recognize that prob.

So buddy drop this habit and cheers as your motor is moving now !!!!

docel
01-07-2006, 01:43 AM