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?
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
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,
when it was connected to the output of the MUX: 180mV
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?
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...
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)?
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.
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
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?
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.
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;