Collecting ECG signal with TI ADS1299 daughter card and STM32F4 Discovery

on Wednesday, May 28, 2014
I will blog about my journey from the beginning with the ADS1299 than I'll write about my ECG recording session. This project is my thesis so I can't post everything before I complete it. I started with the ADS1299 Evaluation module from January 2014. The module is helpful to get the feel of ADS1299 chip. A software comes with the module can collect couple seconds of data with different configurations. The designer of the Evaluation board created many jumpers and test points for multiple usage scenarios but it's very confusing to set them up. You will love it later when you understand the design.

Build my own module:
I decided to follow a tutorial from Chris Rorden's Neuropsychology Lab which shows a way to collect data from TI daughter card by any micro controller with SPI capability. The tutorial is on Arduino; I ported it to STM32F4 Discovery module.
ADS1299 EVM + STM32F4 Discovery + Bluetooth module

Collecting ECG signal:
My ECG set up for this time. another variation is at EEG hacker with disposable electrode.


My ECG data without right leg electrode
I expected to get a noisy signal without a right leg electrode. I don't think it's this bad. Probably I will redo the test later.
My ECG data with Right Leg Drive
It's very interesting that Chip from EEG Hacker can capture a good ECG signal with only two electrodes on two hands without a right leg or reference electrode. I can't get any useful data with only two electrodes. The noise overwrites my ECG signal.
I'm very happy with my ECG signal. It shows that my module is working at 1mV peak-to-peak signal. My next step is to test the EOG signal. EEG signal is still far away from now.

Update 1: My wiring configuration
Because Sebastian asked me to share the wiring configuration for the STMF4, I would like to share my note on the design. There are three main groups of pins in this design:
 SPI group: MOSI, MISO, CS, DRDY, START, SCK
UART group: TX, RX
Generic pins: Power, PWDN, Reset

STM32F4 Pin configuration with ADS 1299 EVM
Below are the pin details. Upper half presents signal pins. Lower half presents power pin.

11 comments:

Mariam Hassib said...

Hi,
I am really enjoying your blog and your EEG discoveries. I am also working on a similar project. I previously worked with EEG but using commercial devices (Neurosky) Now I am trying to get into it more and build my own BCI. I have an ADS1299 evaluation module and I am trying to also collect ECG signals as a start. I have 3 electrodes (disposable). I connected one to the +ve input of channel 1, and one to the +ve input of channel 2. As for the reference electrode I will connect it to pin 5 or 6 from JP25. Is this correct? I am not really understanding the TI manual and I do not know what to do with the negative inputs (should I remove all jumpers or just the ones I need from the input channels?). I am new to electronics and I know some questions are pretty basic :)
I would really appreciate your help!

Unknown said...

Hi Mariam,
Thanks for visiting my blog. It's great to meet someone in the same field. The Neurosky sounds fun. I saw many others did interesting project with it.
For the ADS1299 EVM module, the TI manual is vague and brief. It's very difficult to understand. Different jumpers set up on the board will lead to different electrode connections. I can't tell without knowing your set up. Because you said that you started to collect ECG signal as a start, I think you may start with something else which is simpler. Did you try to use the module as a voltage meter? test the internal test signal using TI software? These tests are very helpful to check out the board.

Mariam Hassib said...

Yes exactly the TI manual is very bad :S Especially for an electronics beginner! Well I did try the internally generated signals and they worked. How can I use the module as a voltage meter? May I also ask what kind of software do u use to visualize the signals? (i was using the one coming with the EVM). I tried connecting the electrodes as I mentioned above but all i get is a wrong sinusoid don't know where that is coming from even..

Unknown said...
This comment has been removed by the author.
Unknown said...

Hi
can you explain your spi configuration I try to do same project but I could not understand ,how can I do it from datasheet
SPI_HandleTypeDef spi_init; //for the spi initialization
GPIO_InitTypeDef gpio_init;// fot the gpio init



