Go Down

Topic: DUE ADC Read Value Stability (Read 7091 times) previous topic - next topic

dlloyd

Quote
Taking the samples in such quick succession on a Due means you're sampling at way more than 1 kHz. You'll still experience the full joy of line noise.
This method works great on my Due, however I do understand it would depend on the nature of the "noise". If it's just switching noise, no problem. If it's say the 3rd harmonic of the line frequency (or similar), then it would be easy to modify the function to include a non-blocking interval between readings and to only sort after "n" readings. Also a non-blocking interval between function calls could be included.
There's nothing like an oscilloscope image to get a true picture.

Dande80

#16
Jan 27, 2015, 10:16 pm Last Edit: Jan 27, 2015, 10:17 pm by Dande80
Hi everybody,

I did some more testing and as it seems as improving the analog circuit reduces the problem by a factor of 2. Here is the new test setup (sligthly different then before because I want to use this circuit later on):
  • I am using a LMC6484N quad op-amp. When I write opamp in the next lines I always refer to one the 4 opamp in this chip.
  • First of all the analog reference voltage (currently I just use the 3v3 supply voltage) is buffered by using an opamp as a voltage follower.
  • Then I am using a voltage divider (two 5k6 resistors) to get half the reference voltage. This voltage is again buffered using an opamp as a voltage follower.
  • After this the signal is split in two and connected to a bnc connector (in the future I will connect a pH-probe and a Redox-probe but for the moment gave the output back by terminating the BNC connector using 50Ohm plugs).
  • The signal is then amplified and filtered using an opamp with a low pass filter (10MOhm + 1µF -> 16ms response time). This signal is then fed back to the Due.
  • Additionally I used short wires between my circuit and the DUE board.

The circuit is attached to this post as an Eagle schematic.

I used the following code for the Due:
Code: [Select]

#include <Arduino.h>

// Pins to be read
const int pin1 = A0;
const int pin2 = A1;

// Exponential Averaging factor 0 means no averaging, 1 means infinite averaging
const double avgfactor = 0.9;

// Variables for Read Values and Averaging
int value1, value2;
double value1avg = 0, value2avg = 0;


void setup()
{
 // Initialize serial port
 Serial.begin(9600);
 
 // Set Analog Read Resolution to 12bit to use Dues abilities
 analogReadResolution(12);
}

void loop()
{
 
 // Read analog voltage
 value1=analogRead(pin1);
 value2=analogRead(pin2);
 
 // Calculate Average Values
 value1avg=avgfactor*value1avg+(1-avgfactor)*value1;
 value2avg=avgfactor*value2avg+(1-avgfactor)*value2;

 // Output values to serial port
 Serial.print(value1);
 Serial.print(" ");
 Serial.print(value1avg);
 Serial.print(" ");
 Serial.print(value2);
 Serial.print(" ");
 Serial.println(value2avg);
 
 // Wait a little bit
 delay(100);
}


Getting myself a few thousand values from the serial port I get the following statistics (Min Max Average StandardDeviation):
Value1: 2034 2039 2036.33 0.78
Value1Avg: 2035.70 2036.98 2036.33 0.20
Value2: 2027 2032 2029.10 0.91
Value2Avg: 2028.43 2029.79 2029.10 0.21

As can be seen this results are actually quite good. Actually the values are that good that I am not sure that it is worth to try to improve the situation even more. I was thinking about the following possible approaches to improve the situation:
  • Putting a some capacitors between 5v and GND as well as 3v3 and GND to stabilize the voltages.
  • Using a better analog reference voltage. And use this one instead of the 3v3 supply voltage.
  • Using a decent 5V power supply instead of the USB power supply (this I will do anyways as there is a not to bad 5V power supply in the box the DUE will be used in and I don't see any reason to use more then one power suppply)
  • Create a separate analog 3V3 voltage out of the 5V in order to give the opamps a clean supply voltage. This voltage could also be used as analog reference voltage but it might be higher then the supply voltage of the SAM3X and therefore it might damage the controller.

Could anybody comment on this ideas. Which one would be most promising, which one will not work?

Thanks a lot
Daniel

Go Up