• Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

L298 Short-circuit protection

stevenh

Member
To everyone, from a fairly uneducated newbie :)

I've just recently completed a DCC (Model Railway Command Control) Booster Circuit of which I can successfully control my DCC-equipped trains from my com port. A schematic of the circuit is here: [See attachment: 941202_s.gif]

I've realised one huge issue though... if the tracks happen to short then things start either cooking or exploding; which, as you could imagine, is not the result I'm after...

I'd read the information on page 3 of this document [See Attachment: 1681.pdf]
and attempted to apply it between '1EN' and the L298 but to no avail...

I then saw a similar circuit here: [See Attachment: bstr-1.gif]
that ties the 'current sense' pin to ground with a huge 0.47/5Watt resistor but also feeds it back into a TL072 to disable the input (although it doesn't seem to control the actual '1EN' pin?)

Due to a lack of knowledge though, I have no idea how to combine this into the current schematic as the 'current sense' pin is already tied to the feedback circuit and the '1EN' is tied into the 555 timer to only enable the output on data input...

I imagine I need a way of combining the 555 input into an AND gate of some form? Or something similar to only enable when the current sense is minimal? 3-4A would be a good current rating... but anything above 1A is great.

I'm currently using a ~13.8v DC transformer to power the circuit.

Any help would be greatly appreciated :)

(Apologies for attaching everything... I couldn't post links as it's my first post?)

Thanks, Steven.
 

Attachments

Last edited:

MrAl

Well-Known Member
Most Helpful Member
Hi there,

From the sound of it, the first thing you should do is verify that you are able
to DISABLE the bridge with the enable pin. Make sure when you switch that
high and low that the output turns on and turns off as it should. Get this
working first.
Next, you can build a simple 'pulse catcher' with two sections of LM339 alone.
The idea is that the first LM339 will catch a current pulse (or level) that is
too high and trigger the next LM339 section, and that will turn off the enable
signal to shut off the bridge. The bridge will then stay off for a certain period
determined by the capacitor and resistor you use on the output of the first
LM339.
The .47 ohm resistor (if that is appropriately sized) drops some voltage and
that is sensed by the first LM339 setup to detect a voltage level I/0.47, and
the output of that stage is a cap to ground and resistor to V+. When
the LM339 trips, it discharges the cap, and that is sensed by the next
stage. Once the current goes back to normal or lower, the cap starts
to charge up and after some time the bridge is switched back on.
If the problem still exits, the bridge is shut down again, etc., and this
repeats until the problem is corrected. Since the delay time can be
made large (100ms or even longer) the bridge does not heat up.
Total devices required: one LM339 package and a few resistors and
one capacitor say 0.1uf or so.
 

stevenh

Member
Ok,
So the LM339 sees the reference voltage at the negative input (of each comparator) and as long as the voltage at + is lower it will keep the output pinned to ground (or low...)

So what I would need to work out is how to make sure that when over-current occurs the sense pin will raise the voltage to above a certain level... Should I slap a multimeter on there and short the circuit out briefly to measure what comes through?

I've made up a design to incorporate these two comparators and it sorta makes sense to me but the resistors required are beyond me.

I would imagine the initial feed from the 555 circuit needs to be lowered from +5v since that's the comparative voltage and I don't know if the voltage out of the current sense pin will exceed that?

Also, the 0.1uf cap will provide the timing... 100ms = 0.1uf? I'd nearly like the timeout to be 1000ms since times to find faults would exceed this easily and I'm happy for power to be cut off for longer periods.

