主题中讨论的其他器件: ADS131A04、 ADS131E04
你好
我使用的是使用 Arduino 的 ADS131e08 IC。 每个通道的 ADC 工作正常、但在使用多个通道时显示垃圾数据。 我在此附上读取数据代码。
void read_data()
{
const uint8_t nof 字节= 3*num_ch+3;
uint8_t data[nof 字节];
long resp.[nof 字节];
memset (data、0x00、sizeof (data));
while (digitalRead (DRDY_PIN)=高电平);
if (digitalRead (DRDY_PIN)=低电平)
{
digitalWrite (CS_PIN、低电平);
delayMicroseconds (1);
对于(int i = 0;i < nof 字节;i++)
{
RESP[i]= SPI.transfer (data[i]);
}
delayMicroseconds (1);
digitalWrite (CS_PIN、高电平);
}
对于(int ch = 1;ch <= num_ch;ch++)
{
long val = 0;
长值= 0;
Val=(((RESP[(3*(ch))+0]&0xff)<< 16)|((RESP[(3*(ch)+1]&0xff)<< 8)|(RESP[(3*(ch)+2]&0xff));
if (((val & 0xffffffff)&(0x800000)))
{
值= val|0xc000000;
}
其他
{
值= val;
}
float volt =(float (value)*2.4/8388607);
如果(ch ==1)
{Serial.print (volt);Serial.print ("\t");}
如果(ch == 2)
{Serial.print (volt);Serial.print ("\t");}
如果(ch == 3)
{Serial.print (volt);Serial.print ("\t");}
如果(ch == 4)
{Serial.print (volt);Serial.print ("\t");}
如果(ch == 5)
{Serial.print (volt);Serial.print ("\t");}
如果(ch == 6)
{Serial.print (volt);Serial.print ("\t");}
如果(ch == 7)
{Serial.print (volt);Serial.print ("\t");}
如果(通道==8)
{ Serial.println (volt);}
}
}