I have a low-voltage detection circuit which I use to trigger one of two LEDs (green, and red) that is powered off of a +9V battery cell. As the battery discharges, its output voltage decreases, until when it finally hits the 6.9V level. When the battery provides an output voltage greater than 6.9V, the green LED is turned on, and currently flows from the source to the drain of the PMOS, Q4. If the voltage falls below 6.9V, the green LED is turned off, the red LED is turned on, and the output of Q4 is turned off.
However, as another commenter mentioned in a separate question on part of this circuit, I should implement hysteresis in some form or another so that I don't have the circuit alternating between the two LEDs at the cutoff point due to the average load of the circuit changing when in the "green" mode of operation. What is the most straightforward way to approach this?
Do I have a comparator feeding into the gate of the PMOS? Since my voltage rail is expected to change, I can't really use a voltage divider across Vcc and Gnd for reference. My intent is to have the circuit stay in the "red" region (ie: cutting off Q4) if it enters that region, with some noise tolerance for when the circuit is first turned on.
I simulated the circuit by Asmyldof below using a 100R resistor for the load, and a pair of AC power supplies with a shared 6V offset, and 0.5V amplitude each (60Hz and 120Hz frequency sinusoids), and the simulation below it. This appears to just offset the output signal with respect to the input supply power. Is this actually hysteresis, or is my simulation just terrible? Thanks!
Circuit Simulation - Light Blue:Power Rail, Orange:Output/Load Voltage