Showing posts with label Soldering. Show all posts
Showing posts with label Soldering. Show all posts

Saturday, January 3, 2015

Soldering 16-chan OpenBCI

For a while now, I've been using the 8-channel version of OpenBCI.  You can see some of my EEG data here and some of my accelerometer data here.  Recently, I've been interested in getting more EEG channels, which means that I have turned my attention to the 16-channel version of OpenBCI.  The 16-channel version consists of a single 8-channel OpenBCI board with a additional "Daisy Module" to provide the additional 8-channels.  Today, I'm going to show a few pictures of the soldering necessary to assemble these two boards into a working unit.

OpenBCI Daisy Module (Left) with OpenBCI 32-Bit Board (Right) along
with their male and female headers (bottom).

I started the assembly process by reading through the assembly instructions (with its pictures) as provided on the OpenBCI website.  Those instructions were good, though I thought that some additional illustration would be helpful to others.  Hence, the reason for today's post.

Parts and Components:  As you can see in the picture above, the OpenBCI boards themselves are fully assembled.  But, like many Arduino-style kits, you do need to solder on some pin headers in order to connect the boards together.  To make this easy, I found that the OpenBCI kit comes with the correct male pin header for the Daisy module as well as the correct collection of female headers for the base OpenBCI board.  Great!

A Trick for Soldering Headers:  I started by looking to solder the female headers to the base OpenBCI board.  Based on my experience soldering headers to various Arduino kits, I know that soldering the female headers can be annoying because it is hard to hold the header in place while your two hands are already busy holding the soldering iron and the solder.  To overcome this problem, I used a trick that I saw a while ago where you use a solderless breadboard to hold your female headers vertically in place, hands-free.  It's pretty sweet trick.  In addition to a solderless breadboard, you need some cheap double-ended pins (see below left).  I got mine from Adafruit, but they are standard items available from a number of vendors.  I only ever this pins for this soldering trick, so I bought them once and they've lived in my toolbox ever since.

Use double-ended extra-long pin headers along with a solderless breadboard as a trick to hold
the female headers in place.  The long pins will go into the bread board.  The short stubs off
the top of the female header get soldered into the OpenBCI board.

As seen in the picture on the right, above, you stick the extra-long headers into the female header that you are looking to solder to the OpenBCI board.  Then, as shown in the picture below, left, you stick the extra-long headers into the solderless breadboard, which leaves the short pins (which are the solderable part of the female header) sticking up in the air.

Use the extra-long pin header to hold the female header onto the solderless breadboard.
Then flip the OpenBCI board upside-down and place the OpenBCI board onto the
solder pins of the female header.  You're ready to solder those pins!

Soldering the Female Headers:  Now, you can place the OpenBCI board over those solder pins (see the right picture, above).  Note that the OpenBCI board has been flipped over so that it is face-down.  It's important that you solder the header onto the correct side of the board!  Once you have confirmed that everything is sitting correctly, you can start soldering.

Soldering each one of the pins in this header.
Then repeat for all of the other headers.

After repeating this process for all of the other female headers, the base OpenBCI board is fully prepared.

The base OpenBCI 32-bit board is finished.

Preparing the Daisy Module:  With the base OpenBCI board finished, I turned to the Daisy module.  Here, you start but using your pliers to snap apart the single, long, male pin header into the smaller pieces needed to fit into the different spots of the Daisy module.

Prepare the male pin headers for the Daisy board.  Snap the long pin header
into the correct number of pieces.

Use the Base Board as Your Fixture:  Then, as before, it can be tricky to solder these headers when your hands are full with the soldering iron and solder.  The tick this time, is to use the base OpenBCI board itself as your fixture.  This is a classic trick for soldering Arduino shields.  As shown in the picture below, left, insert the male pin headers into the base board's female headers.  Do this for all of the male headers that you will solder to the Daisy module.   Once they're in place, you can simply place the Daisy module onto the pins (see below, right) and everything will be nicely aligned and ready to solder.
(Left) Insert the male pin headers into the female headers that were just soldered into
the base OpenBCI board.  This holds them in the right place.  Then, place the Daisy board
on top so that you can solder the pins into the Daisy board.

Solder the Daisy Module:  With the pins all in place, solder the headers into place.  With everything so nicely held, this part is fast!  For me, it went so quickly that I forgot to solder one of the headers into place.  Ooops!  So, I went back and soldered the remaining pins.  No problem.

Soldering the pins to the Daisy board.  Be sure to solder all of the pins on all
of the new headers (I forgot one header when I did it)

Ready for EEG:  With the last soldering complete, the two boards are mated and I'm ready to collect 16-channels of EEG.  This is gonna be fun!

