Maker Pro
Maker Pro

LM393 Comparator Problem

Old Steve

Jul 23, 2015
734
Joined
Jul 23, 2015
Messages
734
Forum Post Circuit.JPG
I'm hoping that someone can see what I've done wrong in this circuit, (attached). It looks fine to me, but I haven't done any electronic design for some years and must be getting rusty. It monitors a 9V Ni-Cd battery - the top comparator should go high when the battery voltage is 7.2V or higher, and the bottom comparator should go high when the battery is at 6.0V or lower.

The comparators will be connected to the 'Set' and 'Reset' inputs of a 4013, with the 'Q' output switching a P-channel MOSFET via NPN transistor to switch the battery voltage on or off to the following circuitry.
I could have gone with a single comparator with hysteresis, but this should give more accurate results. (Should)

I've built the circuit on a breadboard, exactly following my schematic. The transistors/LEds are temporary, for diagnosis, and will not be in the final circuit.

Instead of clean switching, I'm getting a slow response, with the LEDs gradually getting brighter/dimmer over about 0.2V of input voltage variation. An LTSpice simulation gives me fast switching, but the actual circuit doesn't.

Is this likely to be caused by the breadboard, and a problem that will disappear when I make a final PCB, or should I make some changes? (Maybe adding a little hysteresis to both comparators)

Any insights much appreciated. I haven't done any circuit design for many years, but thought this would be simple.....
(This is my first post here, by the way. A great forum, from what I've seen so far.)
 

Harald Kapp

Moderator
Moderator
Nov 17, 2011
13,700
Joined
Nov 17, 2011
Messages
13,700
with the LEDs gradually getting brighter/dimmer
This is possibly due to oscillations of the comparators when the input voltage is around the threshold voltage. The effect and a cure are described here in chapter 3.23.
If you have an oscilloscope, you can easily measure this effect.

May I also suggest you reduce the values of R10 and R11? Imagine that on the output wires sits a capacitance (wiring, input of connected logic) that needs to be charged via these resistors on the low-high transistion. The higher the resistance, the lobger the RC time constant. Use no more than 10kΩ, even 1kΩ is suitable as the input of the conected CMOS gate will draw no current and overdriving the transistors in the test setup is no issue at all.
 

Old Steve

Jul 23, 2015
734
Joined
Jul 23, 2015
Messages
734
This is possibly due to oscillations of the comparators when the input voltage is around the threshold voltage. The effect and a cure are described here in chapter 3.23.
If you have an oscilloscope, you can easily measure this effect.

May I also suggest you reduce the values of R10 and R11? Imagine that on the output wires sits a capacitance (wiring, input of connected logic) that needs to be charged via these resistors on the low-high transistion. The higher the resistance, the lobger the RC time constant. Use no more than 10kΩ, even 1kΩ is suitable as the input of the conected CMOS gate will draw no current and overdriving the transistors in the test setup is no issue at all.
Thanks for the reply, Harald.

I didn't think I'd need to add hysteresis to the comparators in this particular circuit, (trying to reduce component-count), but I'll add a tiny bit to avoid oscillations when close to the switching point.

The reason I went with 100K pull-up resistors on the comparator outputs was to reduce current consumption while the comparator outputs are low. While it's true that the 4013 CMOS inputs use negligible current, that's only relevant when the comparator outputs are high. When they're low, up to 9mA will be drawn by each resistor if I use 1K pull-ups - way too much. I was trying to keep all individual current draws below 100uA.
I could reduce the values considerably in the test circuit, but they still need to be fairly large in the final circuit or excessive current will be drawn from the little 160mAh battery.

Edit: I've attached the full schematic here, minus the transistors/LEDs, so you can see what I'm aiming for:-

WPM Receiver.JPG

Regarding the RC constant of the 100K resistors and the CMOS input, there should be no problem with switching time - the CMOS inputs are max 7.5pF, making an RC time constant of 750nS, and the PCB traces will be short and well separated so that shouldn't be a problem, except maybe in the breadboard version. Which is why I asked the question in the first place. Is there likely to be much capacitance in the breadboard? Will everything work better when I make the PCB?
 
Last edited:

Old Steve

Jul 23, 2015
734
Joined
Jul 23, 2015
Messages
734
Probably more than on well designed PCB.

Unlikely as this circuit is low speed. low power. Your breadboard will probably give you a very good idea of the workings of a final PCB.

Back to the drawing board then, I guess. I might go back to a single 311 comparator, without the 4013, and see if I can get away with 1V of hysteresis. I'll also drop the pullup resistor value from 100K to 47K to speed up the MOSFET's switch-off time.

If I can't get the performance that I want, I'll re-visit the dual comparator with 4013 method, but add a little hysteresis to both comparators.

Thanks once again for your help, Harald.
 
Top