Saturday, March 30, 2019

Ways to Improve ADC Measurement Accuracy and Resolution Part 1

In this video series we look at ways or tips to improve ADC measurement accuracy and resolution. In part 1 define what accuracy and resolution is and different types of error that can affect ADC measurements. We also look at the importance of using an accurate ADC reference voltage and why you want to scale the range of the signal you are measuring to the ADC's range.



//***************Arduino code used in video*******************************
/*This code demonstrates how to change the ADC voltage reference on an Arduino 
 * This was shown in an ADC tutorial on the ForceTronics YouTube Channel.
* This code is free and open for anybody to use at their own risk. 
*/

void setup() {
  Serial.begin(115200); //setup serial connection
  while(!Serial);
  analogReference(AR_EXTERNAL); //sets the ADC reference voltage to external (input is aRef pin)
  //analogReference(AR_DEFAULT); //set the ADC reference to default which is AVCC (uses power supply voltage or VCC as reference)
  //analogReference(AR_INTERNAL2V23); //uses 2.23V internal reference in SAMD21 uC
  analogReadResolution(12); //Set ADC to 12bit resolution, default is 10
  burn8Readings(); //make 8 readings but don't use them to ensure good reading after reference change
  delay(100);
  for(int i=0;i<500;i++) { //loop through a bunch of ADC readings and print them to serial plotter
    Serial.println(analogRead(A0)); //Make ADC measurement at A0
  }
  
}

void loop() {
  //don't need the loop
}

//This function makes 8 ADC measurements but does nothing with them
//Since after a reference change the ADC can return bad readings at first. This function is used to get rid of the first 
//8 readings to ensure an accurate one is displayed
void burn8Readings() {
  for(int i=0; i<8; i++) {
    analogRead(A0);
    delay(1);
  }
}

4 comments:

  1. We all know that analog inputs drift a lot, so I am using the ADS1015, and this gives me a very stable reading.

    ReplyDelete
  2. The code is quit different from the code in the video. Otherwise a very good video.

    ReplyDelete
  3. The code is quit different from the code in the video. Otherwise a very good video.

    ReplyDelete