DIY Electromyography

by SelkeyMoonbeam in Circuits > Assistive Tech

42257 Views, 286 Favorites, 0 Comments

DIY Electromyography

Screen Shot 2014-08-22 at 12.15.46 PM.png
Screen Shot 2014-08-22 at 12.17.55 PM.png

Electromyography (EMG) is the measurement of nerve impulses to your muscles. Probably the most popular consumer device using EMG is the Myo, which is an armband that lets you do gesture control– check out their website to see some cool demos of why EMG is exciting.

The principle behind EMG is pretty simple: nerve impulses are electrical signals on the order of millivolts, and you can read those millivolts through your skin using electrodes.

In this Instructable, I'll show you how to read the muscle impulses in your bicep, using materials you can buy online and a bit of simple JavaScript code.

You can also find this project written up somewhat differently here: https://projects.tessel.io/projects/emg-over-the-gpio

Materials

emg.jpg

You will need:

  • Tessel
  • Servo module (optional, but fun)
  • Electrode leads
  • Electrodes (you need at least three electrodes, but you'll want spares since they're single use. The link is a 100-pack.)
  • Electrical parts (schematic) – you can get these on DigiKey. Get spares just in case you drop something.
    • AD622A (x2)
    • A00B (x2)
    • BBFDK (x1)
    • 1uH 230mA inductor (x1)
    • 10k resistor (x11)
    • 1nF capacitor (x7)
    • 1uF capacitor (x7)
    • 50k ohm potentiometer (x2)
    • Wires

Make the Circuit

Screen Shot 2014-07-30 at 3.17.26 PM.png

You will need to build a circuit to process the incoming signal from the electrodes.

This circuit takes input from five electrodes, amplifies the signal and applies some filtering, and sends it as an analog output. Specifically, it's set up to feed the analog output into the pins of Tessel's GPIO bank as two channels of information, with gains adjustable via the potentiometers.

You can breadboard this. We were kind of fancy and got a custom PCB printed, and then assembled with surface-mount components.

Place Electrodes

Screen Shot 2014-08-22 at 12.15.21 PM.png
Screen Shot 2014-08-22 at 12.19.09 PM.png

You need three electrodes to get a signal:

  • One electrode, Vref, goes somewhere near the muscle you're measuring, but not on a muscle– so if you're measuring your bicep, you can put it on the back of your elbow.
  • One electrode goes in the center of your muscle. Flex to see your muscle and stick it right in the middle.
  • One electrode goes on the end of the muscle– so for your bicep, just above the inside of your elbow.

By now, you should have electrodes stuck to your arm, the snap-on electrode leads hooked up from your arm to the circuit, and the circuit wired in to Tessel's GPIO bank.

Code

Screen Shot 2014-08-22 at 12.11.41 PM.png

Plug your Tessel in to your computer with a microUSB cable.

Now you're going to work from the command line. (If you've never done that before, it's not that hard. Here's a one-minute primer: Mac | Windows)

If you haven't used Tessel before, follow the instructions at tessel.io/start to install and get it up and running.

Now, clone my Github repo: https://github.com/Frijol/Tessel-GPIO-EMG (in the command line, enter: git clone https://github.com/Frijol/Tessel-GPIO-EMG.git)

Change directory into that folder of code (cd Tessel-GPIO-EMG).

Ok. Now here's what you have:

  • index.js: a library you can use for EMG. See APIexamples.js for examples of all of the available functions.
  • APIexamples.js: examples of every available API call from index.js.
  • test.js: prints the output from channels 1 and 2 of the GPIO module. Very simple, does not use API– just lets you see if the hardware is working.
  • strength-meter.js: turns a servo in proportion to the output from channel 2. Kind of messy, pre-API.

Run test.js with this command: tessel run test.js

Your terminal should spit out some numbers. Try flexing! The numbers on one of the channels should change noticeably when you're flexing vs. relaxed.

Screen Shot 2014-08-22 at 12.17.47 PM.png

Play! Hook up that output to something and control the something with your muscles.

Here's me hooked up to a robot snake.

Here's Jon demonstrating strength-meter.