Monday, February 3, 2014

MindFlex headset Arduino interfacing

Posted by rinson

Simple EEG reading

The basic data that comes out of the MindFlex headset by default actually gives us quite a lot of information for only £40. In the default configuration you have soldered on only two connections, one for a common ground and one for the serial data stream. I connect this to a SoftwareSerial pin on the Arduino and read in the packets. Here's what data you get:
  • Signal strength (0 - 200) where 0 means good signal, and 200 indicates a problem with the connection.
  • Attention and Meditation eSense values. These are a proprietary measure that is calculated by the TGAM1 using NeuroSky's own algorithm. The toys based on this technology use the attention measure.
  • EEG power band values: A measure of the various power bands that has been pre-calculated by the chip, this updates once per second.
The Arduino Brain Library already includes functionality for working with these values.

TGAM1 Region Change

If you bought the EU version and you're in EU then skip this bit.
The MindFlex, MindSet, Necomimi, etc all based on the TGAM1 that includes a notch filter on the EEG wave to remove electrical noise from the data. If you bought a MindFlex from a different region then you will need to adapt it to work for you. For example, if you've bought a headset from the US it will have a notch filter at 60Hz. In Europe our "mains hum" is at 50Hz. You can switch the notch filter to work at the correct frequency with a bit of soldering.

Getting full RAW EEG data

Now on to getting the full raw EEG data from the MindFlex headset. In addition to the two connections you soldered on before there are two extra connections required. This allows you to configure the TGAM1 board that is in the MindFlex to switch between two modes. The 'configure' connection is actually called B1 on the TGAM1 board. In the MindFlex headset B1 is connected to GND via a 10K resistor. I have marked this resistor with an X on the image.
You need to remove this 10K resistor from the circuit board, and connect B2 to VCC via a 10K resistor to enable full raw EEG data output.
The full EEG data is output at the higher baud rate of 57600. You also get the same packets as in normal mode.
You can switch back to normal mode, with just the basic data output at baud rate of 9600 by connecting B1 back to GND with the 10K resistor instead of the VCC connection.

Signal strength

The normal data and raw data modes both give you the summary packet once every second. In this is a measure of signal strength. It should be zero to indicate that the board is getting good measurements. Anything more than 0 indicates poor signal, and 200 is used to indicate a problem.
When I had the Arduino hooked up to the computer serial port I struggled to get the signal strength to 0. When running off batteries (I have an Arduino Pro mini connected to the headset's battery pack) I have had no issues with signal strength.
The issues were resolved by adding an extra GND connection from the Arduino and connecting to the body of the person being tested. I don't recommend this approach and running the headset completely off batteries is recommended.
This requires no wired connection to the computer, hence the RF link that has been implemented.

RF data link

I am using a cheap low-power RF transceiver to send the EEG packets to the computer. This makes the headset wireless and solves the signal strength problem that required the extra ground connection.

Receiving the data

The Processing Brain Grapher is a good starting point to check everything is working but it only works when the headset is in normal mode and sending the data via the serial port.
I am working on a Processing library that will work with the updated headset in full EEG mode, this giving access to the eSense meters, the EEG power band values, and the full EEG raw data. I'll be expanding this section as I make more progress with the libraries and visualisations.

0 comments: