Close

Firmware for OpenLD: STM32F4 w/ ADS1299

A project log for OpenLD: Lucid Dreaming Research Platform

An open source platform to help induce and explore the realm of Lucid Dreaming for Research and Personal Well-being

jae-choiJae Choi 09/12/2016 at 19:070 Comments

I apologize for the lack of build logs. I will be uploading them more frequently, as I have progressed significantly in terms of firmware & software for this project.

Github repo for the (beta) version of the OpenLD firmware here!

Apologies of the rogue assembly codes in the firmware. The readability of the entire firmware will be improved in the future, I promise.

General Overview of the Firmware

In the STM32F4, we need to enable the required peripherals in order to use them. Therefore, the program starts out by enabling GPIO, SPI (for ADS1299), UART (for the Bluetooth module), and Interrupts. Also, it sets up the configuration registers for ADS1299, which is described below. The program then goes into an infinite loop and relies on interrupts for the rest.

The firmware has 3 concurrent interrupts. The interrupt EXTI9_5_IRQHandler, which is activated by the ADS1299 DRDY signal (pg. 8-9), reads data 250 samples per second from the ADS1299. This data is saved in a buffer.

Meanwhile, interrupt EXTI0_IRQHandler is triggered when 250 samples are received in the buffer, hence every second, and sends it to the RN42 through UART for Bluetooth transfer. Since the update rate is not a huge issue, I have opted for 1-second packet transfers for simplicity.

There is also another interrupt for SETTINGS() option, which presents a command line-like interface that is used for enabling & configuring channels. This interrupt is triggered by sending a 'S' character.

ADS1299 EEG IC from Texas Instruments

Title

WHOAMI signal from ADS1299 (ID Control Register), captured from the SPI bus with a logic analyzer

The ADS1299 is an all-in-one chip for EEG data acquisition, which makes the hardware much simpler (no need to worry about amplifiers and DRL!). After reading through the 65 page long datasheet, I came to the following conclusion for the configuration (I highly recommend going through the datasheet yourself, as it is fairly involved):

In the Github repo above, the function ads1299_init() in the file cmd_ADS1299.c initializes the features described above.

I apologize for this rough explanation. This is just a beginning of the software side of OpenLD. Now, things are going to get much more interesting. Next time, we'll be evaluating the performance of the OpenLD.

Discussions