Continue to Site

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.

  • 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.

Overvoltage protection MCU pin (voltage divider)

Status
Not open for further replies.
Standard voltage divider (10K and 20k+100k pot) in order to monitor voltage with MCU.
It is designed to work with 3.3V MCU and to monitir voltage from 0 to 9.9V (10K and 20K) up to 42.9V.

The problem is proper protection of the MCU ADC pin and supplying stable voltage in the same time.

For example, monitoring 12V with setting pot to 0 ohm (non-proper trim position) would provide 4V at ADC pin.
One obvious solution is to use 3.3V zener before input pin, however, current is very low at these configuration, thus using zener diode in this case, voltage drops from 4V to some 1.6V instead to 3.3V, which makes reading useless.

What would be proper way to protect MCU pin and in the same time get correct voltage from voltage divider in this case?
 
An MCU is a Cmos IC. All input pins on a Cmos IC already have protection diodes to prevent damage from static electricity. The diodes limit the voltage to a little more than the positive supply and a little below 0V but you need to limit the diode current with a series resistor. The datasheet for the MCU will state the maximum allowed diode current, maybe 10mA. A problem might be when the MCU is turned off then the positive diode does not clamp a positive input voltage.
 
Most MCU AD inputs require the source impedance to be <10K, so design your voltage divider accordingly.
Common trick is to put a Schottky diode, anode to AD input pin, cathode to Vdd to act as a clamp.
 
If the impedance to the pin is high enough you can get away without any protection so long as the uC has internal protection diodes on its input pins which these days is common, as the diode will conduct and clamp the voltage to that of the supply to the uC.
You could also place a diode from the i/p to the supply rail to clamp the voltage, as just mentioned.
 
Thanks to all for advices.

Using extra clamping diode may protect the pin, however also destroy MCU from Vdd if voltage difference exceed MCU maximum voltage range...

Ideal protection would be if extra voltage could be saturated without interference to main rail. However, I'm not aware of ideal way to achieve that. Perhaps adding several LEDs in series or other extra components.

Making more proper choice of resistors and trim/pot will allow usage of zener, however, wide range of voltage makes this choice problematic and require extra resistor to ensure current limit, making reading low and high voltage unreliable...

Perhaps, in this case, cannot be avoided usage of dedicated voltage monitoring IC, primarily intended to be avoided.

Thanks.
 
Last edited:
Perhaps, in this case, cannot be avoided usage of dedicated voltage monitoring IC, primarily intended to be avoided.

Not at all, you're massively over thinking this VERY simple circuit :D

With a PIC all you need is two resistors as a potential divider, nothing else - as you're simply monitoring the supply rail, and required sample speed is VERY low, then you can happily exceed the specified low source impedance requirement, as it's almost entirely down to fast sampling speeds. In any case, it's an incredibly simple job to run a few experiments with different value resistors to check the results of higher impedance sources.
 
Nige is right.
Clamping to the rail could lift the rail voltage up and damage something, usually though the decoupling capacitor across the rail is able to soak up any impulses, and as I said if the i/p impedance is high not enough current will flow to lift the rail.
Your kinda making a mountain out of a molehill, do a google for measuring a voltage with a pic, theres probably lots of data on the subject.
 
Well, it is trivial task if have fixed resistors and limited measured voltage... :)
I'm not novice with electronic nor MCUs, however that is hobby only and googling is not the best way to find answer for specific problem - the reason I posted here and it is rather theoretical, as practical use of specific circuit must follow strict spec.

Anyway, thanks.
 
setup your voltage divider, and then from the output of the divider a 2.2k or so resistor to the pic pin, so you limit the curent into the pic pin?

Code:
+43v ----\/\/\/\------x-----/\/\/\/-----ground
          15k         |         1k
                      |
                      L----\/\/\/\/\--------- to adc pin
                      |
                      |-----| |--------- ground
                       cap size depends on dampening required
 
setup your voltage divider, and then from the output of the divider a 2.2k or so resistor to the pic pin, so you limit the curent into the pic pin?

If resistors creates voltage division are high enough, current from it is small enough to go directly to MCU pin (usually max limited current to MCU I/O pins is 20-40mA, depending on MCU) - no need extra resistor. However, then zener cannot be used properly, as require some minimum amount of current.

If resistors have too small values, zener can be used and then extra resistor to MCU pin is required. However, then extra resistor may influence on significant voltage drop and reading is unreliable... However, if use small resistors for voltage divider and use it to measure high voltage, resistance is too low in order to prevent burning...

As well, with large difference between R1 and R2 forming voltage divider, there is a problem with accuracy, especially with 10-bit ADC, commonly used in small or older MCUs. Further, extra protective clamping diode can influence on main rail voltage rise enough to destroy circuit, etc. And we are back at beginning...

It cross my mind also to use digital resistor ic (to form R1 with fixed 20K) for such large 0-40V range monitoring, however not commonly available for me.

In any event, it was strictly theoretical issue.
 
Last edited:
As I said, you're GREATLY over thinking this, it's a dead simple problem, with a dead simple solution - two resistors (suitably chosen) and nothing else.

Why do you have a problem with that?.
 
The reason is certain required precision, nothing else...
Error between low and high voltage measurements is significant, BTW.

Perhaps the most easier solution would be to change MCU with new one have more pins, multiple ADCs (12-bit minimum) using it to measure voltage from more than one suitable voltage dividers, more ROM and adapt whole project to it... Voltage monitoring is just one project feature, however not minor one.
 
