Pages: [1]   Go Down
Author Topic: adc / accuracy?  (Read 1581 times)
0 Members and 1 Guest are viewing this topic.
Brunsbüttel, SH, F.Rep.GERM
Offline Offline
God Member
*****
Karma: 4
Posts: 596
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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*

both (LM35 and arduino) were powered by the USB cable...
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
« Last Edit: October 04, 2009, 06:18:15 pm by RIDDICK » Logged

-Arne

Offline Offline
Edison Member
*
Karma: 3
Posts: 1001
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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  smiley-wink

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

Brunsbüttel, SH, F.Rep.GERM
Offline Offline
God Member
*****
Karma: 4
Posts: 596
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

i used an
"analogReference(INTERNAL);"
call and the result of analogRead() was about 148...

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?
Logged

-Arne

Brunsbüttel, SH, F.Rep.GERM
Offline Offline
God Member
*****
Karma: 4
Posts: 596
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

can it be that i have to connect all input legs of the MUX?
i read something about "crosstalk" in the datasheet...

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*  smiley-wink
« Last Edit: October 05, 2009, 06:53:55 am by RIDDICK » Logged

-Arne

Brunsbüttel, SH, F.Rep.GERM
Offline Offline
God Member
*****
Karma: 4
Posts: 596
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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...
Logged

-Arne

Brunsbüttel, SH, F.Rep.GERM
Offline Offline
God Member
*****
Karma: 4
Posts: 596
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

now i found the cause, i think:  :smiley

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"...   :smiley

should i better ask in an electronics forum,
since this is surely not arduino related
(the arduino measures fine)?
« Last Edit: October 05, 2009, 08:20:00 pm by RIDDICK » Logged

-Arne

Cumming, GA
Offline Offline
Edison Member
*
Karma: 20
Posts: 1659
Ultimate DIY: Arduino
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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
« Last Edit: October 05, 2009, 11:29:00 am by pwillard » Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 637
Posts: 34602
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Brunsbüttel, SH, F.Rep.GERM
Offline Offline
God Member
*****
Karma: 4
Posts: 596
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

yup - i put some 470nF caps and some 22nF caps in parallel to the supply voltage of the MUXes... i read ur article before...  smiley-wink

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?
Logged

-Arne

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 637
Posts: 34602
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

tytower
Guest
 Bigger Bigger  Smaller Smaller  Reset Reset

[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

« Last Edit: October 06, 2009, 02:31:26 pm by tytower » Logged

Brunsbüttel, SH, F.Rep.GERM
Offline Offline
God Member
*****
Karma: 4
Posts: 596
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

not anymore...  smiley-grin

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...
Logged

-Arne

Pages: [1]   Go Up
Jump to: