## [TUT][HARD] Simple ADC Input Stage

10 posts / 0 new
Author
Message

We often need a simple way to measure a voltage which is both positive and negative using the ADC. As long as we impose a few simple rules we can do this using nothing more than three resistors. The rules are...

1) The voltage range is symmetrical. ie the maximum positive voltage is equal in magnitude to the maximum negative voltage.

2) The voltage range in centred in the ADCs range. ie zero volts in will read half full-scale.

3) The voltage source must be able to both source and sink current.

4) The voltage source must have a low output impedance.

With this in mind let's design an input stage to take a +/-40V signal and transform it into a 0V-5V signal to feed to the ADC.

So, we take this signal...

...and turn it into this...

How? Using this simple circuit...

How do you calculate the resistor values....

And as a PDF...

## Attachment(s):

'This forum helps those who help themselves.'

pragmatic  adjective dealing with things sensibly and realistically in a way that is based on practical rather than theoretical consideration.

Last Edited: Thu. May 14, 2015 - 04:48 PM

Fantastic.

'Selecting R1 to limit current through the protection diodes'

I've not seen any figures quoted in any datasheets (or I don't remember seeing them), but I recall a figure in AVR182 of about 1 mA maximum current.

Let's put 99V into your example.  What will be the current into the protection diode?

Let's forget about R2 and R3 altogether for now, and we'll consider what happens when only the 10K R1 comes between Vin and the mcu pin.  The protection diode will attempt to clamp the voltage at the input pin to Vcc+0.5V.  With Vcc=5V, that's 5.5V.  the voltage across R1 will be 93.5V, so the current through R1 will be 93.5/10000 = 9.35 mA, far too much for the diode.

Adding R3 into the mix (still ignoring R2), we have ourselves a 9:1 voltage divider:

R3 / (R1 + R3)

1250 / (1250 + 10000)

1250 / 11250

1/9

So the voltage at the pin will be 99/9 = 11V

Here's where I get fuzzy.  What happens now?  The diode will attempt to clamp the divider to 5.5V, which will result in some current flowing from Vin through R1 into the pin and through the diode to Vcc.  How do we calculate it?

And then, how do we bring R2 into that calculation?

(EDIT for typos)

 "Experience is what enables you to recognise a mistake the second time you make it." "Good judgement comes from experience.  Experience comes from bad judgement." "When you hear hoofbeats, think horses, not unicorns." "Fast.  Cheap.  Good.  Pick two." "Read a lot.  Write a lot." "We see a lot of arses on handlebars around here." - [J Ekdahl]

Last Edited: Mon. May 11, 2015 - 02:33 PM

joeymorin wrote:

Let's put 99V into your example.  What will be the current into the protection diode?

When I'm feeling lazy I just put the numbers into a simulator...

New Input...

Clamped Input to uC...

Current in top diode....

Current in bottom diode...

So we have a peak current of 4.5mA but an average current of only 560uA which is probably well within the spec of the chip's internal diodes.

But in the real world it's probably best to run with external diodes and maybe even a capacitor across R3 to filter away any HF nasties.

'This forum helps those who help themselves.'

pragmatic  adjective dealing with things sensibly and realistically in a way that is based on practical rather than theoretical consideration.

This circuit does not work if the source cannot sink current like some sensor output stages. It also loads the source (depending on the resistors chosen of course) introducing possibly significant measurement errors.

I would not use this circuit as a general purpose input stage unless you know the source.

One design I inherited at work exactly uses this arrangement to interface to inductive proximity sensors and it does not work properly: the sensor cannot pull down its output below 2.5V because to do so it would need to sink current which it can't, so the usual 0-10V is reduced to 2.5V-10V. Unfortunately in this application, the interesting voltage range is the lower one, not the higher one.

Interesting point, but why would you need to centre a 0-10V signal around Vcc/2?

The approach held interest for me as a means of sampling mains, either directly or through a step-down transformer.

 "Experience is what enables you to recognise a mistake the second time you make it." "Good judgement comes from experience.  Experience comes from bad judgement." "When you hear hoofbeats, think horses, not unicorns." "Fast.  Cheap.  Good.  Pick two." "Read a lot.  Write a lot." "We see a lot of arses on handlebars around here." - [J Ekdahl]

Someone specified for some reason the input needs to be able to handle -10V-10V inputs.

The circuit will work for sampling mains directly or through a transformer; in fact, another project I worked on uses exactly this approach.

Quote:
Someone specified for some reason the input needs to be able to handle -10V-10V inputs.
Handle, or measure?

If only handle, then wouldn't a beefier protection diode on to ground solve that problem?

 "Experience is what enables you to recognise a mistake the second time you make it." "Good judgement comes from experience.  Experience comes from bad judgement." "When you hear hoofbeats, think horses, not unicorns." "Fast.  Cheap.  Good.  Pick two." "Read a lot.  Write a lot." "We see a lot of arses on handlebars around here." - [J Ekdahl]

jayjay1974 wrote:

This circuit does not work if the source cannot sink current like some sensor output stages.

Although I would argue that a source that cannot sink current is not a voltage source.

But for people who come across this post I've added another caveat in post #1.

'This forum helps those who help themselves.'

pragmatic  adjective dealing with things sensibly and realistically in a way that is based on practical rather than theoretical consideration.

joeymorin wrote:

Quote:

Someone specified for some reason the input needs to be able to handle -10V-10V inputs.

Handle, or measure?

If only handle, then wouldn't a beefier protection diode on to ground solve that problem?

Measure.