3
\$\begingroup\$

I have the following circuit. U26 is a simple unity buffer and U15 is just a dual comparator.

I want the top comparator to compare the battery voltage (VBAT/2) on the inverting input with 2.0V reference on the non-inverting input. I also want 50mV of hysteresis. For some reason, pin 3 is sitting at 2.8V and pin6 at 2.4V. I figure it has to do with the Req of R13, R14, and R16 but I can't seem to figure out how to get the equations to work to make pin three of U15 2.0V and have hysteresis.

Likewise, I want the bottom comparator to compare VBAT/2 with 1.70V on the inverting pin and have 50mV of hysteresis made with R22 and R23.

The equations and how to derive them to get pin 3 at 2.0V, pin 6 at 1.7V and 50mV of hysteresis for each comparator will be accepted.

The output is just 3 LEDs where only 1 can be on at once, being on when the output of the comparator is low.

EDIT:

So what I got working was to multiply R21, R22, and R23 by 10. This gives me the desired effect. I see no downsides to this method? I still can't derive the equation that figures out the voltages at pins 3 and 6 though.

enter image description here

\$\endgroup\$

2 Answers 2

2
\$\begingroup\$

Assuming you have some buffering so the comparators swing exactly 5V.. solving numerically to minimize the error squared of the two thresholds and the two hysteresis (using solver software)

R13 = 30.000K (defined)

R14 = 2.923256628K

R16 = 16.07788776K

R21 = 1142.70829K

R22 = 1061.133891

Obviously you could scale those values higher or lower. I happened to pick an exact value for R13, based on arbitrarily making the divider current about 100uA and thus having feedback resistors in the 1M ohm range.

That makes the voltages at pins 3 and 6 2.000 and 1.7000 with both outputs high- with the respective output low they each will switch 50mV lower- 1.9500V and 1.6500V

I simply calculated the current voltages given resistor values (assuming both outputs high), then calculated the two (high and low) resistances looking into the divider from R21 and R22, and from there the hysteresis with a 5V change- 5 * Rthev/(R21 + Rthev), for example.


To roughly estimate the resistor values, you can ignore the feedback (we know it's relatively small voltage change), assume a divider current of (say) 100uA and then you know that:

R13 = (5V - 2V)/0.1 = 30K

R14 = (2V - 1.7V)/0.1 = 3K

R16 = (1.7V)/0.1 = 17K

Just roughly, looking into the node at pin 3 and ignoring R22, we see R13 || (R14 + R16), so the feedback resistor R21 should be roughly 4.95/0.05 = 99 times higher, or about 1.2M. Similarly, looking into the node at pin 6 and ignoring R21, we see (R13 + R14) || R16, so R22 should be around 1.1M.

As you can see, those guesstimates are not far off at all, and it's possible to just fiddle a bit with them in Spice and get close enough that (say) 1% resistor tolerance will dominate.


C14 is a really bad idea- the op-amp will oscillate, also C21 and C22 are not a good idea either. To get the output to snap you should not delay the feedback.

\$\endgroup\$
9
  • \$\begingroup\$ Where I got stuck is "(assuming both outputs high)" I see that it makes R21 a parallel connection with R13 but why do assume it is high and not low? \$\endgroup\$
    – ACD
    Commented Jan 14, 2015 at 13:53
  • \$\begingroup\$ Okay, you get to pick whether you want the hysteresis is centered, off to one side, or off to the other side (or something else). You did not specify, but the implication was that you wanted switching at the listed thresholds when the input was within the 'window' between 1.7 and 2.0V, with hysteresis before it would return- in that window (for example, at 1.85V) both outputs are high. It's an arbitrary choice, and making a different one would change the resistor values slightly (and the numerical solution would require different equations) \$\endgroup\$ Commented Jan 14, 2015 at 14:01
  • \$\begingroup\$ Cont'd. Remember there are actually four switching points here - I happen to have chosen 1.65/1.70/1.95/2.0 (which requires the outputs to be high for the higher switching points- positive feedback). From your information, one could as easily have chosen 1.675/1.725/1.975/2.025, or 1.70/1.75/1.95/2.0. Since the specification is ambiguous, in a real project that (and some other things, for sure, such as tolerance, which I didn't touch on, and output loading, for which I mentioned the assumption) would have been clarified before cranking out a design. \$\endgroup\$ Commented Jan 14, 2015 at 14:09
  • \$\begingroup\$ Before I kill the program I plugged in the values for centered hysteresis and got these: 30 3.501347054 16.75639954 1188.188893 1097.535567 \$\endgroup\$ Commented Jan 14, 2015 at 14:16
  • \$\begingroup\$ So you can technically solve it with the output low as well, and combine the equations to get any desired hysteresis window? \$\endgroup\$
    – ACD
    Commented Jan 14, 2015 at 14:34
