Hello all,
I've created a sketch to read some outputs from an analog-to-digital converter. I've chosen the AD7124, from Analog Devices, and found a well-reviewed library online from EpsilonRT : https://github.com/epsilonrt/ad7124.
I uploaded the sketch to my board (a homebrew board with Teensy 3.2 parts, plus the aforementioned AD7124). All is well - I can read the desired ports, plus the device ID. BUT... if I power-cycle the board, the serial port produces inaccurate AD7124 values - all static values of -2 and -2.5. I probed all SPI signals, including CSS, and they are still toggling; also, serial port is still indicated correctly in the Arduino app. I tried loading a separate, un-related sketch, and it works OK, even after a power cycle.
So, is my sketch faulty, or perhaps this library is working some evil on the serial port settings?
Many thanks!
---------------------------------------
Here's my ultra-short sketch:
I've created a sketch to read some outputs from an analog-to-digital converter. I've chosen the AD7124, from Analog Devices, and found a well-reviewed library online from EpsilonRT : https://github.com/epsilonrt/ad7124.
I uploaded the sketch to my board (a homebrew board with Teensy 3.2 parts, plus the aforementioned AD7124). All is well - I can read the desired ports, plus the device ID. BUT... if I power-cycle the board, the serial port produces inaccurate AD7124 values - all static values of -2 and -2.5. I probed all SPI signals, including CSS, and they are still toggling; also, serial port is still indicated correctly in the Arduino app. I tried loading a separate, un-related sketch, and it works OK, even after a power cycle.
So, is my sketch faulty, or perhaps this library is working some evil on the serial port settings?
Many thanks!
---------------------------------------
Here's my ultra-short sketch:
Code:
const int CSS = 15; // uC pin 15 Teensy 3.2
Ad7124Chip adc; // create an object
long value;
double voltage;
void setup() {
delay(1000);
SPI.begin();
Serial.begin(115200);
Serial.println("AD7124 VM");
pinMode(CSS,OUTPUT);
digitalWrite(CSS,HIGH);
adc.begin(CSS);
adc.setConfig (0, Ad7124::RefInternal, Ad7124::Pga1, true);
adc.setChannel (0, 0, Ad7124::AIN3Input, Ad7124::AIN0Input);
adc.setAdcControl (Ad7124::ContinuousMode, Ad7124::FullPower, true);
}
void loop() {
value = adc.read (0); // Ch 0 defined above in setChannel
voltage = Ad7124Chip::toVoltage (value, 1, 2.5, true); //value, gain, vref, bipolar boolean
Serial.println(voltage, 3);
value = adc.getRegister (AD7124_ID_REG);
Serial.print("Dev ID ");
Serial.println(value);
delay(2000);
}
Last edited by a moderator: