KrisKasprzak
Well-known member
All,
I was experimenting with using analogReference and have yet to get anything reliable working. I have a Teensy 3.2 powered by a 3v3 buck converter and a 10uf + a 0.1 uf cap across A3 to ground. This setup is used for both analogReference on and off.
My voltage applied to A3 is approx. 0.753 volts as read with a voltmeter. I'm not worrying about measuring exactly as my voltmeter reports, but I expect analogRead() to be close and somewhat reliable.
1. with analogReference (INTERNAL) commented out, vVolts is 0.7476 and around +/- 0.001 (which I consider close enough to input)
2. with analogReference(INTERNAL) included, vVolts is 2.065 and around +/- 0.005
It seems using internal analogReference requires a different REFERENCE_VOLTAGE and is noisier. I read somewhere that internal reference for Teensy 3.2 is 3v3 but something is wrong with my implementation.
Thoughts?
I was experimenting with using analogReference and have yet to get anything reliable working. I have a Teensy 3.2 powered by a 3v3 buck converter and a 10uf + a 0.1 uf cap across A3 to ground. This setup is used for both analogReference on and off.
My voltage applied to A3 is approx. 0.753 volts as read with a voltmeter. I'm not worrying about measuring exactly as my voltmeter reports, but I expect analogRead() to be close and somewhat reliable.
1. with analogReference (INTERNAL) commented out, vVolts is 0.7476 and around +/- 0.001 (which I consider close enough to input)
2. with analogReference(INTERNAL) included, vVolts is 2.065 and around +/- 0.005
It seems using internal analogReference requires a different REFERENCE_VOLTAGE and is noisier. I read somewhere that internal reference for Teensy 3.2 is 3v3 but something is wrong with my implementation.
Thoughts?
Code:
#define BIT_CONVERSION 4096
#define REFERENCE_VOLTAGE 3.3f
#define VM_PIN A3
float vVolts = 0.0f;
void setup() {
analogReadRes(12);
analogReadAveraging(4);
// constant voltage at A3 is about .753 volts
analogReference(INTERNAL);
}
void loop() {
// get the voltage
vVolts = analogRead(VM_PIN);
vVolts = vVolts / (BIT_CONVERSION / REFERENCE_VOLTAGE);
// analogReference commented out, vVolts is 0.7476 and around +/- 0.001 (which I consider close enough to input)
// analogReference(INTERNAL); vVolts is 2.065 and around +/- 0.005
// seems using internal requires a different REFERENCE_VOLTAGE and is noisier
Serial.println(vVolts, 3);
delay(100);
}