I'm finished!

Follow-Up:  I measured the power draw of the system here.

Thursday, May 15, 2014

Arduino Control of a Hex Bug

Based on my previous success with visual entrainment, I'm moving forward with my plans on making a brain-computer interface (BCI) using my blinky lights.  To really kick this project into high gear, though, I need a good goal -- I need something that would be really fun to control with my brain.  Luckily, my OpenBCI friend Conor, found these cool remote-controlled 6-legged robots that can walk around a fire a little gun.  Bingo!  As you can see below, today's post shows how to hack the robot's remote to make it controllable from an Arduino.  Once it is controllable from an Arduino, it's only one more step until it's controllable from my brain!



The Hex Bug Battle Spider:  The remote-controlled robot that Conor found is a Hex Bug Battle Spider.  They are available in two colors and you can have them do battle.  Hex Bug makes smaller and cheaper versions of this robot, but I believe that only the Battle Spider has the ability to do battle.  I'm looking forward to facing off cerebro-a-cerebro with Conor, so I'm sticking with the Battle Spider.

Hex Bug Battle Spider - My Hacking Target for Today

IR Remote Control:  The Hex Bug is commanded using an infrared (IR) remote-control.  It is the remote control that I will hack so that the Hex Bug can be commanded from an Arduino.  As you can see in the picture below, I was so anxious to hack the remote, that I never got a picture of it while it was still in one piece...I just couldn't wait to smell the solder!  Regardless, as you can see, the remote is simply a bunch of plastic pieces, a couple of coin cell batteries (not shown), and a printed circuit board (PCB).

The Hex Bug Infrared Remote Control (in Pieces)

Thank You, Test Points!  Flipping over the PCB, I was very pleased to see that this board has test points for everything.  Oh, the joy!  Because of these test points, it is much easier to probe the board with my multimeter or with an oscilloscope to figure out how this thing works.  The test points also makes it much easier to attach wires to control this thing from the outside (like from my Arduino).  It turns out that there is a test point for each of the four user buttons on this board.  The relevant test points are shown in the picture below.  These test points will be the focus of my work.

All those test points enable easy hacking.  The test points
with the arrows are for the user buttons.

How the Buttons Work:  After a bit of probing of these test points, I learned that the buttons are used like most buttons in small devices like this (see "Button" demo by the Arduino folks for more info).  The buttons on this remote control are simply switches that are normally open-circuit.  When you press a button, the switch becomes closed-circuit.  The "low" side of each button is tied to ground.  The "high" side is connected to 3.3V via a pull-up resistor (probably inside the microcontroller).  The microcontroller is continually sensing the voltage on the high side of the switch.  When the button is not pressed, no current flows through it nor through the pull-up resistor, so the voltage seen by the micro is high.  When the button is pressed, current flows through the button, which drops the voltage seen by the micro.  As a result, the micro knows that the button was pressed.  Easy!

Hacking Approach:  Based on this discussion, it is clear that the microcontroller on the remote control knows nothing about the buttons...it only knows about the voltage being controlled by the buttons.  When one of those lines goes from high to low, the microcontroller thinks that a button has been pressed.  My hacking approach, therefore, is to wire the Arduino to the remote control so that the Arduino can pull the lines low for me.  This requires me to attach a wire to the high side of each button and to a attach a wire to the remote control's ground.  Normally, I'll keep the Arduino's pins in a high-impedance state so that no current flows.  When I want it to "press" a button for me, I'll command the relevant pin to go into a low-impedance state to allow it to conduct current to ground.  Electrically, this will mimic the behavior of the buttons themselves.  No extra components will be necessary!

Connecting Ground:  OK, we're mostly done talking.  Now let's start soldering.  First, I connected a wire to the remote's ground.  After looking around the PCB, I decided that I liked the solder that was on the low side of the "fire" button.  So, as you can see below, I sneaked a black wire into that location and soldered it in place.

A blurry picture showing where I soldered a black wire to
attach to the remote control's ground.

Connecting Each Button:  Then, I flipped the board over and soldered a colored wire to each button's test point.

All of my wires are now soldered to the test points.

Snip a Pass-Through for the Wires:  While it is not necessary to do this, I like the idea of re-assembling the remote so that I can use it with my fingers (as if it were not modified) or so that I can use it with the Arduino.  To enable the reassembly of the remote, one simply has to cut a hole in the plastic housing to get the wires out.  I used a "nibbler" tool to cut a small hole.  As you can see below, it worked really well!

For extra credit, I used a nibbler to cut a hole in the plastic housing so that
I can get the wires out, even after I fully re-assemble the remote control.

