Being an hacker, I’ve always been on a quest to reverse engineer everything around me, to understand inner workings and improve and add functionality to the things I see and use everyday. This includes my body.
I was fascinated by the recent developings in Brain Wave monitoring technology, so when my friend Francesca told me she needed to choose a final project for her last high-school year, I promptly offered to help her developing something interesting and innovative. I was going to build the hardware and let her write the software, but I ended up doing all the work for her! 🙂 So much fun! Well, after a bit of research I started building my own ModularEEG from scratch!
First things first, the bare PCBs etched with the laser printer method:
I wasn’t satisfied by the original choice of microcontroller for the ModEEG project, so I decided to leave the socket and the related parts unpopulated and connect a PIC breakout board I made. The board is a repurposed prototype of a CAN connected sensor based on a PIC18LF2680 that I had laying around. It was just a matter of connecting the power pins, serial TX and RX pins, calibration output pin, and analog input pins. As a good measure , I threw in a simple op-amp buffer on the analog lines, because the impedance from the analog board was too high for the specification of the ADC input of the PIC. I rewrited the code from scratch, implementing 2 standard protocols and a debug mode switchable via software from the serial port. Scroll down to the Firmware section to get the source code!
Since I didn’t know where to find electrodes for cheap, I first tried to design and make some active ones on my own based on Jarek’s design, but they didn’t work as well as I hoped:
Luckily, Francesca’s parents works in a hospital, so they introduced us to a very cool neurologist that explained us a bunch of things about brainwaves, and he even let me try his equipment. He donated us an elastic cap, some conductive gel, a bunch of electrodes and cables and an AgCl DRL clip. Thank you very much!!
As you can see in the picture, electrodes are simple metal “buttons” in a plastic case, with some tissue covering the flat contact surface. These electrodes must be soaked in a water+salt solution before use.
And here’s the final unit conveniently stored inside an old Videocassette case. That case is very useful because it allows easy opening, it’s widely available, and includes a transparent plastic sleeve so that you can put some nice artwork to explain connector function.
It’s just a matter of setting up the timer to fire an interrupt 255 times per second, grabbing the analog values from the ADC, packing them and sending everything to the PC via the serial port. As an added bonus, you can choose the protocol by sending the key ‘1’, ‘2’, or ‘3’ (0x31, 0x32, 0x33) to the serial port. To lower the amount of data to parse, my implementation of the P3 protocol sends only the 2 channels that I’m sampling, as allowed by the protocol specification. This caused some compatibility problems with BrainBay, but Chris Veigl promptly updated his source files!
The firmware’s source is released under the WTF public license, but it would be cool if you let me know if/how you use my code. Here it is: Download eeg1_pic18lf2680.zip (5KB)
While our initial goals were set high, we settled with a modest game due to time constraints and difficulties in processing the EEG data. Since the easiest signal to recognize between the vast amount of EEG data is the muscle movement, I placed the electrodes directly above the eyebrows and wrote some code to catch eye-blinks. Then I stareted to look around for a simple flash game that needed only a single key to play (I’m completly clueless about graphic programming), and found SoopaSprinta from Liam O’Donnell, a nice game with simple controls, that fit perfectly with my requirements. The game is loaded in a webbrowser control, where keypresses can be easily simulated with the SendKeys.Send(key); function. The fast clicking of the right arrow is costantly applied, so the character keeps moving on at a constant speed. A simple Schmitt trigger is implemented to detect a spike in the signal from the EEG and to send the “jump” comand to the flash game.
Again, the software’s source in C# is released under the WTF public license, but it would be cool if you let me know if/how you use my code. Get it here: Download EEGame1.zip (119KB)