Lesson 19--Microduino "Sampling ADC of internal reference source"
目录ObjectiveWhen using LM35, voltage increased 10mv, corresponding temperature rises 1℃, there is a linear relationship between them, therefore, it needs high stablility for the voltage. This experiment will collect temperature combine LM35 by calling Microduino internal reference source (3.3V or 1.1V voltage). Equipment
Experimental schematicThe VCC pin of LM35 connects to 5V,GND connect to GND,and VOUT connect to A0. Experiment One
void setup() {
Serial.begin(115200); //Set the baud rate 115200
pinMode(A0, INPUT);
}
void loop() {
int n = analogRead(A0); //Read the voltage from A0 port
double vol = n * (5.0 / 1024.0*100); //Use double type variable to save the temperature value which converted from voltage
Serial.println(vol); //Output the temperature from serial
delay(1000); //Wait for 1s to refresh data
}
The data in serial monitor: Experiment two
void setup() {
Serial.begin(115200); //Set the baud rate 115200
analogReference(INTERNAL); //Invoke 1.1V onboard power souce
}
void loop() {
int n = analogRead(A0); //Read the voltage from A0 port
double vol = n * (1.1 / 1024.0*100); //Use double type variable to save the temperature value which converted from voltage
Serial.println(vol); //Output the temperature from serial
delay(1000); //Wait for 1s to refresh data
}
The data in serial monitor: Experiment three
Note:Use the aref pin as the base source, connect the 3.3V base source to aref pin of Microduino Use the 3.3V as the external base source, please refer to:http://www.geek-workshop.com/thread-5717-1-1.html
void setup() {
Serial.begin(115200); //Set the baud rate 115200
analogReference(EXTERNAL); //Use the aref pin as the base source, connect the 3.3V base source to aref pin
}
void loop() {
int n = analogRead(A0); //Read the voltage from A0 port
double vol = n * (3.3 / 1024.0*100); //Use double type variable to save the temperature value which converted from voltage
Serial.println(vol); //Output the temperature from serial
delay(1000); //Wait for 1s to refresh data
}
The data in serial monitor: AnalysisUse three methods to test the temperature and got three different value.
ResultAccording to the above analysis, use USB power supply, the reference source error is smaller then other power relatively. USB power supply temperature closer to the real temperature, when the power supply isn't stable, the internal reference source will play a role. If require a higher precision, then need to use the external precision reference source. Referance error is smaller, and the accuracy of the ADC is higher too. According to the requirement to choose suitable reference source in all kinds of production is also very important. Video |