Attach a Pin Header:  To ease the connection of these 5 wires to the Arduino, I decided to solder the free ends of the wires to a piece of basic pin header.  With these pins, I can easily insert the five wires as a single unit into the sockets on the Arduino board.

To make it easier to connect the wires to an Arduino, I attach the wires to
a basic pin header.

The Hacked Remote:  The picture below shows the hacked remote after I reassembled it.  I tested it by pressing the buttons with my fingers and the robot moved.  So far, so good!

My hacked remote control is now re-assembled and ready for testing.

Software:  If I'm going to command this robot from my Arduino, the Arduino needs software.  So, I plugged in my remote to the Arduino (because the Arduino is really flexible, I used the Analog Input pins even though these signals are neither Analog nor are they Inputs...but that doesn't matter, you can use the Analog pins as Digital ins and outs, too) and then began coding.  My code is available on my GitHub as "TestHexBugController".  This code tells the Arduino to listen to commands coming over Serial from the PC.  I assign one ke on the PC's keyboard to each of the Hex Bug's four functions: "forward", "turn left", "turn right", and "fire".  When the Arduino receives one of these commands, it toggles the relevant pin to pull it LOW for 500 msec.  That's all it takes!

Using the hacked remote so that I can use an Arduino to control my Hex Bug via
commands entered from the PC.

Testing it Out:  As you can see in the video at the top of this post, this setup works pretty well for controlling the Hex Bug.  I can make it walk anywhere and shoot its gun on command.  It's pretty fun.  If I cared to, I could no script a whole series of maneuvers.  If I attached a pen to the Hex Bug, maybe I could make it walk around on a big piece of paper so that it would draw out a funny picture.  That could be fun.  Or, I could combine it with some computer vision on my PC and have it chase my cat around.  That would definitely be fun.  Sadly, I don't know anything about computer vision.

Brain Control:  Really, though, my next step is to control this with my brain.  So, I'll attach my OpenBCI shield to this same Arduino and I'll have the Arduino pipe my EEG signal to the PC.  On the PC, I'll process the EEG signal and, if it detects the right brainwave signatures, I'll have the PC send robot commands back to the Arduino.  The Arduino will then convey those commands to the robot via the IR remote.  All of the hardware pieces are in place...now it's time to put it all together!

Follow-Up:  I finally did put all the pieces together.  I can now control the Hex Bug with my brain waves!

Wednesday, May 7, 2014

Measuring Video Blink Rate with an Arduino

In my previous post, I used blinking videos on my computer to entrain my brain waves.  A key question, though, was whether my computer could play those blinking videos steadily.  If the blinking isn't steady, it won't entrain brainwaves that are easily detected.  So, in this new post, I show how I hacked a photocell and my Arduino to measure the blink rate that my computer is actually producing.  It's a pretty simple (and cheap!) setup and, as you'll see below, its data explains some of the important findings in my EEG data!

Measuring the Blink Rate From the Movies Played Back by my Computer

Using a Photocell:  My approach to measuring the video blink rate is to quickly and continuously measure the light produced by my computer screen.  I chose to use a photocell, mostly because I had one that came with my very first Arduino.  To learn how to use a photocell, I followed the tutorial at Adafruit.  It explains what a photocell is and it explains exactly how to hook it up to an Arduino.  The key is that you connect a photocell and a 10K resistor in series.  Together, they form a voltage divider.  Then, you connect one end to +5V and the other end to ground.  In the middle, at the junction between the photocell and the 10K resistor, you connect that point to the Arduino's analog input pin.  Pretty easy!

Wiring It Up:  To connect all of the bits together, I needed to solder a few things.  First, I gathered my components -- the photocell, some wire, and some shrink tube (to keep the soldered wires from shorting to each other).

The Components: A Super-Cheap Photocell, some Wire,
and some Shrink Tube.  The 10K resistor is not shown.

Then, I soldered the wires to the legs of the photocell and insulated them with the shink tube.  The photo below shows the components after this assembly.  Looks decent enough.

Fully Assembled.  This is the first version that I tried.  Notice that the back
and sides of the photocell are exposed.  This turned out to be bad.

Unfortunately, when I hooked it up to my Arduino, I found that I was not seeing any change in the light level from my computer screen.  After some playing around, I found that the photocell is sensitive to light from the back and sides, in addition to being sensitive to light from the front.  So, as seen in the photo below, I added another layer of shrink tube to block out the light entering from the back and sides.

Modified Assembly.  I added more shrink tube to wrap around the sides
back of the photocell.  You have to keep out that light!

