# Linear resistive divider for the ADC

This is a topic that’s very simple, but I’ve seen individuals do it in ways that are really over complicated. My example will show how to measure from -24v to 24v using a 10bit Analog Digital Converter (ADC) with an analog reference of 5v. The micro controller for this example will be an Arduino since it’s easy to get up and running. If you are having issues with selecting resistor values for your situation, leave a comment and I’ll help you out!

Design and deriving the equation:

This is a circuit that’s basically an addition to the simple voltage divider which gives one the ability to measure high voltage ranges using an ADC with limited voltage ranges. I’m going to be using a voltage divider that starts out at half the Vdc, which is 2.5v for the Arduino’s 5V power. From there I’m going to use a higher valued resistor to pull the 2.5v up to nearly 5v at it’s peak positive voltage, and down to 0v for its minimum negative voltage. If you wanted to measure just negative voltages then get rid of Rc (use infinity in the equation).

For deriving the equation, I just used nodal analysis. As you can see there is no calculus or anything very math intensive, but there are some variables. This isn’t a guide on circuit analysis, but if you need some tutorials on signal analysis look around youtube or try the book – Schaum’s Outline of Basic Circuit Analysis. Just as a warning there are a similar methods of doing nodal/mesh analysis that will get different equations but yield the same final equation.

Note: Vout is the output of the resistive divider, which will be what’s connected to the Arduino’s analog input (ADC). Vout should only go from 0-5v. Vac is the input to the overall circuit which may vary from positive to negative voltages. Vout may be found by using 5*(double)analogRead(pin)/1024.

Usage notes:

This isn’t a volt meter! If you build it and you’re not measuring a voltage, you’ll notice that it reports a few volts although nothing is connected. Connect Vac to Ground and you should get close to zero volts. As you can see the example above is fairly low impedance, but you can use higher resistors. The two resistors standing up are both 10k. Two 10k resistors in parallel are equivalent to 5k. Red wire running off of picture is Vac and black is ground.

As for problems: the only thing I can think of is if the ADC wasn’t giving off good readings. If you’re measuring something that’s time critical or behaves sinusoidally, don’t put any capacitors on Vout since this will do a phase shift on Vout. If you’re worried about voltage spikes then you could use two  zener diodes facing oppositely. Also remember that in this example the voltage spread is over 24*2 = 48 volts, so with a 10bit ADC that’s 48/1024 ~ .5 volt increments.

Example code and material:

Voltage equations from above (pdf)

Arduino example program (pdf)

I was going to use this for a 3 phase triac driver with simple pwm. I needed a zero volt detector on one phase which would allow me to calculate the other phases and trigger the triacs at the right time. Originally I was going to sample the voltage with the ADC and look for about 2.5v coming to the ADC. I ended up using a simple voltage divider and a comparator which is definitely a better route! Now you can measure negative voltages with your ADC or Arduino! About Moser
Electrical Engineer who loves to bike!

### 6 Responses to Linear resistive divider for the ADC

1. GS test says:

Linear resistive divider for the ADC | ReiBot.org

2. Roberto says:

Hi Moser,
Sorry but I am not sure I fully understand this circuit. Why 24 V is AC and has positive and negative signs as if were a DC voltage?
I want to do something similar with Arduino:
I want to measure -15Vdc from a power supply but do not know how to feed that negative voltage into arduino analog inputs (as far as I know it only takes positive voltages).

Can you help me?

Thanks

Roberto

• Moser says:

I’m feeding the circuit AC to demonstrate it’s capability. For measuring -15v just rebuild the circuit and connect your -15v to the red wire on the right side of the image. once you get it all setup, measure it first with a multimeter before connecting it to the adc pin to ensure the dividers output is between 0 and 5v in case you missed something on the wiring

3. cm1 says:

/ 1024 not / 1023.

4. james says:

48/1024 ~ .5 volt increments.

Should be ~ 0.05 V increments

5. Inoace says:

Thank you. helped me quite a bit.
although i only needed to meassure -ve voltage on dual adjustable power supply