Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Beginner
1,465 Views

SPI : mraa_spi_write_buf function problem. Read data error in ECG signals using ADS1298.

Hi, please, I need some help regarding the acquisition way using the SPI interface. I'm doing an ECG acquisition system using ADS1298 and a Intel Edison Arduino module. The scenario is the following:

I am using the MRAA SPI library for reading data from an IC: ADS1298.

The IC: ADS1298 sends a falling edge signal every time a data frame is available.

The data frame has a size of 27 bytes = 9 words of 24 bits and this should be read completely

in less than 4 milliseconds. The SPI frequency is set to 4MHz. I use GPIO Interrupt to know when to read

My code is as follows.

if(ads1298_ready==1){

mraa_gpio_write(cs, 0);

usleep(1);

mraa_spi_transfer_buf(ads, trama_data, trama_rcv, 27); //read 27 bytes data frame and store in a trama_rcv buffer

usleep(1);

mraa_gpio_write(cs, 1);

for(i=0;i<9;i++){</span>

canal[i]=trama_rcv[3*i]; //separated data in 9 channels

canal[i]=(canal[i]<<8) | trama_rcv[3*i+1]; //separated data in 9 channels</span>

canal[i]=(canal[i]<<8) | trama_rcv[3*i+2]; //separated data in 9 channels</span>

if((canal[i]>=0x800000)&&(canal[i]<=0xFFFFFF)){canal[i]|=0xFF000000;} //Positive or Negative </span>

fcanal[i]=(float)canal[i]/0x7FFFFF; 0 to 1

fcanal[i]=2.4*fcanal[i]; Vref=2.4

}

}

 

 

The reading and writing of the registers of the ADS1298 is perfectly done but the problem occurs when reading the 27 bytes data frame because in some instants the acquired data are not correct. This problem is shown in the next image.

In the image above, I print 2 Channel of the 27 bytes data frame. The red circles show the data error. Thanks in advance.

0 Kudos
3 Replies
Highlighted
Community Manager
56 Views

Hello Richard,

 

 

Thank you for your interest in the Intel Edison board.

 

Your request has been received and is currently being investigated.

 

We will get back to you as soon as possible.

 

 

Regards,

 

Octavian
0 Kudos
Highlighted
Community Manager
56 Views

Hello rahrnible,

 

 

 

Thank you very much for your patience in receiving an answer to your query.

 

 

After investigating, we have noticed that with the SPI interface in Edison, some sensors work just fine and some others don't.

 

Based on previous customer experiences using SPI like mentioned here /thread/109617 https://communities.intel.com/thread/109617, there are limitations to the SPI interface with frequencies greater than 3 MHz.

 

I'd suggest to try a lower frequency (i.e. 2 MHz) and hopefully that works.

 

Also make sure the board is flashed to use the latest firmware image as well as the most current mraa library version.

 

 

 

Let me know if this helps.

 

 

Regards,

 

Casandra
0 Kudos
Highlighted
Community Manager
56 Views

Hello rahrnible,

 

 

 

Was the information provided previously helpful?

 

Do you have any other queries on this topic?

 

 

 

Regards,

 

Casandra
0 Kudos