Hello epsilonRT, thank you very much for sharing your excellent library. It works very nicely, however I was hoping you could please assist, I'm having trouble performing a calibration.
I'm using the ad7124-thermometer.ino example, other than changing the gain to 8 and using a 6K reference resistor, the only change I made was to add the internalCalibration() function on channel zero at the end of void setup() and changed the power mode to MidPower as required for an internal calibration as noted in the AD7124 datasheet. At the end inside of void setup() in my ad7124-thermometer.ino sketch, the changed lines are as follows:
ret = adc.setAdcControl (StandbyMode, MidPower, true);
if (ret < 0) {
Serial.println ("Unable to set up ADC");
}
adc.internalCalibration(0);
Without adding the calibration I get perfect room temperature readings which respond correctly to temperature changes applied to the probe. However after adding the calibration I get a constant temp reading of -259.740 Celsius and the reading will not respond to any changes in temperature applied to the probe.
I added some printf() test messages in the internalCalibration() function in ad7124.cpp to test each stage of return ret; and it completes successfully to the end of the function to line:
return enableChannel (ch, false);
with no negative ret returns.
I tried to enable channel 0: adc.enableChannel (0, true); after the adc.internalCalibration(0); line in my sketch, which changed the temp readings to 1688.311 Celsius and the reading will still not respond to any changes in temperature applied to the probe.
Any help you could give would be greatly appreciated, and also was wondering about usage for system calibration as there is no system calibration function existing in ad7124.cpp. Thank you very much.
Below is the entire sketch for reference:
#include <ad7124.h>
#include <SPI.h>
using namespace Ad7124;
Ad7124Chip adc;
const int ledPin = LED_BUILTIN;
const int ssPin = 10;
const double Gain = 8;
const double Rf = 6E3;
const long Zero = 1L << 23;
const long FullScale = 1L << 24;
void setup() {
int ret;
long value;
pinMode (ledPin, OUTPUT);
digitalWrite (ledPin, 1); // clear the LED
Serial.begin (115200);
adc.begin (ssPin);
adc.setConfig (0, RefIn1, Pga8, true);
adc.setConfigFilter (0, Sinc4Filter, 384);
adc.setChannel (0, 0, AIN2Input, AIN3Input);
ret = adc.setAdcControl (StandbyMode, MidPower, true);
if (ret < 0) {
Serial.println ("Unable to set up ADC");
}
adc.internalCalibration(0);
adc.enableChannel (0, true); // tried with and without this line
}
void loop() {
long value;
adc.setConfig (0, RefIn1, Pga8, true);
adc.setCurrentSource (0, IoutCh0, Current500uA);
digitalWrite (ledPin, 0);
value = adc.read (0);
digitalWrite (ledPin, 1);
adc.setCurrentSource (0, IoutCh0, CurrentOff);
if (value >= 0) {
double r, t, tf = 0;
r = ((value - Zero) * Rf) / (Zero * Gain);
t = (r - 100.0) / 0.385;
tf = (t * 9 / 5) + 32;
Serial.print ("TEMP FAHRENHEIT = ");
Serial.println (tf, 3);
Serial.print ("TEMP CELSIUS = ");
Serial.println (t, 3);
}
else {
Serial.println ("AD7124 FAIL");
delay(100);
}
}
Hello epsilonRT, thank you very much for sharing your excellent library. It works very nicely, however I was hoping you could please assist, I'm having trouble performing a calibration.
I'm using the ad7124-thermometer.ino example, other than changing the gain to 8 and using a 6K reference resistor, the only change I made was to add the
internalCalibration()function on channel zero at the end ofvoid setup()and changed the power mode toMidPoweras required for an internal calibration as noted in the AD7124 datasheet. At the end inside ofvoid setup()in my ad7124-thermometer.ino sketch, the changed lines are as follows:Without adding the calibration I get perfect room temperature readings which respond correctly to temperature changes applied to the probe. However after adding the calibration I get a constant temp reading of -259.740 Celsius and the reading will not respond to any changes in temperature applied to the probe.
I added some
printf()test messages in theinternalCalibration()function in ad7124.cpp to test each stage ofreturn ret;and it completes successfully to the end of the function to line:return enableChannel (ch, false);with no negative
retreturns.I tried to enable channel 0:
adc.enableChannel (0, true);after theadc.internalCalibration(0);line in my sketch, which changed the temp readings to 1688.311 Celsius and the reading will still not respond to any changes in temperature applied to the probe.Any help you could give would be greatly appreciated, and also was wondering about usage for system calibration as there is no system calibration function existing in ad7124.cpp. Thank you very much.
Below is the entire sketch for reference: