Comparator-less voltage level detection

Thread Starter

cmartinez

Joined Jan 17, 2007
8,252
Say I have a raising voltage source, that through the course of several seconds, will go from 0V to 20V (dc) tops. Is there a way to trigger the digital input of an MCU when the voltage reaches certain level (say, 4.85V) without using a comparator ic? A zener connected to a transistor, perhaps? Another requirement is that current draw should be kept to a minimum, in the order of tens of microamps or less.

I'm already doing it using a TL431 voltage reference. But the thing is behaving with hysteresis. That is, it will activate its output by pulling it down when the voltage reaches it calibrated value (4.85V) but as the voltage drops, its output won't go up again until it reaches 4.35V ... and that's too large a gap for what I want.

upload_2018-7-12_12-35-53.png

 

ian field

Joined Oct 27, 2012
6,536
Say I have a raising voltage source, that through the course of several seconds, will go from 0V to 20V (dc) tops. Is there a way to trigger the digital input of an MCU when the voltage reaches certain level (say, 4.85V) without using a comparator ic? A zener connected to a transistor, perhaps? Another requirement is that current draw should be kept to a minimum, in the order of tens of microamps or less.

I'm already doing it using a TL431 voltage reference. But the thing is behaving with hysteresis. That is, it will activate its output by pulling it down when the voltage reaches it calibrated value (4.85V) but as the voltage drops, its output won't go up again until it reaches 4.35V ... and that's too large a gap for what I want.


Well a Schmitt trigger is only almost a comparator - or you could argue that its 2 comparators. Your input has to cross one threshold to change the output state, and cross another to change it back again.
 

Jony130

Joined Feb 17, 2009
5,488
To be honest I do not like your simulation results. The 0.8V at the output ? How? And from what I remember TL431 saturation voltage is around 2V.
And minimum current must be larget than 1mA. And why zener diode?
. Is there a way to trigger the digital input of an MCU when the voltage reaches certain level (say, 4.85V) without using a comparator ic?
Why not use a BJT and the voltage divider instead?
 
Last edited:

Thread Starter

cmartinez

Joined Jan 17, 2007
8,252
Well a Schmitt trigger is only almost a comparator - or you could argue that its 2 comparators. Your input has to cross one threshold to change the output state, and cross another to change it back again.
That's what I want, but with the "window" between states as narrow as possible, even if a slightly noisy signal ensues while in the change zone.
 

crutschow

Joined Mar 14, 2008
34,408
The TL431 circuit will take more than your low current limit?

You might try a TLV431.
It's a CMOS, lower power version of the TL431.
Note that its reference is 1.24V instead of 2.5V.
 

AnalogKid

Joined Aug 1, 2013
11,036
Does the uC input have a max risetime spec? Some digital inputs do not like slow-edged signals.

4.85 V (as opposed to 4.86 V) is almost 9 bits of precision. A low-power comparator could have that much error in its input stage (input offset voltage).

ak
 

ebp

Joined Feb 8, 2018
2,332
Try your simulation without the capacitor and zener diode. When the 431 turns on, it can sink substantial current. When it turns off, the only thing that raises the output voltage is the 470k resistor. The cap limits slew (haven't looked carefully at how much). A zener in that voltage range is a true zener (as opposed to an avalanche diode) and the knee of the voltage-current curve will be very rounded. I think these things are masquerading as hysteresis. It looks to me like the 431 is turning off at exactly the same voltage at which it turned on, but the rise is slow. Have a look at the cathode current of the 431.

[EDIT] Jony is right, the cathode voltage when used as a comparator should be around 2 volts (it is cathode-anode voltage that power the whole circuit - which nominally includes a 2.5 volt reference that I suspect isn't actually 2.5 V but pretends to be at the REF terminal)

There are lots of micropower voltage supervisors available that might meet your needs. The do tend to be absurdly expensive for what they are.
 
Last edited:

Thread Starter

cmartinez

Joined Jan 17, 2007
8,252
If this is for use with your 10F322 project, the 12F6xx and 12F1xxx series have comparators and are only marginally bigger.
It is ... but I'm in too deep with the 10lf322 to switch MCUs now. Besides, I chose that particular chip for its extremely low power draw.
 

jpanhalt

Joined Jan 18, 2008
11,087
It is ... but I'm in too deep with the 10lf322 to switch MCUs now. Besides, I chose that particular chip for its extremely low power draw.
I think the code for the 10F can be transported to a 12F (except the 1sF5xx, whic lack interrupts) quite easily. If you go to the 12F1xxx series you get so much more and the port names and pins are even the same.

Example:
upload_2018-7-12_16-27-24.png
 

jpanhalt

Joined Jan 18, 2008
11,087
The 12F1xxx has automatic context save and the code is so short, paging will not be a problem. Since it has 31 banks (e.g., PORT and LATA are in different banks), there will be a few movlb's or banksel's.

While all of the capabilities of the 12F1xxx will not be utilized, it is really quite a chip family and the (to me) minor need to select the correct bank is trivial. I am sure there is at least one person here willing to port the current 10F322 code to a 12F6xx or 12F1xxx "for free."

John
 

danadak

Joined Mar 10, 2018
4,057
For future there is always a processor with OpAmps, Vref, ADC, Comparators, DACs,
Mixer, PGA....eg. analog.

Even has a power system management facility, just some of its resources -

upload_2018-7-12_17-43-13.png


Regards, Dana
 

Thread Starter

cmartinez

Joined Jan 17, 2007
8,252
Your 10lf322 has 3 A/D inputs. Could you use one of those?
I've considered that, but I'm trying to tell when a source has reached 4.85V using a 3.3V MCU ... a resistor voltage divider might do the trick to limit the voltage being fed into the pin, but it would also consume a significant amount of current. Besides, a low impedance (<10k) source is recommended for the adc to work properly.
 

RichardO

Joined May 4, 2013
2,270
I've considered that, but I'm trying to tell when a source has reached 4.85V using a 3.3V MCU ... a resistor voltage divider might do the trick to limit the voltage being fed into the pin, but it would also consume a significant amount of current. Besides, a low impedance (<10k) source is recommended for the adc to work properly.
If you divide 20 volts down to 1 volt using 190K and 10K resistors then that meets your 10k source resistance requirement. Only 100uA is drawn from your 20 volt source.

Placing a cap from the A/D input to ground also helps at higher value source resistances.
 
Top