Mounting Everything:  Once I had my photocell on those long(ish) lead wires, I connected it to the Arduino as discussed on the Adafruit site.  I then needed a way to hold the photocell close to the computer screen so that I could measure its blink rate.  As shown in the photo below, I found that my adjustable soldering fixture (sometimes called a "3rd Hand" fixture) works really well.  It works best if you position the photocell to be VERY close to the computer screen.

I held the photocell to the computer screen using a"3rd Hand" soldering fixture.
To record the photocell signal, I used one of the Analog Inputs available on the
Arduino that is the host for m OpenBCI shield.

Position the photocell to be VERY close to the screen.

Arduino Software:  If I'm going to use my Arduino to read the photocell, I need to some software for the Arduino.  My first step was to use the built-in Arduino example called "AnalogInOutSerial".  I then extended this program to report the actual resistance of the photocell under different lighting conditions ("ReadPhotocellResistance").  While either of these programs works fine to read the photocell, neither is clocked to read the values a steady pace.  If the sampling isn't steady, there's no way to know if the video blinking istelf is steady.  To fix this, you need to setup an Arduino timer.  Or, you could...

Integrate with OpenBCI:  The OpenBCI shield generates data packets at a very precise rate (I usually configure mine to sample at 250 Hz).  It could act as the clock to drive the Arduino to sample the photocell steadily.  So, I modified the OpenBCI Arduino sketch to read one of the analog input pins every time that it receives data from the OpenBCI shield.  It then appends this extra data value to the OpenBCI data packet and sends it to the PC.  Finally, I modified my OpenBCI GUI to receive the extra data and to include it in its log file.

Results:  I used this system to record the blinking produced by the blinking movies from my previous post.  Each movie was about 20 seconds long and each movie blinked at a different rate.  The digitized Photocell values are shown in the figure below as raw counts from the Arduino.  Clearly, this graph is a bit too zoomed out to see much of interest (though you can see the non-steady amplitude when at the fastest speed on the right).  We need to zoom in to see more detail...

Sample values recorded from the photocell by the Arduino's analog input pin. I played
my 10 whole-screen-blinking movies.  Each movie is about 20 seconds long.  Each movie
has a different blink rate -- from a 1 Hz white-to-white blink rate up to a 10 Hz w-w rate.

Zooming-In:  Excerpts from three of the movies are shown below.  In these plots, you can see that the light pulses recorded during the  3 Hz and 10 Hz movies look to be steadily paced, whereas the pulses in the 7 Hz movie looks much more irregular.  Based on this qualitative view, I'd say that the irregularity of the 7Hz movie might cause complications when used for EEG experiments.

Zoomed-In waveforms recorded from the photocell during my blinking movies.  Excerpts at three
different blink rates are shown.  The red and blue dots show features that I used to quantify each
movie's blink rate.  Note that the time scale is different for each of the movies so that you always
see 4 periods, despite their increasing speed.

Measuring the Blink Rate:  To better assess the steadiness of each movie, I setup a routine to quantify the blink rate on a blink-by-blink basis.  I did this by, first, computing the mean sensor value for the whole recording.  This is my threshold for deciding whether the screen is "white" or "black".  This threshold value is shown by the horizontal black line in the excerpts above.  Then, I detected when the signal crossed this threshold.  Each threshold crossing is shown as a blue dot in the figures above.  To compute the blink rate, I compute the difference between the dots.  The "white-to-white" blink rate is the difference between the red dots.  Alternatively, the rate at which the screen merely changed (either from white-to-black or black-to-white), I measured the difference between the blue dots.

Blink Rate Throughout the Test:  The plot below shows the results of quantifying the blink rate throughout the test.  In red, the plot shows the white-to-white blink rate.  In blue, I show the blink rate from both transitions.  As expected, the blink rate counting both transitions is twice as fast as the blink rate when counting just from white-to-white.

Blink Rate Measured for my 10 Movies.  The measured blink rate generally follows the expected blink
rate, though the measured blink rate exhibits unsteadiness at the faster speeds. The blink rate when
counting both transitions (whit-to-black and black-to-white) is especially unsteady at the higher speeds.

Unsteadiness:  As can be seen in the plot above, the blink rate is pretty steady for the first four movies (ie, speeds of 1-4 Hz W-W).  For the 5th movie (5 Hz W-W), the plot above starts to look messier, especially the blue line.  This means that the system is not playing back the blinking movie smoothly.  As we get into the faster movies (6-9) Hz, the blue line gets extremely messy.  Clearly, the system is unable to keep a steady pace of white-to-black and black-to-white transitions (the blue line), though the white-to-white period (the red line) isn't too as bad.  Funnily, at 10 Hz, note that the white-to-white blink rate gets very stable again.  It seems that at 10 Hz, the individual movie frames must be well-aligned with the natural update rate of the video system on my computer.

