I am trying to use analogReference(INTERNAL); to reference small millivolt inputs. When I monitor the results in the serial monitor, they do not appear to be any different than when i don't include the analogReference statement.
My (possibly wrong) assumption is that without he statement included in the "set-up" that an analog input is a 5volt input is ADC converted to a 1024 result. Therefore, 1VDC input would result in a display of aprox. 204. A 500 mV input would result in a display of 100.
When inserting the "analogReference(INTERNAL) in to the "set up" I was expecting to see the 1024 now being referenced to aprox. 1.1 volt.
Therefore 1volt DC input would display slightly less than1024 and a 500 mV input would indicate aprox. slightly less than 512.
No matter what I include the displayed output always seems to be "scaled" 5volts/1024.
I am using two different UNO's.
One is an older original version one and has the ATMEGA328P-PU
The other is a Rev3 and has the ATMEGA328P U
I am using a 1.5 volt battery and a 5K ohm pot as a voltage source for my input.
(I will try and and attach a photo of my configuration.)
I have the negative of battery wired to one end of pot and to UNO ground.
I have the positive of battery wired to opposite end of pot.
The "wiper" of pot is wired to analog input A3.
I am going to attempt to attach my sketch and a drawing of my wiring to the UNO.
I haven't done a post in a long time so I apologize for any incorrect things that I have done.
I would greatly appreciate it if participants could explain my misconception and/or my errors that may be in my code.
I will attempt to attach code and drawing.
And I Thank you for your patience, understanding, and help.
Rick
[code]
#include <SD.h>
File myFile;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
pinMode(10, OUTPUT);
if (!SD.begin(10)) {
Serial.println("initialization failed!");
return;
}
analogReference(INTERNAL);
}
void loop() {
// put your main code here, to run repeatedly:
float raw = analogRead (A3);
delay (500);
raw = analogRead (A3);
float calc = raw * 5.0725;
Serial.print (raw);
Serial.print (" ");
Serial.println (calc, 3);
myFile = SD.open("ricks.txt", FILE_WRITE);
myFile.println (calc, 3);
myFile.close();
delay (5000);
}
[/code]
7 posts - 4 participants