0
\$\begingroup\$

I am trying to make a light sensing circuit which has hysteresis.

I want an op-amp (LM358) to output logic 1 (12v) when the light level rises above 250 lux, and output logic 0 (0v) when the light level drops below 100 lux. The hysteresis should be enough to prevent small, insignificant changes (~1v) in the light level from abruptly flipping the output.

I made a simple potential divider to get my threshold voltages for the LDR I was using:

schematic

simulate this circuit – Schematic created using CircuitLab

I measured:

  • At 250 lux, the voltage is 5.27v.
  • At 100 lux, the voltage is 3.4v.

I have then created the following Schmitt Trigger circuit schematic:

schematic

simulate this circuit

My problem is that I have no idea how to calculate R2 and R3, and I don't know what Vref I should pick! I would much appreciate some guidance on how to create this circuit.

Thank you

\$\endgroup\$
4
  • \$\begingroup\$ You should begin by defining what voltage corresponds to "small, insignificant changes". In other words, how much of a change in voltage should the circuit ignore? \$\endgroup\$ Commented Mar 15, 2019 at 18:52
  • \$\begingroup\$ @ElliotAlderson Thank you for your comment, I would say 1v would be appropriate. \$\endgroup\$
    – Billy
    Commented Mar 15, 2019 at 18:55
  • \$\begingroup\$ So if the light level goes to 250 lux and the voltage reaches 5.27V you want the op amp output to go high, but if the light level then decreases the output of the op amp should stay high until the voltage falls to 4.27V. Is that what you want? \$\endgroup\$ Commented Mar 15, 2019 at 19:11
  • \$\begingroup\$ @ElliotAlderson Pretty much, yeah! And if the voltage drops below 4.27v, the op-amp should stay high until the voltage rises above 6.27v. \$\endgroup\$
    – Billy
    Commented Mar 15, 2019 at 19:13

2 Answers 2

0
\$\begingroup\$

I can tell you a general procedure that should get you close.

First, find a value of R1 that gives you 6V across R1 when you have 250 lux. Set Vref at that value, 6V. Now we assume that you want the op amp output to go high when the R1 voltage rises above 6.5V and go low when the output voltage falls below 5.5V.

Assume that the output is high (12V) and you want it to go low when the voltage falls below 5.5V. Assume that R2 and R3 are much larger than R1, say 50X bigger so that they don't have much influence on the voltage across R1. Now, R2 and R3 form a voltage divider between the 12V op amp output voltage and the 5.5V across R1. You want the voltage at the non-inverting op amp input to be 6.0V at this point, so the op amp output will fall if the R1 voltage gets any lower. So you need 0.5V across R3 and 6.0V across R2. They have the same current flowing through them so the voltage ratio is also the resistor ratio.

Now assume that the op amp output is low (0V) and you want the voltage at the inverting input to be 6.0V when the voltage across R1 is 6.5V, so that any further increase in the voltage across R1 will cause the op amp output to go high. Once again you have 0.5V across R3 and 6.0V across R2 so the same resistor ratio works in this case.

So, choose resistor values so that R2 is 12X larger than R3 and so that both are much larger than R1. This is a rough, back-of-the envelope design but you can experiment and tweak the values as you like. The important thing is to set Vref at one half of the supply voltage, then the ratio of R3 and R2 will set the amount of hysteresis.

\$\endgroup\$
0
\$\begingroup\$

A comparator circuit with hysteresis would work:

enter image description here Source: https://www.analog.com/en/analog-dialogue/articles/curing-comparator-instability-with-hysteresis.html

If we choose R2 to be 10k (arbitrarily) and Vref to be 5.25V (in the center):

6.25V-4.27V = ~2V which is the hysteresis voltage centered around 5.25V

VOL is 0V and VOH 12V because the amp rails at Vcc or GND.

This means that the ratio of R3/R4 is equal to 6 via this equation:

$$ HYST = R_3/R_4*(V_{oh}-V_{ol})$$

so R3 could be 10k and R4 could be 1.66k from the schematic above.

\$\endgroup\$

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.