void init_spi()
{
__SPI1_CLK_ENABLE();
spi_init.Instance=SPI1;
spi_init.Init.BaudRatePrescaler=SPI_BAUDRATEPRESCALER_16;

spi_init.Init.CLKPhase=SPI_PHASE_2EDGE;
spi_init.Init.CLKPolarity=SPI_POLARITY_LOW;
spi_init.Init.CRCCalculation=SPI_CRCCALCULATION_DISABLED;
spi_init.Init.CRCPolynomial=7;
spi_init.Init.DataSize=SPI_DATASIZE_8BIT;
spi_init.Init.Direction=SPI_DIRECTION_2LINES;
spi_init.Init.FirstBit=SPI_FIRSTBIT_MSB;
spi_init.Init.Mode=SPI_MODE_MASTER;
spi_init.Init.NSS=SPI_NSS_HARD_INPUT;
spi_init.Init.TIMode=SPI_TIMODE_DISABLED;

__GPIOA_CLK_ENABLE();
//gpio initialize
gpio_init.Alternate=GPIO_AF5_SPI1;
gpio_init.Mode=GPIO_MODE_AF_PP;
gpio_init.Pin=GPIO_PIN_5|GPIO_PIN_6|GPIO_PIN_7;
gpio_init.Pull=GPIO_PULLDOWN;
gpio_init.Speed=GPIO_SPEED_MEDIUM;

__GPIOE_CLK_ENABLE();

HAL_GPIO_Init(GPIOA,&gpio_init);
HAL_SPI_Init(&spi_init);

gpio_init.Pin = GPIO_PIN_8;
gpio_init.Mode = GPIO_MODE_OUTPUT_PP;
gpio_init.Pull = GPIO_NOPULL;
gpio_init.Speed = GPIO_SPEED_FAST;

HAL_GPIO_Init(GPIOA,&gpio_init);


if(HAL_SPI_Init(&spi_init) != HAL_OK)
{

}
}

void InitializeLEDs()
{
__GPIOD_CLK_ENABLE();
GPIO_InitTypeDef GPIO_init;
GPIO_init.Pin=GPIO_PIN_12|GPIO_PIN_13|GPIO_PIN_14|GPIO_PIN_15;
GPIO_init.Mode=GPIO_MODE_OUTPUT_PP;
GPIO_init.Speed=GPIO_SPEED_FAST;
GPIO_init.Pull=GPIO_NOPULL;

HAL_GPIO_Init(GPIOD,&GPIO_init);
HAL_GPIO_WritePin(GPIOD,GPIO_PIN_12|GPIO_PIN_13|GPIO_PIN_14|GPIO_PIN_15,GPIO_PIN_SET);
}


int main()
{
init_spi();
uint8_t gelen = 0;
int i=0;

InitializeLEDs();
CS_LOW();
SPI_WriteRead(_WAKEUP);
CS_HIGH();

for(i=0; i<100000; i++);

CS_LOW();
SPI_WriteRead(_SDATAC);
CS_HIGH();

for(i=0; i<100000; i++);

while (1)
{

Test(&gelen);
for(i=0;i<100000;i++);
trace_printf("%d\n" ,gelen);
if(gelen==0)
{
HAL_GPIO_WritePin(GPIOD,GPIO_PIN_12|GPIO_PIN_13|GPIO_PIN_14|GPIO_PIN_15,GPIO_PIN_RESET);
}
else
{
HAL_GPIO_WritePin(GPIOD,GPIO_PIN_12|GPIO_PIN_13|GPIO_PIN_14|GPIO_PIN_15,GPIO_PIN_SET);
}
}

Unknown said...

Hi Thong,

very interesting design. I also started playing around with the TI EVM and the Teensy posted on Chris Rordens web page. However, I was recently thinking about switching to the STM discovery board.
May I ask two questions: [1] Could you provide information about the wiring? [2] Did you adapt the firmware from Chris Rorden to run with the STM? Or isn't that necessary?

Thanks a lot for your help!

Sebastian

Unknown said...

Hi Sebastian,
1. I posted my wiring in the blog. Is it what you are looking for?
2. The Chris Rordens firmware provided me concepts on how to communicate with the ADS module by SPI. I have to write the the STM firmware from the ground up because two platforms are quite different.

Unknown said...

Hi Thong,

thank you very much for posting the wiring diagram! Yes, this is exactly what I was looking for.

With respect to the firmware, maybe we should join forces (unless you already have it finished). A good starting point might also be STM32F4 firmware provided with the eeg-mouse project. I can send it to you upon request (it seems not possible to upload files here?).

Thanks again and best regards!

Sebastian

Unknown said...

Hi Sebastian,
Glad to hear that it's helpful for you.

I interested in a joice force. Let's meet on skype! My enail is vo.tri.thong@gmail.com. Pls drop me a message.
Thank you.
Thong Vo

Unknown said...

Hi, I am happy to see your nice posting on the blog. I also purchased ads1299 evaluation module. and as you know it consists of 2 board (mother and daughter) and you are using only daughter board. Can I ask you why you aren't using mother board? is not possible to use mother board as real time EEG detector with daughter board?

Unknown said...

I recently purchased a ADS1299 daughter board and was trying to interface with a UNO board. However when i am powering the board with MBMO it seems to be working fine however i am not able to get data with a standalone arduino board. It would be greatly helpful if the connection diagrams were available.

Post a Comment