I have the following schematic:


Vcc can vary from 12 to 15 volts, so the design was intended to switch on the relay through a MOSFET when the input voltage is over 13.4 volts. The actual Zener I've used has a Zener voltage of 6.9 volts, so the comparator output should turn on at 13.8 V. However, two things are happening that I cannot explain:

  1. There is some hysteresis in the circuit. The relay turns on at 13.8V, and switches off at 13.4. I've checked with a DMM at the comparator output: when below 13.4V it is almost 0, when in between 13.4 - 13.8 it is turning to ~7 volts, then increases as I increase the input voltage. How can I explain this hysteresis, and how can I control it?

  2. Once I forgot to put flyback diode D2 in place. The scheme worked OK, but hysteresis narrowed to 0.1V, from 13.7 to 13.8V. Then I decided to use an LED instead of a regular diode, so I replaced D2 with an LED (1.8V forward drop). So with the LED, hysteresis is back to 13.4 - 13.8 volts, and the LED is lighting in this interval, going from dim to bright, then turning dark over 13.8. If I switch off the power supply, the LED produces a flash as the relay clicks.

I guess these two facts are somehow connected. Please help me explain how and why?


So the suggested scheme is as below?

Second schematic

I should swap the inputs, connect the open Emitter to GND, and use a pull-up resistor between Vcc and open Collector/MOSFET Gate?

My second question is still in place - how to add and control a hysteresis to this scheme?

  • \$\begingroup\$ In addition to the primary issue with the open-collector output, it also appears that you have pins 5 and 6 connected to each other, but without tying them to Vcc (either directly or through a resistor network) as advised by the datasheet. I'm not sure, but this might have the effect of significantly reducing the open-loop gain of the comparator. \$\endgroup\$ – Dave Tweed Jun 18 '18 at 12:44
  • \$\begingroup\$ @Dave Tweed I'm reading a datasheet from here: ti.com/lit/ds/symlink/lm311.pdf. Page 15 says: If offset balancing is not used, the BALANCE and BAL/STRB pins must be unconnected. It is also acceptable to short pins together. \$\endgroup\$ – Zhenek Jun 18 '18 at 13:00
  • \$\begingroup\$ @Zhenek Which simulator is that you use? Altium? Or just drawing? \$\endgroup\$ – atmnt Jun 18 '18 at 13:05
  • \$\begingroup\$ @atomant I don't use simulator. I've assembled my initial design on a breadboard, and use a lab power supply as an input. The schematics are drawn in DipTrace \$\endgroup\$ – Zhenek Jun 18 '18 at 13:16
  • 1
    \$\begingroup\$ @atomant I don't think talking about the software is going to help anything. Doesn't really matter what software people use to draw schematics, as long as it is drawn well enough for us to read it. \$\endgroup\$ – MCG Jun 18 '18 at 14:03

The LM311 has an open-collector output. You need to connect the open emitter to ground, not VCC, and provide a pullup resistor on the open collector output.

Don't try to use an LED as a flyback diode. Use a diode with a high surge current rating.

  • \$\begingroup\$ But in this case, how can I continue to use N-channel MOSFET? \$\endgroup\$ – Zhenek Jun 18 '18 at 12:37
  • \$\begingroup\$ @Zhenek After you have rebult to pull-up or changed the LM311 for something else, yes. \$\endgroup\$ – winny Jun 18 '18 at 12:42
  • 1
    \$\begingroup\$ First, the FET will work just fine with a pullup and no pulldown - the comparator will act as the pulldown to drive the gate to zero when necessary. Second, LEDs are not usually rated for reverse voltages greater than about 5 volts, so you definitely need to replace it with a proper (higher current) diode. \$\endgroup\$ – WhatRoughBeast Jun 18 '18 at 12:43
  • 1
    \$\begingroup\$ fixes may be easy or even obvious, but try to explain the behavior of dimming LED and hysteresis , so he understands that he has created a PWM circuit with hysteresis. That was his real question. I feel the points are just indications by newbies to say , I knew that or I didn't know that. \$\endgroup\$ – Sunnyskyguy EE75 Jun 18 '18 at 13:31
  • 1
    \$\begingroup\$ Yes your suggestions are good, but he explained an interesting linear gain with brightness with incorrect use of LED but it shows that it was unstable with oscillations like PWM on a comparator prone to this and perhaps high ESR supply that drops voltage with coil current creating some comparator hysteresis. The relay also had 50% hysteresis so the PWM threshold noise would make the LED dim indicating average output voltage. Also his original Q. was “to explain behaviour” \$\endgroup\$ – Sunnyskyguy EE75 Jun 18 '18 at 15:08

Your Answer

