# Open-collector comparator with hysteresis and LED indicator at output

I am trying to choose the correct resistor values to make Vout go high when Vbatt falls below 18V and go low when Vbatt rises above 20V. I've built the actual circuit and my measured values are 18.0V for the lower threshold and 19.6V for the high end. I used TI's reference design to choose the values for Rx, Ry, and Rh. Since the LM293 is open collector at the output, I read through the post here trying to account for the discrepancy between my measured upper threshold and my theoretical threshold. I believe D1 is the cause of my calculations being incorrect, but I am unsure how to analyze the circuit while accounting for it. Using the NSPW500BS model in LTspice for D1 gives me very accurate simulated values compared to the measured values of the actual circuit.

This circuit is a modification of an existing circuit, and I am restricted to only changing the five resistor values. How do I need to modify my calculations to achieve a desired range of hysteresis? simulate this circuit – Schematic created using CircuitLab

When the output of the open collector comparator is OFF then output high voltage of the comparator is determined by the LED bias resistor, the forward voltage drop of the LED by the small current through the feedback resistor into the voltage divider.

To make your analysis simpler do consider taking the LED mostly out of the equation by placing another resistor in parallel with the BIAS resistor and the LED. This additional resistor would be from the +5V to the comparator output. A good starting value would be to use 1K ohm as long as the comparator is capable of sinking the current from both the added 1K branch and the LED branch when the output goes low. At the low current that the 715K feedback resistor takes I would guess that the voltage drop across the added 1K resistor is small enough that the LED never biases on at all and can be neglected in the analysis of the high level output mode.

• Your solution does make the analysis easier. The output high of the comparator measures 3.32V without the parallel resistor. As you said, this is due mostly to the forward drop of the LED. It looks like the reason the LED does not light is due to the limited current through it due to the high values of Rh and Ry. My sim in LTspice shows this current in microamps. Looking at the datasheet for the LED, this would put the forward drop at about 1.6-1.8V (typical is 2.2) which explains the 3.32V at the output. – ET2EE40 Mar 17 '17 at 18:03
• I think my solution at this point is to adjust my calculations using a higher theoretical Vbatt until it gives me the desired actual 20V I need. Using 21V for Vbatt in my calculations changes my Rh to 600k and Ry to 46.6k. The spice sim shows an Vbatt of around 20.05 as the upper voltage that switches the comparator output. – ET2EE40 Mar 17 '17 at 18:07
• @ET2EE40 - I disagree. Place the parallel resistor and then get the proper performance. If you built the circuit in volume leaving the LED as shown above the upper threshold is going to vary from unit to unit based upon the low level current which will be different LED to LED and have a temperature dependence. – Michael Karas Mar 17 '17 at 20:54

You need to learn to do error budgets.

1) Are your 24 and 5 volt supplies exactly 24 and 5 volts? If not, what will this do to your trip points?

2) I'll assume your resistors are 1% units. Go through the various permutations of each resistor being 1% off (99% or 101% of nominal) and look at the results. Combine this with 1) above.

3) Your speculation about D1 is probably correct (at least as a factor), but there is no excuse for not determining its effect rather than speculating. With the 293 output high, exactly what voltage do you see on the output? How about when the output is low?

• Thanks for the response. 1) The 24V is a battery that is not exact, but this shouldn't be a factor. Rx, Ry, and Rh were chosen to give a hysteresis range that is crossed when the Vbatt drops below 18V or rises above 20V. Vcc is a regulated supply. 2) I am using all 0.1% resistors. 3) I am an EE student. I wish not to speculate. The main purpose of my question is to determine how to analyze this circuit with D1 present. With my current knowledge level, I do not know how. – ET2EE40 Mar 17 '17 at 0:28
• I took some measurements and the 293 output high measures 3.32V and output low measures 121mV. Vcc measures 4.988V. This 12mV difference in VCC accounts for about 100mV difference in my upper range when running the spice sim. – ET2EE40 Mar 17 '17 at 16:06
• @ET2EE40 - Presumably you mean that that changes the comparator + inpuit at high trip by about 100 mV. Since the 24 volt input has about a 10:1 attenuator, that effectiively produces about a 1 volt change in input trip. And in understanding how to model the LED at low current, a first approximation is the diode current model i = I0 e^(-qV/kT), with I0 set appropriately. – WhatRoughBeast Mar 17 '17 at 16:29

The 5V must be exact or else use a bandgap ref Voltage and just add another 1k pullup R to get 5V out.

Your desired Hysteresis is +/-1V or +/- 5.26% about mean of 19V.

## Other notes

Your ref from 24V seems to be 2V for 19Vin thus it swings 5.26% for input limits which is what the feedback thresholds must be set to from 5V. Except the comparator saturates around 150mV instead of 0 which adds considerable error, but not as much as the diode.

If 5V sags then your Vbat thresholds drop, which ought to be fixed with a 2.5V band gap ref. VOL for comparator is also 150mV nom. which also affects thresholds. 