Relationship to EEG Data:  The whole purpose of this investigation was to see if my EEG results from my previous post (copied again below, for convenience) were reflecting properties of my brain, or if they were reflecting artifacts from imperfections in my computer's movie playback.  My main question with my EEG data is why I exhibited no video-entrained EEG signals above 10 Hz.  Well, looking at the graph of the computer's blink rate (above), we see that the video blink rate becomes extremely unstable for any frequency above 10 Hz.  My computer, in other words, was unable to generate steady visual stimulation above 10 Hz.  Without stable stimulation, my brain had nothing to entrain with.  Therefore, these limitations in my video system mean that I cannot declare either way whether my brain can entrain with visual stimuli at speeds greater than 10 Hz.  With a more stable video system, maybe I could entrain with the faster blinks.

EEG data shown in my previous post.  This is the signal recorded from the back of my head (reference
on left ear) when staring at my blinking movies.  The signals marked by the blue arrows seem to indicate
periods when my brain entrained with the video on every transition of white-to-black and black-to-white.
The periods marked by the red arrows seem to indicate periods when my brain entrained on just the
white-to-white blink rate.

Next Steps:  With this system, I have proven that I can assess the steadiness of my video playback system.  Steady playback is critical to inducing visual entrainment of brainwaves.  So, as I move forward with trying to create a BCI based on visual entrainment, I can use this synchronized photocell recording to confirm that the video stimulation is sufficient to (hopefully) induce EEG responses.  Let the development of the visual BCI begin!

Saturday, January 18, 2014

EEG Electrode Adapter - Version 2

As many people are aware, many commercially-available EEG electrodes use an unusual connector called a "touch-proof" connector.  If your EEG system does not use these connectors, you need to either replace the connectors on the electrodes, or you need to make an adapter.  While it is a sensible choice to cut up your electrodes, I prefer to make an adapter.  My previous version of such an adapter worked really well, but it was a bit fragile.  So, I decided to try again.  I also decided to work with a friend of mine who's a little smarter about these kinds of things.  Here's what we came up with.

My Revised EEG Electrode Adapter ("V2") attached to an OpenBCI Board

Problems with the Previous Version:  The picture below shows my previous version of the adapter.  The good part was that the adapter was really small.  I liked that.  The bad part of this adapter (in addition to the fact that I never finished all of the connections) was that it was quite fragile. Specifically, the soldering of the wire to the female connector had no strain relief, which meant that mating the connector always threatened to break the wiring.  Another problem was that I was always confusing which electrode I had plugged into which input on the OpenBCI board.  I really needed to remake the adapter so that it was easier to see which were the "special" connections (SRB, Bias, and 8P) versus all of the "normal" connections (1N-8N).  These are the deficiencies that I focused on in this revision.

My First Attempt at an EEG Electrode Adapter ("V1")
Revised Approach:  With this iteration, my friend and I decided that it would be best if the female touch-proof connectors were mounted to some sort of rigid frame instead of merely being attached to the ends of the wires.  This would give the strain relief that we needed when mating and de-mating the connectors.  To address my other issue -- getting the connections confused -- I decided to use color-coded connectors, instead of just the black connectors in my first build.  Easy.  Ok, let's go!

Parts:  The parts are all the same as in the first build.  The female touch proof connectors are P/N 36145 from Plastics One.  The ribbon cable is just a set of female-female jumper wires from Adafruit (P/N 266).  This time, we also used a piece of scrap plastic channel that we had lying around, probably originally from McMaster-Carr.  And, as you'll see, I used a thin scrap piece of plastic sheet and a wide piece of shink tube, both from our generally pile of "goodies for a future project".  None of these pieces (except for the female touch-proof connectors) are particularly critical, so use what you have.

Assembly:  My buddy who came up with the idea of using the plastic U-channel as a mounting plate did all of the of the assembly.  He started with drilling a bunch of holes in the U-channel into which he pressed in the female connectors.

Touch-Proof Connectors Mated to the U-Channel -- For Strength!

He then took the purchased wires, pulled off (as a group) the number of wires that we needed and cut the existing connectors off one end.

Inexpensive Jumper Wires Used for My Wire Bundle

To keep the individual wires from splitting themselves off the ribbon, he reinforced the ribbon with a flat piece of plastic and a big piece of shrink tube.  Here's him preparing the items.  The red thing is the big shrink tube and the yellow-ish thing is the scrap bit of flat plastic that he'll use for the reinforcement.