The reason is certain required precision, nothing else...
Error between low and high voltage measurements is significant, BTW.

What precision do you need?, and why do you think you need that level of precision?.

Assuming a 10 bit A2D, and a 40V range then you've got 40mV resolution, or 0.1% - more than pretty well any meter accuracy you can buy :D

If you only apply 10V to it, then you've still got 40mV resolution, but now only 0.4% - still more than accurate enough for pretty well anything, and resolution that's pretty well certain to exceed the voltage reference accuracy you're using.
 
Assuming a 10 bit A2D, and a 40V range then you've got 40mV resolution, or 0.1% - more than pretty well any meter accuracy you can buy :D

In theory perhaps... :)

Voltage divider is consisted of 1% resistors (trim/pot is 5%, however that can be ignored here). Reference voltage is from main 3.3V LDO linear regulator rail (used to power MCU and MMC board for logging), which fluctuates depending of active modules (of course, device is full of decoupling caps), temperature etc. If used internal MCU reference voltage (around 1.1V), that is for sure another type of headache...

The common voltage range is between 9-20V, with maximum of 40V. Of course, maximum can be staring reference, then with large difference between R1 and R2 in voltage divider we have much more error than you have calculated...

Well, have no time currently to remeasure all, however AFAICR, difference is significant.
 
Standard voltage divider (10K and 20k+100k pot) in order to monitor voltage with MCU.
It is designed to work with 3.3V MCU and to monitir voltage from 0 to 9.9V (10K and 20K) up to 42.9V.
...

We have had this discussion before.
and here

Nigel is full of crap! Even though he gets away with it on his favorite Microchip, there is absolutely no guarantee that it works with any other manufacturer's process...

Instead, get the full data sheet for your chosen MCU, and study the section dealing with the characteristics of the I/O pins. There will be a specification dealing with the maximum allowed +- current that you can inject into any I/O pin, and it may be different for an "analog" pin.

There might also be some discussion about "latch-up" occurring if the voltage being measured is present before the power supply to the MCU is turned on...
 
Last edited:
I guess that it all comes down to whether you want:

A cheap simple solution which may fail under abnormal conditions
or
A more expensive and complicated solution which will protect the input under all foreseeable conditions.

I am not sure that I fully understand* the requirements of the measuring circuit, I think that the normal range of input is 0 to 9.9 volts, with an overvolt condition which goes up to 42.9 volts. Does the circuit MEASURE the 42.9v ? or is it just a spurious condition which happens and we have to live with it?

My suggestion to measure 0 to 9.9v and protect against 42v would be to use a two stage voltage divider.

First stage divides the input from 9.9v to 5v. Zener diodes rated at 5.6v prevent the signal from rising above 5.6v (ish) during the overvolt condition.
The second stage divides the 5v signal to 3.3v or whatever the MCU ADC requires.

Just my 0.02€

JimB


Edit
* I have just re-read through this thread and I am now sure that I do not understand the requirements.
What is more, I am not convinced that anyone can correctly determine the requirements from the descriptions given so far by the OP.
 
Last edited:
The common voltage range is between 9-20V, with maximum of 40V. Of course, maximum can be staring reference, then with large difference between R1 and R2 in voltage divider we have much more error than you have calculated...

Obviously 'accuracy' will depend on the exact values of the resistors - but these are easily trimmed if required, but also (as you know) on the reference - which you are using the supply for, so will be pretty inaccurate anyway.

But the use of a potential divider is required regardless of the over-voltage 'problem', so any inaccuracy isn't really relevant. Using the more accurate internal reference would obviously help greatly, and in no way affects anything else - it just needs a different value potential divider.
 
Obviously 'accuracy' will depend on the exact values of the resistors - but these are easily trimmed if required, but also (as you know) on the reference - which you are using the supply for, so will be pretty inaccurate anyway.

I do not point to voltage ratio accuracy, that is essential to be precise as can be. The main point is gain and noise. And even internal VREF (here around 1.1V, depending on each device) is not immune of it. Internal VREF is ideal measuring mV and uV (without need of any voltage divider), however not several dozen volts. If we amplify small noise on larger scale, we obviously gets large error...

Also, voltage divider ratio drifts at 25C , 30C, 40C or more, dictated by voltage and dissipation factor. It also precaution measures require disabling critical modules and pins in order to shut down noise, even using specific ADC pin, averaging several reading ignoring first, etc.

The most common mistake people do, is using floating point math (single precision and even much less in many C implementations for MCUs) making things even worst... It is very easy to use integer basic math operations instead, working in mV or uV.

Thus, many factors are critical for accuracy. ATMEL have several notes about improving accuracy of ADC and conditions, perhaps other manufacturers have similar as well.

Etc, etc.
 
Sorry, but I fail to see how any of your points are at all relevant (and many are completely wrong), but feel free to carry on with any solution you feel is 'better' for you.
 
Sorry, but I fail to see how any of your points are at all relevant (and many are completely wrong), but feel free to carry on with any solution you feel is 'better' for you.

However, all these was not my initial question (overvoltage protection of MCU input pin) nor intention to argue - you have asked for reasons.

For better understanding, you may read this, specifically section 2.9: Atmel AVR126: ADC of megaAVR in Single Ended Mode
http://www.atmel.com/Images/doc8444.pdf

And this: AVR120: Characterization and Calibration of the ADC on an AVR
http://www.atmel.com/images/doc2559.pdf

Indeed, not all MCUs would do the same way and expect the best results without (far too many) preparations. I would prefer to end further discussion on the issue.

Thanks to all.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top