Comparator-less voltage level detection

Discussion in 'General Electronics Chat' started by cmartinez, Jul 12, 2018.

  1. cmartinez

    Thread Starter AAC Fanatic!

    Jan 17, 2007
    5,256
    6,108
    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

     
  2. ian field

    AAC Fanatic!

    Oct 27, 2012
    6,154
    1,111
    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.
     
  3. Jony130

    AAC Fanatic!

    Feb 17, 2009
    4,429
    1,256
    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?
    Why not use a BJT and the voltage divider instead?
     
    Last edited: Jul 12, 2018
  4. cmartinez

    Thread Starter AAC Fanatic!

    Jan 17, 2007
    5,256
    6,108
    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.
     
  5. cmartinez

    Thread Starter AAC Fanatic!

    Jan 17, 2007
    5,256
    6,108
    o_O mind elaborating?
     
  6. crutschow

    Expert

    Mar 14, 2008
    19,150
    5,354
    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.
     
    cmartinez likes this.
  7. cmartinez

    Thread Starter AAC Fanatic!

    Jan 17, 2007
    5,256
    6,108
    The zener is there because the MCU works at 3.3V
     
  8. AnalogKid

    AAC Fanatic!

    Aug 1, 2013
    6,909
    1,964
    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
     
  9. ebp

    Well-Known Member

    Feb 8, 2018
    1,243
    397
    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: Jul 12, 2018
    cmartinez likes this.
  10. Jony130

    AAC Fanatic!

    Feb 17, 2009
    4,429
    1,256
  11. jpanhalt

    Expert

    Jan 18, 2008
    6,138
    1,101
    If this is for use with your 10F322 project, the 12F6xx and 12F1xxx series have comparators and are only marginally bigger.
     
    MaxHeadRoom likes this.
  12. cmartinez

    Thread Starter AAC Fanatic!

    Jan 17, 2007
    5,256
    6,108
    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.
     
  13. MaxHeadRoom

    Expert

    Jul 18, 2013
    15,342
    4,483
    +1
    For small footprint projects, I use either the 12F683 or 12F1822.
    Max.
     
  14. jpanhalt

    Expert

    Jan 18, 2008
    6,138
    1,101
    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
     
    cmartinez likes this.
  15. MaxHeadRoom

    Expert

    Jul 18, 2013
    15,342
    4,483
    The issue with transporting to 12f1xxx is observing the pageselect.
    Max.
     
  16. jpanhalt

    Expert

    Jan 18, 2008
    6,138
    1,101
    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
     
  17. danadak

    Well-Known Member

    Mar 10, 2018
    1,094
    232
    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
     
  18. RichardO

    Senior Member

    May 4, 2013
    2,187
    843
    Your 10lf322 has 3 A/D inputs. Could you use one of those?
     
  19. cmartinez

    Thread Starter AAC Fanatic!

    Jan 17, 2007
    5,256
    6,108
    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.
     
  20. RichardO

    Senior Member

    May 4, 2013
    2,187
    843
    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.
     
    cmartinez likes this.
Loading...