Preparing the Shrink Tube (Red) and Scrap Plastic (Yellow)
to Reinforce the Wire Bundle

With the wire bundle prepared, he soldered the individual wires to the back of the touch proof connectors.  He used some normal size shrink tube to protect the individual solder joints on the back of the connectors.  Very nice.

Connecting the Individual Wires to the Back of the
Touch-Proof Connectors.

And that's all there is to it.  A picture of the completed unit is below.  You can also see it attached to an OpenBCI board at the top.  In the picture below, you can see how reinforcing the ribbon cable was an important feature for keeping the wire bundle from falling apart.

The Finished Adapter.

Pin-Out:  For anyone wondering why I used the unusual color scheme for the connectors, the idea is to clearly indicate that some of the electrodes have different functions.  So, if you use this adapter to connect to the OpenBCI V2 board as shown in the zoom'd picture below, or like the one at the top of this post, the order of the connections is this, from left to right:

   Red: Bias  (aka. driven ground)
   Blue: 8N  (the regular input for channel 8)
   Red: 8P  (the reference input for channel 8, if selected in software)
   Blue: 
       7N  (the regular input for channel 7)
       ...
       1N  (the regular input for channel 1)
   Red: SRB2  (the reference input for all channels)

Further Revisions:  After working with this revised piece for a bit, I found that there is still room for improvement.  For example, in connecting the adapter to the OpenBCI board, it is important to connect the wires in the right order.  The right order is shown below.  At first, I thought it was a good idea that I kept the individual female pin connectors on each wire of the adapter.  I thought that I'd like the freedom and fllexibility that this might provide.  I was wrong.  I should have swapped out the individual female pin connectors for a ganged female connector that would have kept them all in the right order all of the time.  I was wrong.  (So, to the EEG hacker that I'm handing this adapter off to, sorry for the annoyance!).

The Correct Order for the Individual Wires.

So that's the story of the hacking of this electrode adapter.  The real solution, of course, would be to have the connectors on the electrodes and on the EEG system (OpenBCI, in my case) be the same.   The easiest thing would be to put female touch proof connectors on the OpenBCI board.  But, the PCB-mount version are almost $2/each, even in quantity!  This is completely incompatible with the price of the OpenBCI board.  So, the next option would be to buy electrodes with a connector system that we could afford.  That would be a really nice solution to this problem of making kludge-y adapters.

Tuesday, November 12, 2013

Making an EEG Electrode Adapter

My earlier post on making my own EEG electrodes was surprisingly popular.  Thanks, all!  But, for some folks, it might just be easier to purchase EEG electrodes off the shelf.  If you buy your electrodes, they're likely to come with connectors on the ends.  In order to use these electrodes with an OpenBCI board, you'll need to either cut the connectors off, or you'll need to make an adapter cable.  Since I tend to play with a variety of electrodes (both EEG and ECG) and since many types of electrodes use this same connector, I thought that it would be good to make an adapter.  This post is about how I made my adapter cable.  Here's what it looks like when I was done.



Parts

To make the adapter cable, you need the connectors that mate to the EEG electrode, you need some wires, and you need some connectors that mate to the OpenBCI board.

The OpenBCI board simply uses pin headers with a 0.1" spacing.  Therefore, for "connectors", you can use any of the inexpensive jumper wires that are used throughout the hobby world for connecting to Arduino.  For this adapter cable, you need female pin headers.  Adafruit sells a fine pack of 40 female/female jumper wires (P/N 266) for $6.95.  The 40 wires come with the connectors already attached.  The wires also come attached to each other as a ribbon cable, which is very convenient for keeping the cables in order.

Female/Female Jumper Wires from Adafruit
For the EEG electrodes, they usually use "touchproof" connectors.  This are simple singe-conductor connectors where the metal part is completely shrouded in plastic.  They are fairly standardized, though the diameter of the connection can vary between 1mm and 2mm.  All of my electrodes are 1.5mm.  The jacks that mate to these electrodes can be purchased from Plastics One.  Specially, I chose to buy the panel mount, front-loaded, threaded connectors (P/N 36145) shown in the pictures below.  When bought in small numbers, they're $3.14 each.  That's pricey!

Jacks for Touchproof Connectors.  From Plastics One.
Assembly

The OpenBCI board has 11 connections that I might want to use.  So, I took the ribbon of 40 jumper wires and peeled off a single strip that contained 11 wires.  I then cut it in half to that one end had the female pin headers and the other end was just wire.


