DIY Neuroscience With Spiker:bit

by bekathwia in Circuits > Sensors

631 Views, 9 Favorites, 0 Comments

DIY Neuroscience With Spiker:bit

Getting Started with Spiker:bit

Meet Spiker:bit, the new micro:bit-compatible accessory for building your own projects that interface directly with the electrical signals from your body. Spiker:bit provides three basic ways to measure: electromyography (EMG), electrocardiography (ECG or EKG), and electroencephalography (EEG). I’ve been a Backyard Brains fan since I met Greg Gage at Maker Faire Detroit in 2011!

Supplies

To follow along, you will need:

  1. micro:bit board with USB cable
  2. Spiker:bit board and accessories
  3. 2x AA batteries
  4. Computer or mobile device capable of running the MakeCode website

Setting Up Spiker:bit

_com.apple.Pasteboard.LKewBi.png
_com.apple.Pasteboard.JzhAQt.png
_com.apple.Pasteboard.5edAFk.png

The micro:bit slides into the slot on the Spiker:bit, and the cable plugs into the port on the side of the board labeled “HUMAN.” You’ll also need two AA batteries, which go in the holder on the back side.

Next, you’ll need to place some electrodes on your body to read its electrical signals. We’ll start with the forearm muscle and stick the electrodes on so we can detect contractions with EMG or electromyography. Two electrodes go along the length of the muscle, and a third goes on the back of the hand. Clip the black ground cable to the electrode on the hand, and the two red cables to the other two electrodes; it doesn’t matter which is which. Don’t worry, the signals traveling through these wires are extremely small, and there’s no chance of electrical shock, I promise. That’s a lot of what the Spiker:bit board does, actually: amplify those faint signals so we can use them as sensor inputs for our projects.

The electrodes have a conductive gel inside that presses up against your skin as well as the metal bit on the outside. And remember that your body is largely made up of salt water, which is an excellent electrical conductor. So the signals from your nerves that are firing your muscles can be picked up through this method, which is called a BCI or Brain Computer Interface. If you’ve ever been in the hospital or had a doctor monitor your heart, you’ve probably worn this type of electrode before.

Once you’ve got your electrodes on and your board plugged in, you’re ready to read the EMG signal using micro:bit’s MakeCode website. You’ll need to install the Spiker:bit extension. Grab the file from Backyard Brains, click Import File on the extensions page, and choose the file you just downloaded– then you’ll see the Spiker:bit code blocks available with all your others.

Coding for EMG

_com.apple.Pasteboard.U9DG5f.png
PNG image.png
_com.apple.Pasteboard.4JbknC.png

To make the most basic program that displays the EMG data, drag the block labeled ‘start muscle recording’ into the onstart instructions, and drag blocks to print the muscle power signal in the forever loop.

Click the Show Data button, and a live graph will appear, plotting your EMG data. Try squeezing your hand into a fist and then releasing. Notice what the reading does.

You can add a little logic to your program to show a specific graphic depending on whether the muscle is firing or not. Drag out an ‘if then’ block and add a comparator to it. Drag a ‘muscle power signal’ block to either side of the comparator, and set the other side to 50, which is a good starting threshold. Set the comparator to trigger when the muscle power signal is greater than 50. Add one ‘show icon’ block to each part of the ‘if then’ statement, each with a different symbol. Then transfer the code to your micro:bit. Now you’ll have a way to display the reading even when you disconnect the USB cable from the computer.

Neuroprosthetic Hand Project

_com.apple.Pasteboard.QqRVWx.png
_com.apple.Pasteboard.3MegDB.png
PNG image.png
_com.apple.Pasteboard.OUWzcI.png
_com.apple.Pasteboard.Q9bTjS.png
PNG image.png

To take this even further, we can build a neuroprosthetic hand: this is a fun and simple project that mimics the movement of the flexor tendons in the fingers using strings, straws, and a single micro servo motor. Let’s put it together.

Hot glue tip: When you power up your hot glue gun, you should also be preparing to burn yourself with it. Not intentionally, of course, but it’s really easy to do, and the longer it takes you to cool down your skin, the more damage is done. So for this reason, I always prepare a bowl of ice water and keep it nearby when I’m using hot glue. That way, I can plunge my hand into the water as soon as a burn happens, which makes it a less severe burn, so I can get back to making.

Begin by cutting many small pieces of the straws, about 1cm each. Then glue the sides of the straw segments to the foam hand, being sure not to plug up the straw’s hole with glue. Install a string through each finger and glue it to the fingertip end.

The straws represent the flexor tendon sheaths, and the strings represent tendons. When the strings are pulled, the fingers flex. Please refer to the official guide for the neuroprosthetic hand kit for a more complete step-by-step tutorial.

The next step is to prep your servo motor to pull those strings. Attach the longest horn so that it’s perpendicular to the long edges of the motor casing. Next, cut a motor-sized notch in the corner of the included balsa wood, and hot glue the motor in place. If the wires are oriented away from the wood, that’s what will work best for this setup.

Next, glue the pencil along the length of the servo horn. You’ve got to be careful not to get glue on the main body of the motor, though. I think it’s cute that in this kit, the pencil you use to mark the wood becomes part of the project itself. Then tie one more string around the five tendon strings and glue it to the pencil.

The servo plugs into a port on the Spiker:bit. Then it’s a matter of writing some code to move the motor when the muscle signal exceeds a certain threshold, like earlier, but with an additional output. If you haven’t already, you’ll need to install the servo library in the MakeCode workspace. Then expand on the code we made earlier by adding a Servo block to the conditional statement.

Now when you flex your fingers, the servo moves and pulls the strings. You may need to adjust the strings and the servo horn to achieve the desired movement.

Heart Tracking

_com.apple.Pasteboard.UrJz5p.png
PNG image.png

To track your heartbeats using Spiker:bit, you just need to change the placement of the electrodes and use the Heart Blocks included in the Spiker:bit extension. The result is an ECG signal, which is short for electrocardiography, also called EKG.

Sending Eye Movements

_com.apple.Pasteboard.h0S5xs.png

The last thing included in the Spiker:bit code extension is a brain recording block, which we can use to record an Electrooculogram. EOG is a measurement of the electrical activity of the eye. So two electrodes go around the eye, and the black ground electrode goes behind the ear, and now you can make projects that react to your blinks and eye movements.

Q&A

Why is it called Spiker?

Neurons communicate with trains of electrical impulses, called spikes. They send tiny amounts of electricity through your nervous system to control everything you think and do. You just learned a neuroscience term.

Do I have to use the blocks code environment?

No, you can also use Python or Javascript right inside the Makecode site, and switch back and forth between them. If you want to code in pure Python without the limitations imposed by syncing up with the blocks, you just have to switch over to the BBC micro:bit Python editor.

What parts are on the board?

Spiker:bit has circuitry to amplify the electrical signals coming from the body. It’s got a connector for the micro:bit to slide into. On the other side, there’s a battery holder, a jack for the electrode cable, a dedicated connector for a servo motor, a set of expansion headers for clean access to even more pins, and two Grove-compatible connectors: one for digital, and one for analog.

I hope you’re inspired to try out a project with Spiker:bit!