Hello,
I'm using ADS1292R to get simultaneous respiration and ECG data but I cannot get the correct data. I implemented the circuit according to the data sheet and I don't think there is a problem in that part. There seems a problem of data overflow if I used 500SPS because I did not see the overflow when I set the frequency to 250SPS but I want to use 500SPS, so please help me solve this problem.
Here is the code for setting up ADS1292R:
void setup_ADS1292 ()
{
send_command(SDATAC);
write_byte(CONFIG1, 0x02);// 500sps
write_byte(CONFIG2, 0xA0);
write_byte(CH1SET, 0x40); //PGA gain 4
write_byte(CH2SET, 0x00);
write_byte(RESP1, 0xF2); // 135 phase shift according to the data sheet
write_byte(RESP2, 0x03);
send_command(RDATAC);
digitalWrite(PIN_START, HIGH);
send_command(START);
}
Here is the code for getting respiration and ECG data:
void getEKGRESP ()
{
neco=0;
neco1=0;
dalsi = 1;
int numSerialBytes = 3 + (3 * nChannels); //8-bits header plus 24-bits per ACTIVE channel
unsigned char serialBytes[numSerialBytes]; //byte buffer
int i = 0;
digitalWrite(PIN_CS, LOW);
serialBytes[i++] = SPI.transfer(0x00); // get 1st byte of header
serialBytes[i++] = SPI.transfer(0x00); //skip 2nd byte of header
serialBytes[i++] = SPI.transfer(0x00); //skip 3rd byte of header
for (int ch = 1; ch <= gMaxChan; ch++) {
a = SPI.transfer(0x00);
b = SPI.transfer(0x00);
c = SPI.transfer(0x00);
// channel 1 for Respiration signal
if(ch==1){
if (a>0x7F) { //twos complement
a=~a;
b=~b;
c=~c;
aaa=(unsigned int)a<<8;
aaa=aaa<<8;
bbb=(unsigned int)b<<8;
ccc=(unsigned int)c;
neco=aaa|bbb|ccc;
neco=neco+1;
neco=-neco;
}
else {
aaa=(unsigned int)a<<8;
aaa=aaa<<8;
bbb=(unsigned int)b<<8;
ccc=(unsigned int)c;
neco=aaa|bbb|ccc;
}
}
// channel 2 for EKG signal
if(ch==2){
if (a>0x7F) {
a=~a;
b=~b;
c=~c;
aaa=(unsigned int)a<<8;
aaa=aaa<<8;
bbb=(unsigned int)b<<8;
ccc=(unsigned int)c;
neco1=aaa|bbb|ccc;
neco1=data_EKG+1;
neco1=-data_EKG;
}
else {
aaa=(unsigned int)a<<8;
aaa=aaa<<8;
bbb=(unsigned int)b<<8;
ccc=(unsigned int)c;
neco1=aaa|bbb|ccc;
}
}
}
digitalWrite(PIN_CS, HIGH);
data_RESP=neco/10;
data_EKG=neco1/10;
}