13
\$\begingroup\$

I want to read a voltage from 0-30V with an MCU ADC which has a maximum input of 3V.

Initially I thought of using a 100k-10k divider (so 33V translates to 3V) but according to the answers to ADC input impedance on MCUs, this will add a 3% error due to the input leakage current; I'm looking for 0.5% error maximum. However, at lower values for the divider, I risk damaging the MCU's inputs because of overvoltage (the resistors act in tandem with the clamping diodes on the input.) I also increase power dissipation in my resistors, which are tiny 0603 devices, rated for 0.063W maximum. How can I avoid this? n.b. input impedence is not critical.

I'm not worried about sampling speed, it will be monitoring a battery voltage at a maximum of 100 samples per second.

\$\endgroup\$
  • \$\begingroup\$ have you built the previous? 3% was a worst case based on worst case leakage, unless you are fabbing a lot of these you can calibrate them. \$\endgroup\$ – Kortuk Nov 2 '10 at 16:11
  • \$\begingroup\$ Kortuk, do you think I could adjust one of the resistors by 3% or handle it in software (scale by 1.03x?) \$\endgroup\$ – Thomas O Nov 2 '10 at 17:16
  • \$\begingroup\$ You are saying you want high precision, low power draw, at very little extra cost. Not sure that is possible. You can calibrate in software like kortuk has mentioned, but in a fab process that takes time which will equal money. \$\endgroup\$ – Kellenjb Nov 2 '10 at 18:07
  • \$\begingroup\$ Driving an MCU ADC input with a large impedance is bad, anyway. It increases the settling time and causes distortion, etc. "The ADC is optimized for analog signals with an output impedance of approximately 10 kΩ or less. If such a source is used, the sampling time will be negligible. If a source with higher impedance is used, the sampling time will depend on how long time the source needs to charge the S/H capacitor, with can vary widely. The user is recommended to only use low impedance sources with slowly varying signals, since this minimizes the required charge transfer to the S/H cap" \$\endgroup\$ – endolith Nov 2 '10 at 18:32
10
\$\begingroup\$

Use the voltage divider with resistors, and an opamp follower afterwards. Alternative use an opamp circuit to reduce the voltage and you can perform anti alias filtering in one stage!

\$\endgroup\$
  • \$\begingroup\$ +1 use the op amp with a gain of 0.1 and make it double as the anti-aliasing filter \$\endgroup\$ – ajs410 Nov 2 '10 at 16:34
  • \$\begingroup\$ I can't afford an op-amp. I don't have enough space, unfortunately. I may be able to afford a buffer IC, if they are small enough and are available with 8 channels. \$\endgroup\$ – Thomas O Nov 2 '10 at 17:16
  • \$\begingroup\$ Usually you just buy a tiny op-amp and connect it as a buffer. national.com/mpf/LM/LMC7111.html SOT23 is too big? \$\endgroup\$ – endolith Nov 2 '10 at 18:11
  • \$\begingroup\$ Oh, you want 8 channels. \$\endgroup\$ – endolith Nov 2 '10 at 18:13
  • 1
    \$\begingroup\$ using resistors of higher precision will reduce the voltage divider error, the second issue is driving that signal into an ADC. This is where the inaccuracies will occur, hence the proposal to use a buffer. \$\endgroup\$ – smashtastic Nov 2 '10 at 21:18
14
\$\begingroup\$

Okay, from your response to my comment I think I can be more help with a full answer.

Build it!

Build your simple Resistive divider. This has many advantages, for one size, another is cost.

Characterize it!

Now, you are going to use a microcontroller also, this is where you need to characterize your error. use a voltage generator that is very accurate, now check voltages and see what error the uC actually measures.

Analyze it!

Now is when it gets fun. There are a number of things you could measure.

Accuracy and Precision

The biggest thing to measure here is if the error at the points is repeatable. IF every time you sweep you get a different error, or if your sweep following a different path gives a different error at the same point, this is not an option. This often happens with leakage currents. The important part here is that you do not need high accuracy, just a high degree of precision. If you can characterize your error, your uC can correct for it. If you have a large variance you need to change your solution.

What is an X point calibration?

Now, if you have a high precision, as discussed before, you can move on to correcting the accuracy. Now, if when you graph your input voltage versus your output voltage you are going to have to decide the number of "reference points" you need. Nice devices allow a 1 point(or zero point, no need for calibration). Many temperature probes.

One point calibration

Both lines have the same slope, but an offset, so you just need to find the value you must add to a data-point to correct it. This is an ideal situation, as any new calibration only needs a single data-point to calibrate again.

Two Point calibration

both linear curves, possibly an offset and there is a slop difference, you only need two reference points and linear interpolation to extract your offset. This is still relatively easy, you just take any point, multiply it by a scalar and add an offset.

As you can see, it gets messier the more points you need. At some point it is easier to just take every datapoint and correlate it to the actual value. For example, finding that 0000 is 1V, 0001 is 2V, 0002 is 1.5V. This is messy, and this still only works if the offsets are repeatable. This can happen though.

Summing it up

I hope this helps, tell me if you need more clarity. If you end up with a varying leakage current that is not dependable, it is time to just deal with needing a buffer, or something of the like.

I can see a possibility of high error from leakage, but I would bet that the error is relatively small over most of the range, and when it is there can be easily corrected.

\$\endgroup\$
  • 1
    \$\begingroup\$ As a side note, This seems like a ton of work, but it is actually a relatively small amount of work to keep component cost down. \$\endgroup\$ – Kortuk Nov 2 '10 at 20:49
  • \$\begingroup\$ good comment! a brilliant way to do it in software. Your final method of look up table is probably the best method. Only drawback is the ROM it consumes, but for a 8-10 bit ADC on an MCU it should be doable. \$\endgroup\$ – smashtastic Nov 2 '10 at 21:31
  • \$\begingroup\$ It depends on data, I have many different cases a 1point calibration was sufficient. Just an offset. And then building in the hardware to calibrate automatically pays off. \$\endgroup\$ – Kortuk Nov 2 '10 at 22:19

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.