0
\$\begingroup\$

I am working on a project of water pressure measurement, in which I used a pressure transducer which gives me output between 4-20mA current form.

I am using a 250 ohm resistor to convert current into voltage, and then I give this voltage to ADC of an Arduino Uno channel 0 (A0).

The ADC reading is continuously fluctuating up to 10 decimal numbers (ADC value varies + - 5 counts.)

I have also checked by connecting a multi-meter and measuring the sensor current reading for a particular pressure. The current reading is stable (does not even fluctuate 1 or 2 points.)

Also I have checked voltage value after 250 ohms +Ve and ground. The coonverted voltage is also showing very stable.

Why is the ADC reading fluctuating?

I am using an Arduino Uno, it doesn't have any changes in AREF, AVCC etc.

Please suggest effective solution.

My code is as follow..


const int analogInPin = A0;  // Analog input pin that the potentiometer is attached to

int sensorValue = 0;        // value read from the pot

void setup() 
{
  // initialize serial communications at 9600 bps:
  Serial.begin(9600);
}



void loop() 
{
  
  // read the analog in value:
  sensorValue = analogRead(analogInPin);
 
 
  // print the results to the Serial Monitor:
  Serial.print("Reading: ");
  Serial.println(sensorValue);  
 
  delay(1000);
}
\$\endgroup\$
4
  • \$\begingroup\$ "... fluctuation ... up to 10 decimal numbers." What does this mean? How many percent? Please format your code properly. There is a button on the editor toolbar. Make sure it is indented in the correct places. Thank afterwards by upvoting and accepting answers. \$\endgroup\$
    – Transistor
    Commented Aug 2, 2018 at 17:59
  • \$\begingroup\$ "fluctuation ... up to 10 decimal numbers", mean for any particular fixed output of sensor, adc value is up and down between ten numbers, for example if value should be 100 in normal condition, it become either 95 or 105, and between all values. \$\endgroup\$ Commented Aug 2, 2018 at 18:06
  • 1
    \$\begingroup\$ That is normally reported +/-5 counts on 100 or +/-5%. Put that into the question so that your readers have all the information in the one place. Are you sure that the pressure and input aren't fluctuating by 5%? Have you got mains interference? Don't forget to fix the code formatting. \$\endgroup\$
    – Transistor
    Commented Aug 2, 2018 at 18:09
  • \$\begingroup\$ If there is noise on the signal being converted that is harmonically related to the sampling rate with an offset frequency that matches your results, then you have excessive noise. \$\endgroup\$ Commented Aug 2, 2018 at 18:29

4 Answers 4

1
\$\begingroup\$

A variation of 10 counts out of a maximum 1023 is about 1% of full scale, not bad for an Arduino. This is equivalent to about 50 mV and you probably have that much noise on the input signal and AREF.

If the problem is noise and the noise is a random fluctuation then you should be able to improve the readings by averaging. Try summing 16 or 32 values and then dividing the result by 16 or 32. (I proposed 16 and 32 because they are integer powers of 2 so performing unsigned integer division with these values is easy and fast...shifting.)

\$\endgroup\$
0
\$\begingroup\$

Your multimeter averages over a good part of a second so it's not really measuring the same thing.

Look at the ADC input signal with an oscilloscope, set to AC range with a sensitivity of perhaps 100mV or 250mV/division. Since your ADC is 10 bits and 5.0V reference, you are reporting (as added in the comments) +/-5% peak-to-peak variation out of 5.0V full-scale, which is +/-250mV (and about +/-50 ADC counts).

That will tell you how real that signal is. It could be caused by actual variations in pressure or vibrations of the sensor.

It could also be affected by interaction between your serial communications ground and any grounding in the sensor circuit.

\$\endgroup\$
0
\$\begingroup\$

As @Spehro Pefhany has already pointed out, you should use an oscilloscope to view your signal rather than a multimeter.

Here are some good general practice which you should follow:

  1. Always have a bypass caps near to your 'AREF' pin to remove any potential noise. Although you can't get away with all of the noise.
  2. Instead of taking one measurement every time to 'see' a measurement, take mean of, for example, 10 readings at some interval. This is simple but very effective.
  3. Put a low pass filter (LPF) in front of ADC to remove any noise from the input signal. But be careful about designing that LPF.

Try the above tips to have more accurate measurement.

\$\endgroup\$
0
\$\begingroup\$

If the problem is noise related you may be able to reduce the error via averaging. Just change your code to the following and see what happens.

const int analogInPin = A0;  // Analog input pin that the potentiometer is attached to

int sensorValue = 0;        // value read from the pot

void setup() 
{
  // initialize serial communications at 9600 bps:
  Serial.begin(9600);
}



void loop() 
{
  //compute average of 32 sensor readings
  sensorValue = 0;
  for(int i=0;i<32;i++){
      // read the analog in value:
      sensorValue += analogRead(analogInPin);
      delay(31);//wait 31ms
  }
  sensorValue = sensorValue / 32;      

  // print the results to the Serial Monitor:
  Serial.print("Reading: ");
  Serial.println(sensorValue);
}

I chose a 32-sample average because you can only add 32 ADC readings without overflowing a 16-bit signed integer. If you move up to 32-bit integers you can average larger data sets.

Also, if your noise is related to the 60Hz power frequency, you may get better noise cancellation by changing the 31ms delay to 1/2 of a 60Hz cycle (which is roughly 8ms).

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.