# How to read high voltages on microcontroller?

I want to read high voltages, like ~50V, using a microcontroller. I plan to put this as an input into the microcontroller's A/D line. But of course, you shouldn't have voltage that high on the input of a microcontroller or it'll fry.

How might I read high voltages? The main thing is that I need to step down the voltage before reading it. What do I need to consider when stepping down this voltage?

Edit: I noticed in the PIC18 datasheet that it says "The maximum recommended impedance for analog sources is 2.5 kOhms." How does this affect how I step down the voltage, be it with resistive dividers, etc.?

• You mean with a microcontroller? The impedance note about analog sources probably means that if the sources are higher than 2.5K, the input on the PIC will start to load them down. You usually want a source impedance to be at least ten times smaller than the load impedance, so that it is not disturbed by the load impedance. This could be a roundabout way of saying that the input provides 25K of impedance. So we would make the voltage divider about 2K "tall". This means 25 mA will flow. If that's unacceptable, you can use a much more resistive divider, and high-Z buffer. – Kaz Oct 6 '12 at 0:52
• Combining the answers below, I've used a resistor divider to step down the voltage and put the output of that resistor divider through a voltage follower op-amp. This op-amp then acts as a low output impedance buffer. This way, I can use high value resistors to limit the power loss in those resistors. – Jack Feb 27 '13 at 0:40

A simple resistive voltage divider will achieve what you want. The formula to calculate the output voltage is: So if we assume your input voltage ranges from 0-50V, we need to divide it by 10 to achieve 0-5V. If we also assume we want to load the input voltage with 100kΩ, then the calculations would something like:

Vout / Vin = R2 / 100kΩ

0.1 = R2 / 100kΩ -> R2 = 10kΩ

R1 = 100kΩ - R2 = 90kΩ

So R1 = 90kΩ and R2 = 10kΩ

For an ADC requiring a maximum source impedance, you must make sure the voltage divider impedance is below this level. The impedance at the divider can be calculated as R1||R2.

For <2.5kΩ, the above won't meet this requirement as 10kΩ||90kΩ = 9kΩ
If we use 9kΩ and 1kΩ though, we get 1 / (1/1000 + 1/9000) = 900Ω

Bear in mind the lower the resistance the higher the wattage rating resistors you need. 50V / 1k = 50mA -> 50mA * 45V = 2.25W across the top resistor (0.25W across the bottom)
In these cases it's best to use an opamp buffer in between a high resistance divider and the ADC. Or use a 2kΩ and 18kΩ divider, which is not quite as power hungry as the 1k/9k version.

• 2.25W is a lot of power to waste doing a voltage measurement. – Nick Johnson Oct 4 '12 at 10:35
• Yes, I agree - you would use the buffer mentioned (and elaborated on by Steven) in most cases. – Oli Glaser Oct 4 '12 at 10:39
• 50V/1k. How? Aren't those resistors in series? – Adithya Nov 25 '14 at 10:27
• Same question here... how 50v/1k? Further where did this 45v came from? – Prasan Dutt Sep 1 '16 at 15:03
• @OliGlaser not a word about capacitor? ADC input, if driven with high resistance, may distort the signal. Actually it does. So minimum is to use a small capacitor in parallel with lower resistor. – Gregory Kornblum Mar 1 '17 at 12:47 The Schottky diode protects the opamp's input against overvoltage in case the input voltage would exceed the maximum specified 50 V. This is a better solution than the 5 V zener which is often placed in parallel with the 3 kΩ resistor. The 5 V zener voltage requires several mA, if the current is much lower the zener voltage will be lower as well, and the diode may clamp the input to for instance 4 V, or even lower.

The 27 kΩ resistor will allow 2 mA, isn't that enough for the zener? I might, but that's not what the zener will get; most of that 2 mA will pass through the 3 kΩ resistor, leaving only tens to hundreds of µA for the zener, which simply is too little.

Select a Schottky diode with a low reverse leakage current, so that the 5 V supply voltage doesn't influence the divider too much.

• Forgive my naivety here but the Schottky diode protecting the opamp from an over voltage on the 50V rail, would this condition therefore raise the 5V rail? Thinking of doing this but concerned about other devices on the 5V rail (PIC, Arduino, etc) – GreenaGiant Aug 23 '18 at 20:25
• Not if the current is small. Obviously if you connect low impedance source then the voltage will rise. But the 27k resistor ensures the current is small. – Martin Jan 23 '19 at 7:31

For an isolated measurement, you can use a voltage transducer, e.g. LEM's LV-25 or similar.

But a much easier way if you don't need isolation is to just use a voltage divider: To fight your source impedance problem you could first use a voltage divider and then use a standard opamp. That should have a low enough output impedance for you. Here's an app note I posted yesterday on using opamps for converting voltage levels for ADCs.

http://www.ti.com/lit/an/slyt173/slyt173.pdf

Look up something called a resistor divider. Using two resistors, you can multiply a voltage by a constant between 0 and 1. In your case you want to scale 50 V down to the microcontroller level. Let's say the micro is running at 5 V, so you want to scale the input by 0.1. This could be done with two resistors, the first having 9x the resistance of the second. The signal goes into the first. The other end is connected to the second resistor and the micro A/D input, and the other end of the second resistor is connected to ground. With the 9:1 ratio you get a gain of .1 (attenuation by 10).

You probably want the lower of the two (the 1x resistor) to be around 10 kΩ, which would make the other 90 kΩ. I'd probably use 100 kΩ to provide some margin and overrange sensing.

I've successfully done this using a voltage divider and a Zener diode reverse biased between the input pin and ground (just in case).

• A zener diode gives fixed output voltage and used for regulation. How you used it for varying input voltage? Sensor output voltage is varying between 0-50v and adc input should vary accordingly in between 0-5v. Using a zener will fix the adc input voltage. – Prasan Dutt Sep 1 '16 at 13:55
• The zener is to protect the ADC input against voltages higher than the uC can handle, just in case, as he said. Let's say the uC can handle 0V-5V, if you plan to measure 50V, you put a 10:1 divider and a 5V Zener, so if the input goes over 50V, the zener clamps it to 5V. – s3c Sep 5 '16 at 15:06