Quantcast
Channel: Forums - Recent Threads
Viewing all articles
Browse latest Browse all 262198

ADS1298ECGFE-PDK: [EMG] Splitting incoming serial data and converting to volts?

$
0
0

Part Number:ADS1298ECGFE-PDK

Good Afternoon, 

I am working with the ADS1298 connected  SPI with a Bluefruit Feather MCU from Adafruit. I am using the ADS129x tools library by Adam Feuer.

I am using all 8 channels from ADS1298 for EMG and have isolated each channel data with the code found below.

The configuration is set for 2.4Vref with a PGA of 1 (for testing purposes) and I am using the approach provided : "You can do this by 'XORing' the data with 0x800000. Full scale positive is 0x7FFFFF, XORing that with 0x800000 would give you 0xFFFFFF. Full scale negative is 0x800000, which yields 0x000000 when XORed. Your code to voltage input relationship is essentially [code-1 (in decimal)*LSB size]/gain. The LSB size is given in page 30 under the Format section as VREF/(2^23-1). If you need to compensate for polarity, simply take the result and subtract your reference voltage."

Globals pertaining to this chunk of code: 

char hexDigits[] = "0123456789ABCDEF";
uint8_t serialBytes[200];
char sampleBuffer[1000];
long rawVoltageValue1;

uint32_t myData[8] = {0};  //save 8-Channel data as bits







inline void sendSamples(void) { 
  if ((!isRdatac) || (numActiveChannels < 1) )  return;
  if (digitalRead(IPIN_DRDY) == HIGH) return; 
  sendSample();
}

// Use SAM3X DMA
inline void sendSample(void) { 
  digitalWrite(PIN_CS, LOW);
  register int numSerialBytes = (3 * (maxChannels+1)); //24-bits header plus 24-bits per channel  (3 * numActiveChannels(+1)) This will only display the active channels
  uint8_t returnCode = spiRec(serialBytes, numSerialBytes);
  digitalWrite(PIN_CS, HIGH);
  register unsigned int count = 0;
  encodeHex(sampleBuffer, (char *)serialBytes, numSerialBytes);



for (int i = 1, j = 0; i <= 8, j < 8; i++, j++)  
  {
    myData[j] = (uint32_t)(serialBytes[3 * i]) << 16 |
                (uint32_t)(serialBytes[3 * i + 1]) << 8 |
                (uint32_t)(serialBytes[3 * i + 2]);
  }
  

  
  for (int j = 0; j < 8; j++)
  {
    
     
     ((myData[j]^ 0x800000)-1)*((2.4*(pow(2,23)-1)));
  }

 Serial.println(myData[0]);

}





void encodeHex(char* output, char* input, int inputLen) {
  register int count = 0;
  for (register int i=0; i < inputLen; i++) {
    register uint8_t lowNybble = input[i] & 0x0f; //Nyblble = 4 bits
    register uint8_t highNybble = input[i] >> 4;
    output[count++] = hexDigits[highNybble];
    output[count++] = hexDigits[lowNybble];
  }
  output[count] = 0;
}

This is output I am getting ? 

Not sure what I am doing wrong here?


Viewing all articles
Browse latest Browse all 262198

Trending Articles