Introduction: DIY Electromyography
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.
You can also find this project written up somewhat differently here: https://projects.tessel.io/projects/emg-over-the-gpio
Step 1: Materials
You will need:
- 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)
Step 2: Make the Circuit
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.
Step 3: Place Electrodes
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.
Step 4: Code
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.
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.