24位ADC(ADS131E08)采样数据经常出现完全错误的数据,有电路图有程序,求大家帮助。
我在使用ADS131E08的过程中发现采样的数据偶尔会出现完全错误的数据,大概每30次采样中就会出现一次。
我用24位模式采样内部test signal信号。
问题描述: 完全错误的数据可能从第一个通道开始,后面7个通道连着都是错的。也有可能从任何一个通道开始出错,这个通道后面的通道都会出错。
下面是ADS131E08的寄存器配置和读取。电路板上只焊接了两片ADC,所以输出只有2个ADC的数据。
错误数据如下:以下三组数据的第四行、第三行、第三行出现了完全错误的数据,不知道为啥就莫名的出错,实在找不到问题所在了
1c1= -1053,1c2= -1286,1c3= -1163,1c4= -1301,1c5= -1385,1c6= -1393,1c7= -1272,1c8= -1142
3c1= -1306,3c2= -1236,3c3= -1164,3c4= -1185,3c5= -1406,3c6= -1484,3c7= -1121,3c8= -1164
1c1= -1046,1c2= -1268,1c3= -1123,1c4= -1300,1c5= -1402,1c6= -1386,1c7= -1294,1c8= -1156
3c1= -1302,3c2= -1237,3c3= -1161,3c4= -1180,3c5= -1408,3c6= -159,3c7= 522367,3c8= -166656
1c1= -1060,1c2= -1264,1c3= -1145,1c4= -1272,1c5= -1420,1c6= -1433,1c7= -1281,1c8= -1198
3c1= -1305,3c2= -1230,3c3= -1167,3c4= -1180,3c5= -1398,3c6= -1488,3c7= -1105,3c8= -1160
1c1= -1079,1c2= -1256,1c3= -1130,1c4= -1318,1c5= -1395,1c6= -1426,1c7= -1334,1c8= -1167
3c1= -1304,3c2= -1233,3c3= -1166,3c4= -1186,3c5= -1402,3c6= -1480,3c7= -1116,3c8= -1157
1c1= -64,1c2=-4194383,1c3=-1048647,1c4=-2097233,1c5=-7340118,1c6= -89,1c7= 3145644,1c8=-5242953
3c1= -1294,3c2= -1250,3c3= -1161,3c4= -1187,3c5= -1402,3c6= -1472,3c7= -1118,3c8= -1171
1c1= -1086,1c2= -1253,1c3= -1125,1c4= -1302,1c5= -1350,1c6= -1411,1c7= -1315,1c8= -1208
1c1= -1040,1c2= -1233,1c3= -1131,1c4= -1255,1c5= -1408,1c6= -1410,1c7= -1311,1c8= -1196
3c1= -1306,3c2= -1237,3c3= -1160,3c4= -1186,3c5= -1391,3c6= -1479,3c7= -1121,3c8= -1163
1c1= -1035,1c2= -1293,1c3= -1142,1c4= -1312,1c5= -1406,1c6= -353,1c7= 4193978,1c8= -300
3c1= -1297,3c2= -1241,3c3= -1162,3c4= -1183,3c5= -1403,3c6= -1484,3c7= -1120,3c8= -1161
1c1= -1015,1c2= -1267,1c3= -1155,1c4= -1273,1c5= -1399,1c6= -1419,1c7= -1290,1c8= -1191
3c1= -1301,3c2= -1237,3c3= -1168,3c4= -1185,3c5= -1405,3c6= -1480,3c7= -1120,3c8= -1162
1c1= -1018,1c2= -1248,1c3= -1159,1c4= -1311,1c5= -1393,1c6= -1429,1c7= -1325,1c8= -1166
3c1= -1296,3c2= -1246,3c3= -1169,3c4= -1185,3c5= -159,3c6= 522367,3c7= -166400,3c8= -158720
1c1= -1071,1c2= -1257,1c3= -1147,1c4= -1305,1c5= -1408,1c6= -1423,1c7= -1338,1c8= -1195
3c1= -1307,3c2= -1241,3c3= -1165,3c4= -1190,3c5= -1405,3c6= -1480,3c7= -1121,3c8= -1164
1c1= -1046,1c2= -1244,1c3= -1118,1c4= -1288,1c5= -1400,1c6= -1426,1c7= -1306,1c8= -1190
3c1= -1308,3c2= -1235,3c3= -1165,3c4= -1183,3c5= -1403,3c6= -1480,3c7= -1113,3c8= -1166
u8 ADS131E08_Init(void)
{
u8 i=0,j=0,TimeOutCheck=0;
GPIO_InitTypeDef GPIO_InitStruct;
u8 ADS131E08_Test_Init[][2] =
{
{0x96, CONFIG1}, // RESOLUTION~24BIT; DATARATE(kSPS)~1000Hz
{0xF3, CONFIG2},
{0x15, CH1SET},
{0x15, CH2SET},
{0x15, CH3SET},
{0x15, CH4SET},
{0x15, CH5SET},
{0x15, CH6SET},
{0x15, CH7SET},
{0x15, CH8SET},
};
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA, ENABLE);
SPI_mode_change_1(SPI_BaudRatePrescaler_32);
/* ADC_START */
GPIO_InitStruct.GPIO_Pin = GPIO_Pin_3;
GPIO_InitStruct.GPIO_Mode = GPIO_Mode_OUT;
GPIO_InitStruct.GPIO_OType = GPIO_OType_PP;
GPIO_InitStruct.GPIO_PuPd = GPIO_PuPd_UP;
GPIO_InitStruct.GPIO_Speed = GPIO_Speed_25MHz;
GPIO_Init(GPIOA, &GPIO_InitStruct);
ADC_STOP;
/*ADC_DRDY Configure PA0 pin as input floating */
GPIO_InitStruct.GPIO_Pin = GPIO_Pin_4;
GPIO_InitStruct.GPIO_Mode = GPIO_Mode_IN;
GPIO_InitStruct.GPIO_PuPd = GPIO_PuPd_UP;
GPIO_Init(GPIOA, &GPIO_InitStruct);
ADC1_CS_LOW;
ADC2_CS_LOW;
ADC3_CS_LOW;
SPI_SendByte(SPI1, RESET);
delayms(750);
SPI_SendByte(SPI1, SDATAC);
delayus(10);
ADC1_CS_HIGH;
ADC2_CS_HIGH;
ADC3_CS_HIGH;
for(i=0; i<sizeof(ADS131E08_Test_Init)/2; i++){
for(j=1;j<4;j++){
ADS131E08_WriteReg(j, ADS131E08_Test_Init[i][1], ADS131E08_Test_Init[i][0]);
delayus(2);
}
}
ADC_START;
ADC1_CS_LOW;
ADC2_CS_LOW;
ADC3_CS_LOW;
delayus(1);
SPI_SendByte(SPI1, RDATAC); //Put the Device Back in RDATAC Mode
delayus(1);
ADC1_CS_HIGH;
ADC2_CS_HIGH;
ADC3_CS_HIGH;
}
void ADS131E08_Read(s32 *adc1buf,s32 *adc2buf,s32 *adc3buf)
{
u8 ReadBuf[27],i=0;
if(ADC_DRDY==0)
{
ADC1_CS_LOW;
delayus(1);
for(i=0;i<27;i++){
ReadBuf[i]=SPI_ReadByte(SPI1);
delayus(1);
}
ADC1_CS_HIGH;
for(i=0;i<9;i++)
adc1buf[i]=ReadBuf[3*i]<<16 |ReadBuf[1+3*i]<<8 |ReadBuf[2+3*i];
for(i=1;i<9;i++){
if(adc1buf[i]>=0x800000)
adc1buf[i]-=0xffffff;
}
ADC2_CS_LOW;
delayus(1);
for(i=0;i<27;i++){
ReadBuf[i]=SPI_ReadByte(SPI1);
delayus(1);
}
ADC2_CS_HIGH;
for(i=0;i<9;i++)
adc2buf[i]=ReadBuf[3*i]<<16 |ReadBuf[1+3*i]<<8 |ReadBuf[2+3*i];
for(i=1;i<9;i++){
if(adc2buf[i]>=0x800000)
adc2buf[i]-=0xffffff;
}
ADC3_CS_LOW;
delayus(1);
for(i=0;i<27;i++){
ReadBuf[i]=SPI_ReadByte(SPI1);
delayus(1);
}
ADC3_CS_HIGH;
for(i=0;i<9;i++)
adc3buf[i]=ReadBuf[3*i]<<16 |ReadBuf[1+3*i]<<8 |ReadBuf[2+3*i];
for(i=1;i<9;i++){
if(adc3buf[i]>=0x800000)
adc3buf[i]-=0xffffff;
}
printf("1c1=%8d,1c2=%8d,1c3=%8d,1c4=%8d,1c5=%8d,1c6=%8d,1c7=%8d,1c8=%8d\n",adc1buf[1],adc1buf[2],adc1buf[3],adc1buf[4],adc1buf[5],adc1buf[6],adc1buf[7],adc1buf[8]);
printf("3c1=%8d,3c2=%8d,3c3=%8d,3c4=%8d,3c5=%8d,3c6=%8d,3c7=%8d,3c8=%8d\n",adc3buf[1],adc3buf[2],adc3buf[3],adc3buf[4],adc3buf[5],adc3buf[6],adc3buf[7],adc3buf[8]);
}
}
错误数据如下(以下数据是两个ADC共16个通道的数据):
第一组数据的第二行的3c5(ADC3的第五通道) 开始出现完全错误的数据,下一次采样中又开始正常了。
第二组数据的第三行的1c6(-353)开始出现离奇错误。
第三组数据的第三行开始就都错了,下一次采样中又是准确的。
我实在搞明白是哪里出了问题,电路图和程序我检查了好多遍,依然找不到问题所在,拜托大家帮帮忙了,十分感谢!
1c1= -1018,1c2= -1248,1c3= -1159,1c4= -1311,1c5= -1393,1c6= -1429,1c7= -1325,1c8= -1166
3c1= -1296,3c2= -1246,3c3= -1169,3c4= -1185,3c5= -159,3c6= 522367,3c7= -166400,3c8= -158720
1c1= -1071,1c2= -1257,1c3= -1147,1c4= -1305,1c5= -1408,1c6= -1423,1c7= -1338,1c8= -1195
3c1= -1307,3c2= -1241,3c3= -1165,3c4= -1190,3c5= -1405,3c6= -1480,3c7= -1121,3c8= -1164
1c1= -1040,1c2= -1233,1c3= -1131,1c4= -1255,1c5= -1408,1c6= -1410,1c7= -1311,1c8= -1196
3c1= -1306,3c2= -1237,3c3= -1160,3c4= -1186,3c5= -1391,3c6= -1479,3c7= -1121,3c8= -1163
1c1= -1035,1c2= -1293,1c3= -1142,1c4= -1312,1c5= -1406,1c6= -353,1c7= 4193978,1c8= -300
3c1= -1297,3c2= -1241,3c3= -1162,3c4= -1183,3c5= -1403,3c6= -1484,3c7= -1120,3c8= -1161
1c1= -1015,1c2= -1267,1c3= -1155,1c4= -1273,1c5= -1399,1c6= -1419,1c7= -1290,1c8= -1191
1c1= -1079,1c2= -1256,1c3= -1130,1c4= -1318,1c5= -1395,1c6= -1426,1c7= -1334,1c8= -1167
3c1= -1304,3c2= -1233,3c3= -1166,3c4= -1186,3c5= -1402,3c6= -1480,3c7= -1116,3c8= -1157
1c1= -64,1c2=-4194383,1c3=-1048647,1c4=-2097233,1c5=-7340118,1c6= -89,1c7= 3145644,1c8=-5242953
3c1= -1294,3c2= -1250,3c3= -1161,3c4= -1187,3c5= -1402,3c6= -1472,3c7= -1118,3c8= -1171
1c1= -1086,1c2= -1253,1c3= -1125,1c4= -1302,1c5= -1350,1c6= -1411,1c7= -1315,1c8= -1208
3c1= -1301,3c2= -1238,3c3= -1163,3c4= -1187,3c5= -1401,3c6= -1486,3c7= -1123,3c8= -1156
这种情况只能估计和排除. 我觉得比较大的可能性在于数据传输的过程中的时序错误导致的, 当然也不排除信号里大噪声脉冲.