You are viewing an older revision! See the latest version
OpenBCI and MyoWare Robot Control
Overview¶
This project demonstrates the use of the OpenBCI Ganglion, as well as a MyoWare muscle sensor, to control a small robotic car. Previous work using the myoware sensor can be seen here. The OpenBCI Ganglion is a board that will allows for the detection of brain activity. For this project, we will be detecting Alpha Waves and using them as a control input to the car. Much of this work is a derivative of previous efforts by EEG Hacker and OpenBCI.
Getting Started¶
This project will be using a slightly modified version of the OpenBCI GUI found here. This code is written and run with processing.
The hardware used in this project is:
- 2 x MBED LPC1768
- 1 x OpenBCI Ganglion
- 1 x Gold cup electrodes
- 1 x Conductive Paste
- 1 x Muscle Sensor with extension boards
- 2 x nRF24L01 RF transceiver
- 1 x H-Bridge breakout
- 1 x Battery Holder with Barrel Jack
- 1 x breadboard compatible barrel jack
- 2 x DC Motors
- 1 x Shadow Chassis
The Robot¶
The instructions for building the Shadow Chassis can be found here. Note that we did not use most of the parts listed in the guide.
Hardware Setup Vehicle Robot¶
The robot side of the hardware setup consists of a mbed device, nrf transceiver, h-bridge, both motors, and the robot vehicle. First setup the robot kit according to the shadow robot instructions mbed page. The h-bridge should be connected following the sparkfun magician robot instructions, and finally the connect the nRF transceiver according the mbed wiki instructions.
Below is a combination list of the used pins for the code demo provided.
MBED | NRF | H-BRIDGE | MOTORS |
---|---|---|---|
Vin (Battery +) | Vmot | ||
Gnd (Battery -) | Gnd | Gnd | Gnd |
Vout | SIG | ||
Vout | /STBY | ||
Pin 21 | PWMB | ||
Pin 22 | Bin 2 | ||
Pin 23 | Bin 1 | ||
Pin 24 | Ain 1 | ||
Pin 25 | Ain 2 | ||
Pin 26 | PWMA |
Hardware Setup Transmission¶
On the transmission side of the setup, the second mbed device is connected to the nRF according to the same instructions, and then to a computer system through the mini-usb cable. The usb device is setup as a serial connection to receive signal from the processing software, which processes the analog signals from the BCI board, which is connected via bluetooth.
MBED | MyoWare | Servo | Power Supply |
---|---|---|---|
VOUT | + | ||
GND | - | Black | GND |
AnalogIn | SIG | ||
Pin 22 | Yellow | ||
Red | +5v |
Connecting the BCI Nodes¶
Car Control¶
Alpha wave detection is the main control input for the car. When alpha wave production is detected, the computer sends a command to the MBED controlling the muscle sensor. This then sends a packet to the MBED controlling the car via a RF module. Getting sent an 'A' (alpha wave detected) increases the speed of the motors by 10%, while getting sent an 'S' (no alpha waves detected) decreases the speed of the motors by 10%. The direction of the car is determined by the myoware muscle sensor. We have split the range of the muscle sensor into three levels. Between 0 and .4 the MBED will send an 'L' (turn left), between .4 and .8 the MBED will send a 'C' (center up), and between .8 and 1.0 the MBED will send an 'R' (turn right). The MBED on board the car takes the extracts the sent information and then makes the necessary adjustments to the motors.
Ganglion¶
The ganglion we are using was loaded with an older version of firmware, which needed to be updated in order to program it. Although we did not end up changing any code on the device, the instructions to update the firmware and to program the Simblee can be found here.
All of the information for setting up the Ganglion for recording, as well as the proper configuration of the electrodes can be found here. This project makes use of the Ganglion to collect EEG signals. This is done via the software that can be found here. There is an issue with the Ganglion compatible software, where you can not modify the code and build it from source due to a library packaging issue. Until this is resolved, live alpha wave capture using the ganglion will not be possible. The way we worked around this, was to capture our EEG signals in the newest software and save it to a file in the OpenBCI format. We could then load the recorded session into the older software, which we edited to detect alpha waves and transmit this information to the MBED controlling the car. Alpha waves can be reliably produced in most humans simply by closing the eyes. In the future, there are many avenues to produce control signals just from the motion of the face. We plan on integrating these in future iterations of this work. There is an example of detecting these motions that is located at cfausn's repo on github.
Processing¶
This project is currently only compatible with Processing 2.2.1. The following edits need to be made in the program you downloaded earlier. Open all of the files into processing and you should be presented with a structure that looks like this:
We will be editing the OpenBCI_GUI tab as well as the EEG_Processing tab. First in the OpenBCI_GUI tab make the following changes:
Create a new serial port at line 49:
Next, initialize the serial port at line 172:
If you have multiple serial devices connected to your computer, you will need to adjust the value picked from the Serial.list() command.
Now in the EEG_Processing tab at line 130 add in the control signals to send to the robot:
Another possible change that will be required to the code is to adjust the detection parameters for Alpha Waves. They are normally found in the 7.5–12.5 Hz range on most people, but will take some experimentation to find the correct values. In the sketch the detection is based on the alpha wave peak being larger than the other signals produced by the brain. Adjusting the detection threshold value will make it harder or easier for Alpha Waves to be detected.
The detection parameters are located at line 47:
You should now be able to run the GUI by pressing the play button at the upper left hand corner.
When starting the program, you will get feedback about the serial port being initialized.
Correct setup will return a screen that looks similar to this:
You can now load the file that was previously recorded.
After starting the stream and playing the file, if you got a good recording of your brain producing alpha waves, you will get detection triggers from the recording. In this particular recording, I was trying to produce alternating 15 second periods of alpha wave generation and non-alpha wave generation.