Then, I peeled apart the ends of the wire and stripped the ends.  As I prepared to solder on the touchproof jack, I slipped a piece of shrink tube over the end of the wire so that I could make it look nice when I was done.  I'm proud of myself for remembering to do the shrink tube.  I nearly always forget.  Not this time!

Preparing to solder the first jack.

After I soldered it on, I pulled the shrink tube up over the joint, applied some heat, and got a nice looking connection.

First jack is attached.  Nice use of shrink tube!
I then repeated the process for all the other wires that I was going to use.  Here's a picture of me soldering on the second jack.

Preparing to solder the second jack.
Completion

For my immediate testing, I did not need all 11 connections...I only needed four.  So, I only soldered on four jacks.  You can see my "completed" adapter cable assembly below.

My adapter cable with 4 connections.  I'll add the others when I need them.
Note that I added a piece of electrical tape around the ribbon cable to help keep it together.  I had overly separated one of the individual wires and it was threatening to come loose.  I little electrical tape saved the day!  And it makes it look fancy.

Using It

As you can tell by the photo at the top of this post, the adapter cable works great for interfacing OpenBCI to off-the-shelf electrodes.  I've used it with my EEG electrodes for follow-on measurements of my Mu-waves and with my ECG electrodes for checking my heart signals.  It's a great adapter cable to have in my EEG Hacker toolbox!


Tuesday, November 5, 2013

Homemade Passive Electrodes

After the challenge of getting oneself some decent EEG electronics, the next hardest part is getting some decent EEG electrodes.  Sure, there are lots out there that can be bought, but some folks have no interest in paying $8-$20 per electrode (plus shipping) because they know that they need to buy 6-10 of these electrodes and, well, that becomes a lot of money.  So, I decided to try to build my own homemade EEG electrodes.  Here's my story...(and for you impatient folks...yes, there's a fairly happy ending)

Wearing my homemade passive EEG electrodes.
(Beware of cheap cameras and flourescent lights)

The Idea: Use Cheap Bits from the Hardware Drawer

When I look at passive EEG electrodes, I just see a piece of flat metal with a wire attached.  Sure, I see the use of fancy metals (gold, silver / silver-chloride), but is that really necessary?  For EEG research or EEG medicine, the quality and repeatability provided by the fancy metals is necessary.  For EEG Hacking?  I'm not so sure.  So, if an electrode is just a piece of flat metal with a wire attached, it seems like I should be able to build one myself.

I started by searching through my hardware drawer to find a suitable piece of metal that is small and flat.  I found some lock washers with a solder tab (see picture below-left).  It is a very basic and inexpensive component.  I'm pretty sure that mine are from Mouser and cost $0.24 each.  You can probably get them cheaper.



I then grabbed a piece of wire, stripped the end, and inserted it into the tab on the washer.  Looks like it'll do nicely (see picture above-right).  To soldered the wire to washer, I simply placed it in my plastic-gripped vice and applied heat and solder (pics below).  If you don't have a vice, a traditional "3rd hand" soldering fixture would have worked fine, too.  This is not fancy work that we're doing here.


Once the wire was soldered to the washer, I realized that I should have added a piece of shrink tube over the wire to cover the solder joint.  But, once it was soldered together, it was too late to add the shrink tube (the other end of my wire already had a connector on it).  Dang!  When I made a second electrode, I remembered to add the shrink tube on that one.  As you can see below, the black shrink tube makes the second electrode look much nicer than the first one.

My First and Second Homemade Passive Electrodes.  On the second one, I remembered to add a piece of shrink tube to cover the solder joint.  It looks much better.
With the working end of the electrode complete, I could consider the other end of the wire...the end where normally on would add a connector for plugging into the EEG electronics.  Since I stole my wire from an old ECG lead wire, I have the "touchproof" connectors on the end of my electrodes.  But, you don't need anything that fancy if you want to spend less money.

The least expensive approach for "connectors" would be to solder on a male or female pin header, which are only about $0.04 per connection.  This kind of connection is perfect for connecting to OpenBCI, which is built around traditional 0.1" spaced pin headers.  So, if you put the mating gender of pin header on your homemade electrodes, they could plug right into the OpenBCI board.  Great!  Alternatively, if you use OpenEEG, you will want to terminate your electrode's wire with a 3.5 mm stereo phono plug.   That is what the OpenEEG is built around.  These pieces about $0.50 each.

