Other Parts Discussed in Thread: ADS131A04, ADS131E04
Hey
I am using ADS131e08 IC using arduino. ADC works fine for every individual channel, but shows garbage data when i use more than one channel. here i am enclosing read data code.
void read_data()
{
const uint8_t nof_bytes = 3*num_ch+3;
uint8_t data[nof_bytes];
long resp[nof_bytes];
memset(data, 0x00, sizeof(data));
while (digitalRead(DRDY_PIN) == HIGH);
if (digitalRead(DRDY_PIN) == LOW)
{
digitalWrite(CS_PIN, LOW);
delayMicroseconds(1);
for (int i = 0; i < nof_bytes; i++)
{
resp[i] = SPI.transfer(data[i]) ;
}
delayMicroseconds(1);
digitalWrite(CS_PIN, HIGH);
}
for (int ch = 1; ch <= num_ch; ch++)
{
long val = 0;
long value = 0;
val= (((resp[(3*(ch))+0]&0xff) << 16) | ((resp[(3*(ch))+1]&0xff) << 8) | (resp[(3*(ch))+2]&0xff));
if( ((val & 0xffffff) & (0x800000)))
{
value = val|0xff000000;
}
else
{
value = val;
}
float volt = (float(value)*2.4/8388607);
if (ch == 1)
{ Serial.print(volt); Serial.print("\t"); }
if (ch == 2)
{ Serial.print(volt); Serial.print("\t"); }
if (ch == 3)
{ Serial.print(volt); Serial.print("\t"); }
if (ch == 4)
{ Serial.print(volt); Serial.print("\t"); }
if (ch == 5)
{ Serial.print(volt); Serial.print("\t"); }
if (ch == 6)
{ Serial.print(volt); Serial.print("\t"); }
if (ch == 7)
{ Serial.print(volt); Serial.print("\t"); }
if (ch == 8)
{ Serial.println(volt); }
}
}