# Measuring voltage across a resistor using a micro controller

I want to measure voltage across a resistor using the ADC of a PIC micro controller. But my problem is that both ends of the resistor are above GND and may be above 5V. But the difference is always =<5V. I need a circuit which operates at 5V, because i can use only a 5V supply in my design.

As long as you can tolerate tying each end of the resistor to ground via a large resistance (500K or so), without disturbing the circuit, you can use an arrangement like this:

where you use two channels of the ADC (or two ADC's), and compute the difference between them.

The voltage dividers as shown allow only 20% (100K/(400K+100K)) of the voltage to appear at the inputs to the microcontroller. Choose other values as needed.

As Olin as pointed out, this arrangement exceeds the maximum recommended impedance for PIC ADCs, due to the time constant of the ADC input capacitance and the source impedance. It might still be okay as long as the voltage across the resistor doesn't change rapidly and you can tolerate a long acquisition time. It might be worth trying and see if the values you obtain are suitable for your application.

• Thank you man, I prefer this method, because only a small number of external components are required. I think I can use a smaller value resistors without disturbing the circuit. Commented Oct 10, 2011 at 4:18

Use an instrumentation amplifier, with the two ends of the resistor connected to the + and - inputs. The ADC input is connected to the output of the amplifier. This technique is often used for current measurement.

• But here my problem is that the inputs may be higher than the power supply of the amplifier. Commented Oct 9, 2011 at 18:52
• Reduce them with voltage dividers? Commented Oct 9, 2011 at 18:56
• Can you please suggest any circuit with design equations, or some link. Commented Oct 9, 2011 at 19:01
• The wiki entry should help somewhat (the configuration is standard and common). Commented Oct 9, 2011 at 19:11
• Because the inputs could be greater than 5V. Commented Oct 10, 2011 at 12:02

The best method depends on things you haven't told us. If the maximum voltage is only a little above 5V, then a resistor divider may be good enough since you're only attenuating each signal a bit. The problem with dividers is that the more you divide, the lower the efective resolution ends up being after conversion. Each divider will also have some gain error, which messes up the differential calculation. Since you are doing two A/D conversions to get the difference accross the test resistor, you lose a bit there because the errors on each conversion add.

If you do use a divider, don't do what trcrosley suggested. Look at the PIC datasheet carefully and you will see a maximum impedance for the signal driving a A/D input. If you go above this, acquisition times will increase and the specified accuracy is no longer guaranteed. Most of the older PICs can tolerate up to 10 kΩ. Some of the newer ones need less, especially the high speed A/Ds. In any case 80 kΩ as tcrosley suggested is way too much.

What you are trying to do is a common problem when wanting to measure current with a high side sense resistor. There are chips specifically for that purpose. If this is a one-off, check out some of the Maxim parts.