I'm using an etape sensor for monitor the level in a water tank. I've measured the voltage output from the sensor (using a voltage divider to convert the sensor resistance value to a voltage) and it is absolutely stable down to millivolts. The value returned form analogRead(), however, drifts +/- 10 units. I saw a post where which suggested adding a capacitor to solve a similar problem and tried that. When I added a 0.33 uF capacitor, the instability is decreased but it is still there.
Seems like an absolutely stable input should be reflected in a stable analogRead() value. Any idea on what I need to do to fix this?
The value you get is also dependant on the stability of the VREF/AREF signal, I think all Arduinos have a cap on that but adding another wouldn't do any harm.
AREF is normally the 5V power supply, is that stable? Is the top of the voltage divider also the same 5v, or another voltage that is unrelated to the 5v, such as VIN.
I'm using a wall wart sold specifically for the arduino (either from adafruit or maker shed). The value
from the sensor is completely stable and it is powered off the 5v output from the arduino. Is it possible
that the aref voltage would be unstable when the arduino 5v is?
You will also want to check for common mode voltage problems.
This is an AC signal that is present from household(earth) gnd to your +V and Gnd on your system.
Often caused 60Hz (or 50Hz) EMI noise that is picked up in cables etc.
It can cause wacky problems in data acquisition systems.
You may try using a choke to limit the current that cmv will produce and using a cap between the
signal lead and earth ground.
One trick is to read the signal at the same time in a multiple of the frequency. ie, every 1/60th of a second, so the signal voltage is read at the same level of amplitude of your cmv noise.
BTW, check with a voltmeter between earth ground and your signal and earth ground and your device gnd (-)
Sometimes the CMV can be quite large, (I have seen 50-60VAC) and can damage data acquisition systems.
On dataq systems, the CMMR Common Mode Rejection Ratio, is what helps protect the system from damage
and erroneous noise.
Hopefully the wall-wart is providing 7+V and connected to the DC barrel jack on the
Arduino. That means the linear regulator on the Arduino is providing 5V free of
switching noise.
If the wall-wart is providing 5V direct to the Arduino it could have lots of switching noise
and not be particularly stable.
AREF defaults to the 5V rail so you are limited by the quality of that. The more stuff
is powered from the 5V rail the more noise and variation there will be on it too.
If the wires to the sensor are long you might want a 4-wire connection to it to remove
the supply IR loss from the signal ground. supply+ground+signal+signal-ground. You
then connect both signal and signal ground to analog pins and read the difference.
JimGarrett:
BTW, check with a voltmeter between earth ground and your signal and earth ground and your device gnd (-)
Sometimes the CMV can be quite large, (I have seen 50-60VAC) and can damage data acquisition systems.
On dataq systems, the CMMR Common Mode Rejection Ratio, is what helps protect the system from damage
and erroneous noise.
Yes, CMMR is an important spec especially for low level signals. This is generally done by using differential input stages to 'measure' the signal voltage, a mode the Arduino analogRead doesn't utilize. The arduino/AVR ADC subsystem is very useful for lots of functions and applications, but precision instrumentation quality measurements is not one of those applications. Modern I2C and SPI ADC chips/modules are a much better and simpler method to deal with higher quality measurements.
How big are the resistors in your voltage divider?
jimbarstow:
Seems like an absolutely stable input should be reflected in a stable analogRead() value.
Verified to be "absolutely stable" with what method? A multimeter lies.
jimbarstow:
I'm using a wall wart sold specifically for the arduino (either from adafruit or maker shed).
Because a generic supply can be used for the Arduino, doesn't mean there are any specifications around its output or its output stability. While buying a supply from a Tier 1 supplier like Adafruit or Makershed usually means a quality product, it doesn't really provide us a baseline for the performance of the supply.
One thing I should have mentioned is that noise voltage goes up as the square-root of the
bandwidth, so a multimeter which is low-pass filtering to 1Hz or so will see 100 times
less voltage fluctuation than an ADC with an input anti-aliasing filter set to 10kHz, assuming
gaussian noise distribution.
Since the Arduino ADC can convert every 110us or so you can view it as having a
bandwidth of 10kHz minimum (in practice if you don't filter its input it will have
a significantly larger effective bandwidth).
Adding an RC low-pass filter on the input might be worth investigating. 100k into 1uF
gives 1.6Hz cutoff, should be OK for a liquid level sensor.