# Use uC hysteresis to evaluate signal

I have a micro controller (uC) with 1.8V supply and no integrated ADC. This uC must monitor one signal, and check if it is currently 5V or below 4.2V.

I then need to be able to trigger interrupts based on the value, by sensing HIGH and LOW:

LOW for <4.2V
HIGH for 5V


Is using the a voltage divider + uC evaluation hysteresis too risky?

Thanks

• @JackCreasey ;) well.. I know that.. and YOU know that.... but .... – Trevor_G Apr 9 '18 at 18:32
• You would have to do the math with the voltage threshold limits for your particular micro.. but since logic signals typically have a wide hysteresis percentage I would doubt you will be able to get it to work the way you imagine. – Trevor_G Apr 9 '18 at 18:36
• Many modern 1.8V µC have an analog comperator peripherial, which is simpler than adc. I'd use that when available. – Turbo J Apr 9 '18 at 18:36
• WHat does "LOW for >4.2V HIGH for 5V" MEAN!... those are not mutually exclusive. and plus or minus WHAT? – Trevor_G Apr 9 '18 at 18:48
• @Trevor_G That was a typo. Typed the wrong signal. Fixed it. Below 4.3V has absolutely to be LOW. – AmiguelS Apr 9 '18 at 20:12

## 2 Answers

You could use a simple RC network.

1. Short the capacitor using the GPIO pin
2. Turn the GPIO to input
3. Measure the time for the input to reach a '1'
4. Use the RC time constant to calculate the input voltage

Temperature variation of the GPIO pin threshold is up to you to discover, but hysteresis does not enter into it. You are only using the positive threshold value.

simulate this circuit – Schematic created using CircuitLab

• Thank you for your answer, but I need to be able to trigger interrupts from this signal. Polling does not fit my use case. – AmiguelS Apr 9 '18 at 18:40
• @AmiguelS you need to edit and put that in the question. Creeping requirement question are really frowned on here. – Trevor_G Apr 9 '18 at 18:41
• If you run a regular timer tick then you don't need to spin waiting for the threshold to be crossed. In any case you could have interrupt enabled on the GPIO pin and simply service that as the threshold ....either will work but you need a timer tick. – Jack Creasey Apr 9 '18 at 18:42
• @Trevor_G I just added that, sorry. Thanks for the warning. – AmiguelS Apr 9 '18 at 18:47
• This will work, though the threshold level tolerance itself may be too high. However, at 1.8V it can't be THAT bad. It depends on how accurate the OP needs the 4.2V to be. – Trevor_G Apr 9 '18 at 18:47

Use a voltage supervisor chip with open collector output + pull-up reststor to be compatible with the uC 1.8 supply. See some sugestions from Texas Instruments