2
\$\begingroup\$

In the absence of contribtutions from R21,

V(pin 3) = 5 x (56.2k + 10k)/(56.2k + 10k + 100k)

V(pin 6) = 5 x (56.2k)/(56.2k + 10k + 100k)

Furthermore, the hysteresis at pin 3 will be about 10 times greater than you think.

Including the effects of R21, and ignoring the effects of loading via the GREEN LED,

for high input voltage, V(pin 3) = 5 x (56.2k + 10k)/(56.2k + 10k + 50k)

for low voltage, V(pin 3) = 5 x [(56.2k + 10k) x 100k) / [(56.2k + 10k + 100k)] /([(56.2k + 10k) x 100k) / [(56.2k + 10k + 100k)] + 100k)

Then, in both cases, V(pin 6) = V(pin 3) x 56.2k / (56.2k + 10k)

A number of suggestions -

1) Get rid of C14. It will likely cause stability problems for U26. If you must do some filtering, put it in parallel with R29.

2) Get rid of C21. Its low-pass filtering will interfere with the snap action that you want from the R21 positive feedback.

3) ETA: Your logic only works if your LEDs are connected anode to +5. If you try to drive to ground the logic reverses and you'll have 2 on at any time.

4) Divide R13, R14 and R16 by 100. Then insert a 2k resistor between the junction of R13/R14 and pin 3. Even better, don't cut the resistor values, and don't get rid of C21, but buffer the R13/R14 voltage with another op amp voltage follower just like you're doing with U26, and feed that to pin 3 with a 2k resistor.

\$\endgroup\$
8
  • \$\begingroup\$ The LEDs are on when the output is low, not high. When the input is high, GREEN is low, when the input is low, RED is on. When the input is in the middle, BLUE is on. \$\endgroup\$
    – caveman
    Commented Jan 14, 2015 at 3:49
  • \$\begingroup\$ "The LEDs are on when the output is low, not high." Actually, that's not clear - he doesn't show the LED connections, and CMOS (including these comparators) will drive LEDs high just fine, thank you. But the point is well-taken, and I did mess up the logic. I've edited. \$\endgroup\$ Commented Jan 14, 2015 at 4:03
  • \$\begingroup\$ caveman was right in his assumptions. I didn't spend much detail there as it's not important. When I multiply R22, R23, and R21 by 10 the circuit works as desired. I still don't get how to calculate the voltage at those nodes though. I can see your equations are right but I can't see how you derived them. \$\endgroup\$
    – ACD
    Commented Jan 14, 2015 at 4:07
  • \$\begingroup\$ For V3 - without feedback. R14 and R16 can be lumped into a single resistor. Then V3 is just a voltage divider from 5V to ground. Likewise for V6 - lump R13 and R14 into a single resistor, then consider this and R16 a simple voltage divider. For V3 with feedback, the voltage divider remains in place with a 100k in parallel with one leg or the other to +5. And V6 is just a voltage divider of R14 and R16 from V3. \$\endgroup\$ Commented Jan 14, 2015 at 4:39
  • \$\begingroup\$ @WhatRoughBeast Oh, how do you draw the conclusion that the feedback resistor is in parallel with 5V and the other leg, I'm really having trouble visualizing that part? Also, do you see any downside to my proposed solution? \$\endgroup\$
    – ACD
    Commented Jan 14, 2015 at 4:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.