So, overall, I estimate that cost of each one of these electrodes is: $0.24 for the washer, about $0.36 for a meter of stranded wire (it's more flexible than solid wire), and $0.50 for a 3.5mm connector.  That's $1.10 in parts, which is a nice reduction compared to commercially available electrodes linked at the top of this post.

But do my homemade electrodes work?

Homemade Electrodes for ECG

As discussed in my previous post, I always like to start my testing by doing ECG measurements.  Because the heart signals are so strong, it is an easy way to confirm that your EEG system (and EEG electrodes) are working to some degree.  So, I got out my tube of Ten20 conductive paste and stuck my electrode to my wrist.  I attached one electrode to my left wrist and the other electrode to my right wrist.

Attaching my homemade electrodes to my wrists to measure my ECG.
The shiny stuff on my skin is Ten20 conductive paste

 How well did they stick?  Well, not nearly as well as the self-adhesive disposable ECG electrodes.  But, the surface area on those sticky ECG electrodes is HUGE, so of course my little electrodes won't stick as well.  Given how small my electrodes were, though, I think that they adhered adequately well.  I think that the big hole in the middle of the washer is not helpful.  If it were solid, I think that these electrodes would stick better.  I'll remember that when I go to make my next set of homemade electrodes.

Once I got the electrodes attached to my wrists, I connected plugged them into my OpenBCI board and had the Arduino pipe the data to my computer, as usual.  Example ECG data from these electrodes is shown below.  I'm showing 6 heart beats.  As you can see, the sharp R-waves and the broad T-waves are both very clear.  The amplitude of the ECG is similar to what I showed in my post yesterday when I used real ECG electrodes.  So, while my signal trace does look a bit noisier than yesterday, I'd say that this is a successful test!

My ECG As Recorded through OpenBCI Using my Homemade Electrodes

Homemade Electrodes for EEG

Since I was successful with the ECG, I made the next step and used my homemade electrodes to acquire some EEG signals.  I am still pretty fixated on my Mu waves, so I decided to use my electrodes to see if I could pick up my Mu waves.

Following a simplified version of my previous procedure, I put one electrode near the top of my head near Cz and one the left side of my head near C3.  As you can see in the photo, it is very tricky to accurately place electrodes on one's own head.  In retrospect, it looks like the one on the top of my head was a bit too far forward for Cz and the one on the side of my head was a bit too far back and a bit too low for C3.  Regardless, they should be good enough to record *something*, so let's see what I got.


Placing my homemade electrodes near
Cz (top of head) and near C3 (side of head).

Using my OpenBCI electronics, I started recording data from my brain.  I spent some time with my eyes closed to generate Alpha waves (Posterior Dominant Rhythm), I spent some time with my eyes open and my right arm and hand relaxed (to hopefully generate Mu waves), and I spent some time with my eyes open and my right hand clenching and un-clenching.  The results are plotted below as a spectrogram.  Unfortunately, it is not very clear where the boundaries were between these different activities, so it is not clear what we *should* be seeing.  We do clearly see the Alpha waves caused by my eyes being closed.  In the middle of the plot, we might also see some Mu waves, but they are very weak.  I would say that these results are fine for Alpha and bad for Mu.


To try to get better results, I moved the homemade electrode that was on the side of my head.  I moved it a little higher to be closer to where C3 is supposed to be.  Then, I repeated my recordings.  This time, I pressed a button on my computer to mark the boundary between each activities to make my post-test analysis easier.  It turns out that the simple act of pressing the button caused my EEG wires to jiggle, which shows up as artifacts within the data.  It makes it clear when I shifted my activity.  See the results below.


As before, the Alpha waves are quite clear.  This time, though, I do think that I see Mu waves during those periods when my eyes were open and my hand and arm were relaxed.  Then, when I moved my hand, I think that I see that the Mu waves go away.  That's exactly what should happen!  At the end, when I relax again, I think that it is interesting that it takes a while for my Mu waves to come back.  Clearly, I am not very good at relaxing.  That's not much of a surprise to me.  I can be quite excitable...especially when I'm EEG HACKING!

Homemade Electrodes Seem to be Good!

So, with this second test, I'm quite pleased with my homemade electrodes.  The signals that I recorded were pretty good.  There was a lot of 60 Hz noise (not shown in these graphs) but that could be due to me not using the traditional 3rd electrode connection (variously named the "bias" or "driven ground" or "driven right leg") for these recordings.  I also felt that these electrodes did not stick to my head as securely as the gold electrodes that I used previously.  I think that the stickiness can be improved by using a piece of metal with more surface area...maybe a regular flat washer instead of the skinny lock washer.  Still, for about a dollar per electrode, I think that the results are pretty darned good.  I'm pleased.

How about you...have you made your own electrodes before?  How did you do it?  Did they work?


Follow-Up: More graphs and discussion of the data is in this post
Follow-Up: Want to see my data from this experiment?  Check out my github!