Another nice advantage would be an LED when the voltage is cut... is there a chance to use an inverter between the two comparators (as the 7404 has been doing, although it's all used up) to slap an LED in (as seen in the 555 circuit) to show the overload status?

Thanks again for your help.
 

Attachments

Last edited:

MrAl

Well-Known Member
Most Helpful Member
Hi again,


Do you know how to calculate resistor dividers to get a lower reference
voltage from a higher voltage like 5v?

The idea is to make the first comparator section sense the voltage across
the 0.47 ohm resistor so you need one divider set to that voltage, and
that gets compared to the sense voltage (voltage across 0.47 ohms resistor).
That discharges a cap and the next comparator senses that and disables
the L298. No 555's required.

The charge time of a resistor and capacitor is equal to the time constant
(sometimes simply called TC) and that is the time it takes the cap to charge
to 63 percent of the supply voltage. If the supply voltage is 5v, then
63 percent of that is 3.15v, so we would make one divider that produces
a voltage of 3.15v and apply that to one comparator input. One time
constant is easy to calculate too so we can figure the cap value and its
resistor: 1 TC=C*R, with C in farads and R in ohms. It takes t seconds
for the cap to charge to 3.15v then t=1TC=C*R. With a 1uf cap and
100k resistor this works out to 0.1 seconds (100ms). If you want 1 second
then a good idea would be to go with a 10uf cap and 100k, or 5uf and 200k.
Since the cap is a bit large it would also be a good idea to beef up the
output of the LM339 with a single NPN transistor. This will speed up the
response to an overcurrent.

To test the circuit for overcurrent to see what voltage you get across
your resistor, it would be a good idea to know what the current is
normally. In other words, what is the current when everything is
working normally? You would want to measure the voltage across the
sense resistor when the current is just above this level or when
whatever you are powering (motor, etc.) is running normally. You
dont want it to trip when it is running normally, but you do when
something goes wrong. Depending on the current you may also have
to switch the 0.47 ohm to something else, like 0.1 or whatever.
An adjustment would be nice too, so the current trip point could
be adjusted during some tests.


Yes adding an LED wont be hard to do.


Perhaps i should make a schematic and post it here for you to take a look
at? I need to know what the normal current draw is for whatever you are
powering first.
 
Last edited:

stevenh

Member
Do you know how to calculate resistor dividers to get a lower reference voltage from a higher voltage like 5v?
I have never really done this form of electronics math but do want to learn... am a software engineer by trade and haven't delved into hardware too much.

No 555's required.
The 555 I refer to is th e cut-off circuit that already exists on the lower half of the diagram to force the enable pin high if there is no incoming data.

The enable pin (when pulled low) does disable the output. I tested this by disconnecting the input to it and grounding it intermittently.

I need to know what the normal current draw is for whatever you are powering first.
Currently the system takes around 500mA per train on the track (but this varies depending on brand/headlights/etc...)

I'd be happy to limit the booster at 4Amp.

My multimeter currently can only show up to 200mA and when two locos are sitting still it's at 154mA and as soon as I set a throttle or headlight on either the multimeter just shows "1" since it can't go any higher.

I'm about to slap the multimeter on the 'current sense' pin and see what happens when I short the tracks.

Voltage on Pin 1 rises to 0.91v when the tracks are shorted
...this would mean that I need to lower the input voltage into the first LM339 + to anything between 0.1 and 0.5 (as the voltage on pin 1 climbs gradually, although quickly, to 0.91) ??



Thanks heaps for your help on this.
 
Last edited:

MrAl

Well-Known Member
Most Helpful Member
Hi again,



The output voltage of a resistive divider is calculated as:

Vout=Vin*RLow/(RHigh+RLow)
where
Vin is the voltage applied to the top of the divider
RHigh is the upper resistor
RLow is the lower resistor

This helps to calculate trip points for comparator circuits like we are
talking about here.

If you have several circuits that need to disable the L298 for some
reason then you need to logical AND all the outputs together and
feed the L298 with the output of the AND gate. What this does
basically is says that every output must be high in order to
enable the L298. If any single one goes low, it shuts the output off.

This current trip circuit i am posting works by detecting the current
and shuts the output off for 1.1 seconds. It's ok if it cycles like
that if there is a short or something.
You do need to make sure your 5v supply remains at 5v during a short
too however.

Here's a typical schematic. Since you are already using 555's this includes one.

 

stevenh

Member
Ok, based on the original circuit above.. I have added in your trip circuit. It seems that if i remove the 'feedback' portion to the left of the sense pin 1 and just take that pin straight into your circuit then I can't get the L298 to enable.. even though there is ~3.9v outputted to pin 6 (enable).

But... leaving that feedback side connected and then joining on your trip circuit (with both the 0.47R to ground in the feedback circuit and then another two 0.47R in series as I don't have 0.5R and one 0.47R would cause it to trip too early on your trip circuit) made everything work...

I don't totally understand the implications of now having pin 1 brought to ground with the original 0.47R + 2x0.47R in this additional circuit... but I imagine it raises the 'allowed' amps through.

I'm going to leave this for tonight and might make more sense of it tomorrow... but so far so good, even if I am just applying guesswork :(
 

MrAl

Well-Known Member
Most Helpful Member
Hi again,

I think you should redraw the schematic you are using now, as the old one
isnt the same now. Also, in that old schematic i see that two of the
comparators (at least) are not connected correctly for the operation you
want.
 

stevenh

Member
Here's the latest.... cutting the circuit at the line marked 'cut' will stop the enable pin from working... i.e. the whole trip circuit just stays tripped for some unknown reason... it could also be that i'm not bringing the enable pin high enough due to my use of incorrectly valued resistors... since it turns out that my 0.47 resistors are actually 0.27R/5W... I tried adding in another 0.27 in parallel to the 2x0.27 (i.e. 0.52 in parallel with 0.27) as that's what i'm cutting off when i remove the feedback circuit but that didn't help either.

I need to source some 0.47 resistors from somewhere :(

On the up-side... everything still works great when both the feedback circuit and trip circuit are connected... I get the ~1.1s timeout and then it all comes back to life... no arching (well, buzzing) from the shorted item when across the tracks anymore.
 

Attachments

Last edited:

MrAl

Well-Known Member
Most Helpful Member
Hi again,


You see that LM339 pin 2 that is connected to the 555?
That section needs to have pin 5 and 4 swapped.
That is, connect the sense resistor to pin 4 and the
resistor divider to pin 5. Test with that circuit alone
as you did before, that's a good idea.
You should see your train or whatever run normally until
there is an overcurrent, and then it will appear to shut
off. If it shuts off when the train starts to move,
that means the current sense is too sensitive. You
might try paralleling some 0.47 ohm resistors (or whatever
you have on hand) to beef up the current trip point.
This also keeps power dissipation in the sense resistor
low too, but if that's not a problem (sense resistor does
not heat up) you can also adjust the resistor divider a bit.
Before you do that however try to get this working with
one train alone.

BTW, with that 10uf cap instead of 1uf you might get
more like 10 seconds between current 'tries', if that's
ok then dont worry about it. Note also that you may
not see this happen, because the LM339 is pretty fast,
so it would turn off fast, then turn on for possibly only
10us, then turn off again. You might not see this happen
but it will be working. Once the short is removed,
up to 10 seconds later the train will start moving again.
It may take the full 10 seconds to start again due to the
10uf cap as noted above.

If you want an LED to show when the current is being
cutback (turned off) you can connect an LED to a
2.2k resistor to +5v (anode toward +5v) and connect
that resistor to the output of another inverter, then
connect the input of that new inverter to the output
of the 555. When the current shuts off, the LED will
light. Note however that when there is a short it
may appear to stay lit and not go out, even after 10
seconds, because the pulse will be very short. After
the short is removed the LED should go out after
a max of about 10 seconds and the train should start
to move again.

There is also the possibility that when the train starts up
the surge current trips the current sense. We'll have
to deal with that too if that happens.

What power rating are your sense resistors?
 
Last edited:

stevenh

Member
That section needs to have pin 5 and 4 swapped.
You might not believe it, but that's the way I actually wired it up, as opposed to drew it :)

You might try paralleling some 0.47 ohm resistors (or whatever you have on hand) to beef up the current trip point.
2 0.27Ohm/5Watt resistors did the trick!

BTW, with that 10uf cap instead of 1uf you might get more like 10 seconds...
Another typo on my diagram, it is indeed 1uf.


...you can connect an LED to a 2.2k resistor to +5v (anode toward +5v) and connect that resistor to the output of another inverter...
I've just been playing with this tonight.. and it works great.

There is also the possibility that when the train starts up the surge current trips the current sense. We'll have to deal with that too if that happens.
this was occuring, but the parallel 0.27ohms seemed to drop the resistance sufficiently?

What power rating are your sense resistors?
0.27 Ohm / 5 Watt



And now, the latest schematic... with my attempt at AND'ing with available components.... 7401 NAND Gate. It seems though that I'm not getting a 'full' High from the NAND... it's not pulling enable high :(

edit: Seems that my outputs from the NAND are backwards ((H(good state)/H(good state)) == LOW) and running that back through the 7404 inverter doesn't work :) I'd imagine there is no source in the 7404 to provide vcc high? it just 'floats'?


edit2: I've just read from here that the outputs of the 7401 require pullup resistors... Now i'll try and determine the values, but i'm stabbing in the dark... I might just source a proper 74hc08 (I think that's the code) tomorrow and stop screwing around.
 

Attachments

Last edited:

MrAl

Well-Known Member
Most Helpful Member
Hi again,


Ok, sounds like you are making a *lot* of progress here, and that's good that
you caught the current surge problem already so we dont have to trouble
shoot that. That's great.
Now there's the thing about adding an *AND* gate. Note that this has
to be an AND gate, not a NAND gate. If you want to use a NAND gate
though that's fine, but you have to use an inverter after it (on the output)
so that the whole construction boils down to an AND gate again.

The pullups, if you still want to use them, can be 2.2k but many times for
stuff that doesnt have to be super fast (nanoseconds) a 4.7k sometimes
works too. From what i read on the web that 7401 is an 'open collector'
so you are certainly right that it needs a pullup on the output, even if
it is connected to another gate, and keep in mind that after that you
still need an inverter (7404) so that it becomes an AND again.

I think you will soon be done with this thing, and perhaps happy with it too :)


