12V LM211 Comparator oscillations

Thread Starter

jrjones

Joined Sep 14, 2015
3
Hey Everyone,
Looking for some input on a simple comparator using a TI LM211 to drive a relay.
I want to use it to turn on/off a relay to charge my accessories on my bike when the engine is running, and since my bike doesn't have an easy to access circuit that signals engine on, I wanted to use the battery voltage to trigger a relay.
When the 12V_Sense is >13.8V, the relay should trigger, and <13V turn off again.
Built the attached circuit, and when testing it, it works exactly as described above, however when I put a load on the relay side, the relay coil starts oscillating (even with varying loads, from <200mA to 5A).
I don't have an oscilloscope so not entirely sure what is going on.
I've tried adding a 10k resistor between output and the non-inverting input, but doesn't make any difference.

Any advice would be appreciated.
 

Attachments

dl324

Joined Mar 30, 2015
16,989
Welcome to AAC!

What is the nature of the voltage on the inverting input? How quickly does it change? Does it oscillate?

You need a diode to prevent back EMF from blowing the comparator output transistor.

Horrible way to draw a schematic.
 

Papabravo

Joined Feb 24, 2006
21,258
It seems you may be unaware that the open collector output of the LM211 REQUIRES a pullup resistor for proper operation. You do have a copy of the datasheet and you did read it. Is that correct? Since you are driving a coil you might also need a flyback diode as well. You should use a traditional comparator symbol on your schematic. It will be more informative than the oversize box.

ETA: some bypass capacitors from VCC to GND might also be a good idea.
 

crutschow

Joined Mar 14, 2008
34,680
You likely need to add some hysteresis (positive feedback) to avoid hunting at the trip point.
Try add a 1kΩ resistor in series with the non-inverting input, and 20kΩ between the output and the non-inverting input.
 

crutschow

Joined Mar 14, 2008
34,680
It seems you may be unaware that the open collector output of the LM211 REQUIRES a pullup resistor for proper operation.
And you seem to be unaware that he is connecting the relay between 12V and the output, so it needs no pullup resistor.

But it should have a diode across the coil (cathode to 12V), as you suggested.
 

Papabravo

Joined Feb 24, 2006
21,258
And you seem to be unaware that he is connecting the relay between 12V and the output, so it needs no pullup resistor.

But it should have a diode across the coil (cathode to 12V), as you suggested.
Maybe the coil has enough DCR, but we really don't know. It should be possible to determine how much current is going through the coil when the output is low.

I'd shoot for something less than 50mA for the output to sink.
 
Last edited:

Ian0

Joined Aug 7, 2020
10,006
You say that it should turn on at 13.8V and off at 13V, which would be an adequate amount of hysteresis, but I see nothing in the circuit to implement that hysteresis. I would expect a resistor between the zener and TP1 and another resistor between TP1 and output. This utility
http://sim.okawa-denshi.jp/en/compkeisan.htm
can calculate the resistor values.
Zeners are not perfect references, so the reference voltage will change a little as the battery voltage changes. Use a bandgap reference such as LM4040 for a better result (although 13V to 13.8V should be enough hysteresis for it not to be needed)
The two "balance" inputs should be left unconnected.
 
Last edited:

Ian0

Joined Aug 7, 2020
10,006
Here's an alternative version:
Screenshot from 2024-03-30 19-47-27.pngThe current through the internal resistor chain will probably provide enough bias current for an LM4040-5 on pin 5.
 

MisterBill2

Joined Jan 23, 2018
18,943
In addition to the earlier comments, understand that the LM211 will oscillate at several megahertz very well. So FIRST there needs to be a 0.1 MFD capacitor across the comparator power terminals, and then another capacitor across the Zener diode.
 

Thread Starter

jrjones

Joined Sep 14, 2015
3
Hey thanks for the replies.
Yes I put the relay coil as the pullup resistor. Relay draws 0.36W, so around 25-30mA, within the LM211's capacity.

I overlooked the flyback diode, had thought the relay I chose had that but must have been looking at a different datasheet when ordering, oops... That made the most difference. I still get a bit of oscillation close to the the changeover voltage, with a 1k between in series before the non inverting input, and 20k between non-inverting and output. Also added the bypass cap.

Normally this circuit shouldn't see any voltage changes except when starting/shutting of the bike.
Bike off state: 12V_Sense is between 11.5-12.5V
Bike on state: 12V_sense is between 13.5-14.3V, usually always 14.3V
So desired effect is to have the relay trigger when voltage is above 13.5V (say 13.8V), and turn off when voltage is <12.8-13.2V.

How would one calculate the hysteresis resistor values when using a zener as the ref voltage on one of the comparator inputs? I recall trying to look this up back when I first drew it up a few months ago, but couldn't really find much.
 

dl324

Joined Mar 30, 2015
16,989
I still get a bit of oscillation close to the the changeover voltage, with a 1k between in series before the non inverting input, and 20k between non-inverting and output.
That's why I asked how quickly the signal changed. Add hysteresis.
 

Thread Starter

jrjones

Joined Sep 14, 2015
3
Would it be better to use the zener as a voltage supply with a voltage divider for the hysteresis?
Or is there a way to calculate the appropriate resistor values when using a zener as a fixed reference?
 
Top