Go Down

### Topic: adc / accuracy? (Read 4291 times)previous topic - next topic

#### RIDDICK

##### Oct 05, 2009, 12:53 amLast Edit: Oct 05, 2009, 01:18 am by RIDDICK Reason: 1
hi!

today i connected a LM35 to an arduino analog input pin and the result was 20mV too low... i didnt like the LM75, because it seemed to be less accurate... *giggle*

the reference voltage was INTERNAL...
the cable between LM35 and arduino was 10m long...
and there was a MUX (4067) (with a 470nF cap at the output) inbetween, 2... :-)

a multimeter at the Vout pin of the LM35 and a thermometer near the LM35 suggested a 2°C (=20mV) higher value, than measured by arduinos ADC...

according to the atmega168 datasheet i can expect an accuracy of -3LSB to +2.5LSB (+/-2LSB and up to .5LSB non-linearity and up to -1LSB quantization error).
but 20mV corresponds to about -18.6LSB... right?

does somebody know this problem already?
what else could i try?

thx.

bye
-Arne

#### BenF

#1
##### Oct 05, 2009, 08:44 am
You say reference voltage is "INTERNAL" which is the 1.1V reference. Is this actually what you use - or is it DEFAULT which is the internal Vcc (USB voltage in your case)?

When using a 5V reference, the ADC resolution is 5V/1024 which is 4.88mV per step. Using the AtMega168 ADC with 2bit LSB absolute accuracy - this is the equivalent of +/- 19.5mV. Altogether not far from what you observe.

To improve on this you may consider the following:

- Eliminate fixed offset errors (use a digital multimeter)

Take a measurement of the AREF voltage (at the AREF pin). Take a measurement of voltage at the ADC input pin and compare to your measurement at the sensor output pin. Use the last two measurements to calculate the voltage drop in your 10m cable and use this along with the measured AREF voltage in your calculations.

- Eliminate/Reduce variations (noise)

To further improve on precision/accuracy, you can download the following application note from Atmel, read it, try to learn from it and apply the gained wisdom in your sketch

http://www.atmel.com/dyn/resources/prod_documents/doc8003.pdf

#### RIDDICK

#2
##### Oct 05, 2009, 12:37 pm
i used an
"analogReference(INTERNAL);"

i tried different tricks (average, average of those samples that dont deviate too much from the average, median value), but they all gave me 148...

now i stuck a LM35 into analog pins 0..2 and gave it some power...
the result was closer to the value read by my multimeter:
multimeter: ~268mV; arduino: 251*1.1V/1024=269.63mV

i measured an input of the MUX,
1. when it was connected to the output of the MUX: 180mV
2. when it was connected to the output of the MUX: 159mV

is it the capacitor or the MUX, that introduces that quite big voltage drop?
maybe i soldered it too hot?

the capacitor is a "little, blue, quite rectangular, short legs, ceramic, 470nF, 50V, RM5, blocking capacitor, h=5mm, MURATA"...
does it have big leakage current or other weird properties?
-Arne

#### RIDDICK

#3
##### Oct 05, 2009, 01:08 pmLast Edit: Oct 05, 2009, 01:53 pm by RIDDICK Reason: 1
can it be that i have to connect all input legs of the MUX?

EDIT:
i just tried it:
and the answer is: no, that doesnt change the result... the voltage still drops by 20mV at _both_ ends of the MUX... *sob*
-Arne

#### RIDDICK

#4
##### Oct 05, 2009, 03:55 pm
ohoh  :-?

when i use a shorter cable (20cm or so), the voltage doesn't drop...

but why does my voltmeter react nicely even at the long (1000cm or so) line?
the only difference i can c is, that my voltmeter has a pull-down resistor of about 1MOhm...
-Arne

#### RIDDICK

#5
##### Oct 05, 2009, 04:56 pmLast Edit: Oct 06, 2009, 03:20 am by RIDDICK Reason: 1
now i found the cause, i think:

when i measure the voltage with my arduino-oscilloscope
(it can do a sample rate of 7kHz to 8kHz at 500kBaud)
at the end of the 10m-line,
i get a cloud of values (no 50Hz wave, but much higher frequency)...

that cloud averages to the right value...

but when i add a capacitor
(i tried a red box-shaped plastic-foil-capacitor with 6.8uF, too),
i get 20mV less...

why is that?
i thought, capacitors would be nice "averagers"...

should i better ask in an electronics forum,
since this is surely not arduino related
(the arduino measures fine)?
-Arne

#### pwillard

#6
##### Oct 05, 2009, 06:20 pmLast Edit: Oct 05, 2009, 06:29 pm by pwillard Reason: 1
With every component that you add to the path between the sensor and the measuring point, it makes sense that you would lose some signal.  I mean, anything that does not AMPLIFY a signal... will weaken it.

Why not amplify the signal before you do things like send it through a MUX or a long cable.  You could use a a single supply op amp like a TLC272 with a 100K in the negative feedback path (with the - input also tied to 5V via 10K resistor)  Use a similar pair of resistors for the sensor input (From the + pin, use 10 K to LM35 source, 100K to GND) and use no more than .1uF on the signal wire  from the LM35 to GND.

You would then have a x10 Amplifier.  (I'm loosely basing this on an instrumentation amp configuration minus the extra input amps.  http://www.national.com/an/AN/AN-31.pdf)  I've used a similar circuit while testing a Motorola Pressure sensor.

pw

#### Grumpy_Mike

#7
##### Oct 06, 2009, 12:37 am
Quote
i get a cloud of values

That means something is oscillating. The capacitor stops it oscillating. That's why oscilloscopes are always the best way of measuring voltages in an electronic circuit. Have you got any decoupling across your multiplexer chip?
http://www.thebox.myzen.co.uk/Tutorial/De-coupling.html

#### RIDDICK

#8
##### Oct 06, 2009, 03:18 am
yup - i put some 470nF caps and some 22nF caps in parallel to the supply voltage of the MUXes... i read ur article before...

but why doesnt the capacitor show the average value, when it is oscillating? is it the ESR of the cap that wastes the energy? but the ESR of a ceramic cap is below 15mOhm according to wikipedia...
when it is not oscillating, the capacitor doesnt loose so much voltage...

i was under the impression, that a capacitor would build the average as if it is an "analog average computing device"...

my plan is now to remove the cap from the MUX output and to make an "ideal capacitor" in software (by computing the average digitally from some thousand samples)...
is that a good plan?
-Arne

#### Grumpy_Mike

#9
##### Oct 06, 2009, 10:29 am
Quote
is that a good plan?

Not if it is still oscillating. You need to stop the oscillation before doing anything else.
This is because an oscillating input will not give you any sort of true reading for the value. You might not even have a problem.

Don't believe all you read on wikipedia.

#### tytower

#10
##### Oct 06, 2009, 09:19 pmLast Edit: Oct 06, 2009, 09:31 pm by tytower Reason: 1
[glow]Oh he has a problem all right[/glow]

Quote
All features of AVR internal ADC can be found on official ATMEL AVR datasheets, but most important to mention are:

±2 LSB accuracy - so measurements aren't very accurate. If AREF voltage is 5V then error may reach ±0.04V but this is still good results for most of tasks;

I have a similar thread going here
http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1254349643

#### RIDDICK

#11
##### Oct 07, 2009, 03:09 pm
not anymore...

my "software cap" works fine...
i just have little deviations of 5mV at AREF voltage of 1100mV...

btw: when i look closer at my "arduino oscilloscope", the "cloud" has a quite clear 50Hz pattern...
-Arne

Go Up

Please enter a valid email to subscribe