Hello everyone,
First of all I'm sorry if this topic has already been solved but I haven't found anything similar for this ADC model.
I interface an ADS112U04 with an ESP8266EX and I need to read 1000 SPS on one channel and 200 SPS on another channel.
The conversion on one channel works perfectly, but when I add more channels, many read errors occur, and the reading stalls.
At a sampling rate of 20 SPS, it works fine, but the higher I go, the more errors there are. Baudrate is 115200.
I proceed as follows (I don't know if this is the right way):
In setup :
- RESET by hardware
- acStartup(); //function provided by TI code
In loop :
uint8_t data_adc[12]; registerWrite(0x00, REG0_AIN0); registerWrite(0x01, REG1); registerWrite(0x02, REG2); registerWrite(0x03, REG3); registerWrite(0x04, REG4); for (int i = 0; i < 10; i += 2) { // Wait for GPIO2/DRDY to transition low while (digitalRead(GPIO_DRDY_PIN) == HIGH) {}; sendCommand_ADC(0x10); while (!Serial.available()); uint16_t dataLowByte = Serial.read(); while (!Serial.available()); uint16_t dataHighByte = Serial.read(); data_adc[i] = static_cast<uint8_t>(dataLowByte); data_adc[i + 1] = static_cast<uint8_t>(dataHighByte); } registerWrite(0x00, REG0_AIN2); registerWrite(0x01, REG1); registerWrite(0x02, REG2); registerWrite(0x03, REG3); registerWrite(0x04, REG4); for (int i = 10; i < 12; i += 2) { while (digitalRead(GPIO_DRDY_PIN) == HIGH) {}; sendCommand_ADC(0x10); while (!Serial.available()); uint16_t dataLowByte = Serial.read(); while (!Serial.available()); uint16_t dataHighByte = Serial.read(); data_adc[i] = static_cast<uint8_t>(dataLowByte); data_adc[i + 1] = static_cast<uint8_t>(dataHighByte); }
sendCommand_ADC function:
void sendCommand_ADC(uint8_t command) { Serial.write(SYNC_WORD); Serial.write(command); }
Register correspondence:
#define REG0_AIN0 (CONFIG0_MUX_AIN0_AVSS | CONFIG0_GAIN_1 | CONFIG0_PGA_BYPASS_NO) #define REG0_AIN2 (CONFIG0_MUX_AIN2_AVSS | CONFIG0_GAIN_1 | CONFIG0_PGA_BYPASS_NO) #define REG1 (CONFIG1_DR_600_SPS | CONFIG1_MODE_TURBO | CONFIG1_CM_CONTINUOUS | CONFIG1_VREF_EXT | CONFIG1_TS_DISABLED) #define REG2 (CONFIG2_DRDY_OLD | CONFIG2_DCNT_DISABLED | CONFIG2_CRC_DISABLED | CONFIG2_BCS_DISABLED | CONFIG2_IDAC_OFF) #define REG3 (CONFIG3_I1MUX_DISABLED | CONFIG3_I2MUX_DISABLED | CONFIG3_AUTO_MANUAL) #define REG4 (CONFIG4_GPIO2DIR_OUT | CONFIG4_GPIO1DIR_IN | CONFIG4_GPIO0DIR_IN | CONFIG4_GPIO2SEL_DRDY | CONFIG4_GPIO2DAT_LO | CONFIG4_GPIO1DAT_LO | CONFIG4_GPIO0DAT_LO)
Thanks to all