BTW, thanks for redrawing that schematic. That helps me understand
much better what you are doing so we dont have to talk back and
forth for 100 years just to figure out the circuit needs this or that.
Please note however that i did not verify the entire circuit, only
the part that i gave you (LM339 and 555) and the 'AND' gate soon
to come. If you have any other problems after this i'll take a
closer look, but it does look like smooth sailing from here.
 
Last edited:

stevenh

Member
Thanks for the comments... But thanks more for the help, I'd still be at square one without it.

As for the pull up resistors... I'll play with stuff like that later on individual circuits to learn the ropes instead of hacking up this circuit :)

MrAl said:
Please note however that i did not verify the entire circuit...
No problem there, the rest of the circuit is assumed to be OK.. which, although dangerous, is a choice I'm willing to make.

MrAl said:
I think you will soon be done with this thing...
Last item on the agenda is to bridge the outputs on the L298, or at least use the second one as well.
Enabling the second channel is seen here and then on page 7 of the schematic is the details for bridging the channels to allow up to 6Amps!?! (Or that's what Rod of the first link says it can handle). Of course this depends on the input DC supply.

I suppose the best option would be to leave them split and then have them just supply two separate blocks... as opposed to one block of trains with more trains... distributing the load. And then I can add in the switch to provide the programming track. (The design is the first link does this..)

Anyway, I can't thank you enough... I just wish I'd gotten off my ass and tinkered with stuff like this a long time ago instead of blindly following schematics and throwing it all out when they fail first time :)
 
