How can I measure -15V using the ADC of an AVR microcontroller?

I would like to scale my signal so that -15V signal voltage equals 0V at the input to the ADC and 0V signal voltage equals 5V at the input to the ADC. Vref and Vcc are 5V.


You'll need a non-inverting summing amplifier:

enter image description here

Start with the -15 V at the Vin input. Then the non-inverting input should be at 0 V, so the ratio R1/R2 should be 3/1, like R1 = 30 kΩ and R2 = 10 kΩ.

If the input voltage is 0 V then with these values the non-inverting input will be at 3.75 V, and we'll choose R3 and R4 to bring that to 5 V. Since the amplification is (R4 + R3)/R3 we can use the same resistor values: R3 = 30 kΩ and R4 = 10 kΩ.

Make sure you have an RRIO (Rail-to-Rail I/O) opamp.

|improve this answer|||||
  • \$\begingroup\$ Isn't inverting amplifier should have -15V input signal "Vin" connected to inverting input? \$\endgroup\$ – Socrates Oct 4 '12 at 8:53
  • 2
    \$\begingroup\$ @Socrates - The voltage levels may be a bit misleading, but it's not an inverting amplifier: the input range [-15 V, 0 V] is mapped to [0 V, 5 V], so the lower limit of the input maps to the lower limit of the output. -15 V becomes 0 V, and 0 V becomes +5 V. In an inverting amp the -15 V would become +5 V, and the 0 V would remain 0 V. \$\endgroup\$ – stevenvh Oct 4 '12 at 9:03

This looks to me like a classic example of overspecification. Inverting a full-range signal in software is trivially easy: just 1's complement the number. (seriously) And most microcontrollers have an instruction that does exactly that.

(Just be sure to invert only the relevant bits and leave the rest '0'. This adds an extra AND instruction for bit-widths that are not multiples of the CPU size.)

Given this information, it no longer matters whether the front-end amp is inverting or not, as long as the software knows which it is. This adds some freedom to the hardware side.

Given that freedom, I would recommend an inverting amp for this application because it can be configured easily to read an input that is outside its own power supply, like this:


simulate this circuit – Schematic created using CircuitLab

R1/R2 provide a reference that is just enough off the rail that the amp can control to it. Read the datasheet and adjust accordingly.

Ri/Rf are the standard feedback network, configured for a gain of roughly -1/3. It's a little bit less than that to account for the reference not being exactly zero. If it clips, make it a bit lower still.

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.