• Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Voltage Monitor Single Port Pin Monitor & Reset?


Well-Known Member
Thread starter #1
For a status monitor I'm designing, I'm using a TL431 to monitor the system's 5 volt supply for dips, as shown in the schematic. Monitoring the supply voltage isn't central to the task at hand but I'd like to know if there are dips. As is the norm with microcontroller projects, port pins are in short supply. What I would like to do is somehow "store" the fact that there has been a voltage dip until the micro can check the state of the port pin, and then use the same port pin to reset the flag. In other words, I would like to see the low level caused by a voltage sag when I get around to looking at it, then switch the pin to a high output momentarily to reset it. Any suggestions on how to do this simply?

I was going to use a dedicated voltage monitor chip for this task but the only chip I could find that allowed setting the trip level with resistors is only available in pain-in-the-butt SC-70 package (TI TPS3803). The TL-431 accomplishes the same thing in a more manageable SOT-23 package using the same number of external components. I originally used the PLVD module of the PIC 18Fk22 I'm using but the voltage range on the system being monitored is too tight for its specs.

Oh. By the way, there are two R2 resistors to allow adjusting the voltage setting with good resolution. The ElectroDroid app for Android calculates resistor values to achieve a specified ratio. Very handy.
TL431 Volt Monitor.jpg

Les Jones

Well-Known Member
Use an I/O pin that has interrupt on change and have a very short interrupt routine that just copies the state of the port to a register. As it is a PIC18 you could use the
MOVFF instruction so you would not even change the W register. The bit in the register would then be the flag bit that could be checked and cleared by the software.



Well-Known Member
Most Helpful Member
I am using this in a project. One input Sets and one Resets. It is not like the TL431 because the ref is 1.24 volts.
You can use two resistors and go in on a Set pin to catch low voltage. Then the micro will need to pulse the Reset pin high.
This part has 6 different versions. Watch out. This is the "L" version.
The schematic above is to Reset when Vin gets too high and Reset when Vin is too low.
Something to think about.


Well-Known Member
Most Helpful Member
What accuracy do you need? Have you considered measuring the FVR (Fixed Voltage Reference) with the ADC and calculating Vdd? No pin required at all.



Well-Known Member
Most Helpful Member
From my experiance; it is hard to catch a short term event in software. (dipping of a supply)
The FF from post #3 catches events with out only uS delay. Then the software can take great time go read it.


Well-Known Member
Thread starter #6
I believe the FVR has the same accuracy as the PLVD module. My client believes a sag below 4.9 volts is a problem with this system. The tolerances on the PLVD module are such that to ensure capturing a sag below 4.9 volts, it may trip as high high as 5.1 volts...not so useful in this case.

The TL431B has a tolerance of 0.5%. I'm going to use 1% tolerance resistors, I'll be able to do a lot better on this.
How about using one of the comparators in the K22?

Run the TL431 output into one of the C12INx- pins and you can set the comparator REF+ using the FVR or DAC output.
The IF flag of the comparator latches, can be reset in code, and has programmable polarity. It has a response time of <400ns.
Only requires one pin.

You could do the whole thing with the comparator and the internal DAC but it probably wouldn't meet the accuracy you want.
If you want a more accurate programmable version then use a fixed ext VREF as the ref to an ext DAC and run that into the C12INx+ pin.

You now have a programmable comparator with no external resistors required (at least for setting up the trip point).
It does take a few more pins since you have the DAC interface to deal with (I2C SDA/SCL + dacout C12INx+ + comparator input C12INx-).


Well-Known Member
Thread starter #8
Hmmmm. i think I like rhe idea of using a comparator to read the TL431 output. i will take a look at how that works. Thank you.

When I looked at the Microchip device page yesterday to make sure I had the HLVD terminolgy correct, it calls the module a Programable Low Volt Detect (PLVD). I wonder when they made that change? The data sheet calls it HLVD as I had remembered. The table of trip points is shown below. If I want a "typ" trip point of 4.74 volts, the worst case trip point could be 5.1 volts. That entire step is unsafe for me to use if I want to ensure there are no false indications.



Well-Known Member
Thread starter #9
Feeding the TL431 output to a comparator input with the FVR as the reference looks like it will do exactly what I need. Not many more parts than reading the voltage directly with good resolution and any sags in level will latch the comparator flag until I read it. Nice solution! Thank you for the suggestion Tumbleweed.


Well-Known Member
Most Helpful Member
Thats not a bad little trick to keep in the back pocket actually, i have noted that one ;). One these days.................i might finally get around to doing a site with these kind of golden nuggets in.
It's a shame the internal DAC and the Voltage References are so poor in most of these, otherwise you could do it all using the internal hdw.

Speaking of, Jon mentioned the HLVD module. That one's only really useful for measuring the internal VDD node since the programmable ladder is on VDD and NOT on the external pin. If you want to use the ext HLVD input, it's fixed using the internal 1.024V ref so you have to use an external voltage divider.

Calling them "voltage references" is being generous. They spec them to 3 decimal places (ie 2.048V) and then put such a wide tolerance on them (typ 5-7%) it makes them laughable. Chances are your VDD voltage regulator has better specs than the int Vref!
Would a diode ... Anode at the TL431 1k junction, Cathode to a 100nF tied to ground work providing enough delay to read the I/O at the Cathode 100nF junction?

Latest threads

EE World Online Articles