Last edited:

MrAl

Well-Known Member
Most Helpful Member
Hi again,

If you have gotten this far i have no doubt you would be able to learn
just about any of this stuff, it just takes a little time that's all.
 

stevenh

Member
MrAl,
Could I just get a few pointers on this circuit...
I had 6 trains running great on it, though if they all tried to start from stopped at the same time then it'd trip the circuit; obviously too much current at once.

There are also accessory decoders which seem to suck a bit of power at startup (they have caps to store a bit of current, it seems, since they usually power solenoids which like a good kick)...
So, to test I threw the acc.decoders on and bypassed the overcurrent check... as soon as the power was fed in I enabled it in (the joys of a breadboard) and they functioned perfectly.

So, I was wondering... instead of screwing around with the sense resistor (parallelling my 0.27R 5Ws I have on hand..) I was wondering if there was a method to allow short bursts of current before tripping... i.e. can you put a delay on the 555 so that it doesn't trip instantly? or a cap on the feed line to the lm339 to allow it to soak up a bit before sending anything along?

Thanks, Steven.
 

MrAl

Well-Known Member
Most Helpful Member
Hello again Steven,


There are two approaches to this. The first way is fairly simple, the second
way is a little tricky.

The first way is to add some start up delay to the circuit so that when power
is first applied (to the circuit) it takes a while before it will actually start
protecting the output from a short. This way is straight forward but it wont
do anything if there is a large but acceptable load applied later.

The second way is to add a small delay to the output of the LM339 that goes
to the 555 trigger, in the form of a low pass filter (resistor and capacitor).
This adds a small delay before any current limit kicks in.

The problem with the first way is that any large but acceptable loads applied
later will still trip the protect circuit.
The problem with the second way is that any actual short current will last
longer than it should.

The only way that seems to be acceptable then is to increase the current limit
itself, by increasing the trip point current level. You have been doing this with
parallel resistors in the past, however there is another way.
The reason this works is because the acceptable load current (even though rather
high sometimes) is allowed to pass, but in the event of a catastrophic current
level the circuit will shut off, and it will still shut off fast. If we delay the
trigger it will allow the short to exist for a while, and depending on what the
system can take without destruction, this may or may not work.

Ok, so now the other way...
The idea is to increase the required voltage level at the input to the LM339.
Although we can not go too high with this, a little higher wont hurt as long
as the sense resistors do not overheat.
Right now the LM339 has a 10k and 1.2k on it's input. We will change
the 1.2k to 2.2k and try that next. This will almost double the acceptable
load current before the circuit trips out.
If we call the 10k resistor R1 and the 1.2k resistor R2 and the sense
resistor Rs, then:

Vx=5*R2/(R1+R2)
Vs=Is*Rs
and the trip point is when Vs=Vx, so

Is*Rs=5*R2/(R1+R2)

Solving for R2 we get:

R2=Is*Rs*R1/(5-Is*Rs)

Although we could set R2 a little higher to use a standard value.

One caution though is that we also have to be careful that we dont
exceed the rating of the L298 with Is. If we do, then we would have
to parallel two sections of the L298.

With this kind of system the driver has to be able to handle the full
power of the load, which means the driver has to be overrated.

If on the other hand, some short circuit current is allowed due
the the system power supply being able to cut back during a short,
then we would be able to add in a delay, which would take care of
the surge and allow everything else to work properly.

The way many systems work is they put out a pulse width modulation
and as the current increases the pattern cuts back, and once the
overcurrent is gone the system ramps up slowly to allow devices
that would draw a surge to start up slowly too. Because we dont
have that kind of system here we have to make trade offs.

So, the first thing to look at is just how much current do we need
to pass to get this to work? Using the formula, calculate the current
setting that would be needed. If that turns out to be too high,
then either parallel more L298's or we can give the delay network
a shot. This would be built with a resistor and small capacitor.

It might also be possible to PWM the output, but this could get
a little complicated here, so hopefully that wont be needed.

One question i have...
Did you say the system works with a short or did it blow something out?
 
Last edited:

stevenh

Member
Ok, gotcha... I'll be testing this out tonight.

As for results of shorting... I had the initial circuit (before we started extending it) on my model railway and it was shorting out without me realising (I thought it was just dirty tracks...) Before I knew it there was a plume of electrolytic smoke coming out of the box and everything was overheating. I had no spare components at the time and still haven't checked if any of the parts in that setup still work.

The 2200uf cap was the obviously casualty... I'll test out the other parts, like the L298, when I have the time.

Anyway, back to work, but thanks again for the assistance!
 

stevenh

Member
Right, after twisting a few resistors together (as the 2K2 was too high, it seems) the 'sweet value' for 2 trains and 2 accessory decoders is 1K4.

Now I just need to make sure I incorporate a heatsink on both the 7805 and L298.

Thanks again.
 

MrAl

Well-Known Member
Most Helpful Member
Hi again,

OH yes, the heatsinks will be a good idea :)
 

Latest threads

EE World Online Articles

Loading

 
Top