MuscleMate

An EMG capstone: wearable electronics, muscle-controlled software, and gesture recognition, 2011–2012.

Carleton University · Capstone project · 2011–2012

I supervised MuscleMate, a wearable interface that turned forearm muscle activity into computer input. Nick Stupich, Mark Klibanov, Musabbir Khan, and Amrita Sandhu built the acquisition electronics, embedded signal processing, recognition software, and applications as one working system.

A contraction could advance a presentation, continuously control a helicopter in a game, or form part of a recognizable gesture. The project brought a useful question into focus: which representation of a muscle signal makes the intended action easiest to distinguish?

My key contribution to that question was the natural-log transformation of the EMG frequency features. It exposed the separation between activation levels and made the geometry of a separating hyperplane clear. That insight also led to a practical way of estimating continuous muscle activation.

MuscleMate armband with acquisition boards, Bluetooth module, battery supply, and forearm electrodes
The complete wearable prototype: removable acquisition boards on an upper-arm strap, with differential sensors over the forearm muscles.
Acquisition
3 channels
Sampling
1,024 Hz
FFT window
256 samples
Representation
8 bins / channel

Building the wearable electronics

The electronics had to preserve a small differential signal while the user moved. Each sensor placed an AD620 instrumentation amplifier close to the electrode pair. Short connections brought the signal into the amplifier; subsequent stages selected the frequency band, controlled gain, and translated the waveform into the microcontroller’s input range.

Pair of silver/silver-chloride electrodes mounted to the MuscleMate sensor
Silver/silver-chloride electrodes provided the skin contact for the working prototype.
Early dry-electrode sensor assembly on a small circuit board
The team also built dry-electrode assemblies and investigated contact stability and motion sensitivity.

Several filter implementations were built and measured. Continuous-time UAF42 circuits provided an initial platform for studying passband and notch responses. The final conditioning design used a MAX7480 low-pass filter and an MF10 dual switched-capacitor filter for the 60 Hz and 120 Hz notches. Clock tuning placed those notches on the interference frequencies; the measured settings were 5,976 Hz and 11,952 Hz for the two MF10 sections.

Gain control linked the analog circuit to the firmware. A pulse-width-modulated output, smoothed into a control voltage, adjusted a JFET resistance in the amplifier feedback path. The firmware tracked mean-square deviation about ADC midscale and selected the gain for each channel. It also retained the gain setting when scaling the acquired samples, keeping changes in electronic gain associated with the signal values used for analysis.

Breadboard implementation of the UAF42 notch filter
An early notch-filter implementation used to evaluate the analog response.

Designing around a 10-bit converter

The ADC accepted a 0–3.3 V signal. Clipping and a DC-offset stage placed the conditioned waveform around 1.65 V. Automatic gain control helped use that input range across changes in contraction strength and electrode contact.

Separate channel boards, a regulated supply powered by two 9 V batteries, and a fabric strap made the complete instrument portable. This modular construction let the students test each stage and then assemble the full signal path.

From samples to frequency features

The Fez Mini microcontroller converted each signal into a compact frequency representation before sending it over Bluetooth. A 256-sample window at 1,024 samples per second spans 250 ms and gives 4 Hz frequency spacing. Successive overlapping windows allowed the software to update its interpretation as a contraction developed.

Sample10-bit ADC
1,024 samples/s
Transform256-point FFT
4 Hz spacing
Summarize24 magnitudes
8 frequency bins
TransmitBluetooth
PC or Android
X[k] = N−1n=0 x[n] e−j2πkn/N
Δf = fs/N = 4 Hz

The real-input FFT used the symmetry of the spectrum to reduce memory and computation. Twenty-four magnitudes were grouped into eight features per channel. The retained frequencies stepped around the 60 Hz interference component:

Bin 012 · 16 · 20 Hz
Bin 124 · 28 · 32 Hz
Bin 236 · 40 · 44 Hz
Bin 348 · 52 · 56 Hz
Bin 464 · 68 · 72 Hz
Bin 576 · 80 · 84 Hz
Bin 688 · 92 · 96 Hz
Bin 7100 · 104 · 108 Hz

Timing and memory were active design constraints. The native routines shared a 10,236-byte code-and-data region. Timer interrupts gave sampling priority while FFT and transmission work ran between acquisitions. A real-input transform, compact trigonometric tables, and a custom packet format kept the processing small enough for the platform.

The wireless protocol carried one scale value and eight feature values per channel, with a reserved delimiter for packet alignment. Channel-selection commands let the host choose which sensors to acquire. This separated the time-critical acquisition work from the training and application logic.

The logarithmic insight

We recorded the forearm extensors at three instructed effort levels: relaxed, intermediate, and maximum perceived contraction. On the original feature scale, the largest values dominated the display. I took the natural logarithm of the data in Mathematica and shared the result with the students. The transformed surface revealed three distinct regions.

The important change was geometric. For a positive frequency-bin magnitude pi, define the transformed feature

zi = ln(pi)

A multiplicative change becomes an additive displacement: ln(a p) = ln(a) + ln(p). Large amplitude ratios become manageable distances, and the intermediate activation level becomes easier to distinguish. This gave us a useful coordinate system for both separation and interpolation.

In these coordinates, a linear decision boundary has the form wTz + b = 0. Written in the original magnitudes, the same boundary is a weighted product:

i wi ln(pi) + b = 0
i piwᵢ = e−b

A simple hyperplane can therefore express a structured relationship among the original EMG features. Choosing the representation changes what a linear model can describe.

Mathematica plots showing the original EMG frequency features, their natural logarithms, and three separated activation regions
Three activation levels across eight frequency-bin features: original magnitudes (top), natural logarithms (middle), and the separated regions (bottom). The training targets were 0%, 50%, and 100% of perceived effort.

From features to muscle control

The software exposed two complementary outputs from each acquisition window: a discrete muscle-state decision and a continuous activation estimate. Each model was trained for the user and the action being controlled.

A separating hyperplane for muscle state

The students implemented a linear support vector machine using LIBSVM. Training paired frequency-bin vectors with labels captured from a key press or a touch input. Each output received its own model. At runtime, the decision reduced to a weighted sum and threshold:

s(x) = wTx + b
ŷ = sign(s(x))

The weights determine the orientation of the separating hyperplane and the contribution of each frequency bin. In the tested linear SVM, x contained the acquired frequency features; the logarithmic transformation above supplied an additional coordinate system for studying separation. The trained weight vector also offered a way to inspect which parts of the spectrum carried the muscle-state information.

For the recorded binary muscle-state data, ten-fold cross-validation gave approximately 99% accuracy for the linear SVM, compared with approximately 96% for a threshold on summed features. The SVM used a cost parameter of 0.001. Errors concentrated around changes of state, connecting classifier performance to the 250 ms observation window and the timing of the training labels.

A log-domain estimate of activation

The continuous output used the logarithmic features directly. For each bin, the students fitted a line from log magnitude to the instructed effort level. They combined the individual estimates using their Pearson correlations with the training target:

ai = mi ln(pi) + ci
â = (i ρiai) / (ii|)

Here mi and ci are the fitted slope and intercept, and ρi measures the association between a bin and the target. Bins that tracked the instructed effort contributed more strongly. The output was a user-calibrated control level, which the helicopter game turned into vertical acceleration.

Recognizing a gesture through time

A gesture is a sequence. Two performances can share the same order of muscle events while differing in duration. The students used dynamic time warping (DTW) to align feature sequences and compare their shapes across changes in execution speed.

Let ui be a feature vector from the incoming sequence and vj one from a stored example. The local cost is their Euclidean distance. The accumulated cost follows

D(i,j) = ‖uivj‖₂
+ min{D(i−1,j),
D(i,j−1), D(i−1,j−1)}

A diagonal step advances both sequences. A horizontal or vertical step allows one sequence to advance while the other holds its position. The resulting alignment accommodates local stretching and compression of the gesture.

The implemented recognizer compared 0.6-second sequences with stored examples. Training estimated a distance threshold from matches to the same gesture and matches to other activity. A penalized subsequence variant allowed the alignment to start or end within a recording, with a cost for the fraction omitted. This made the treatment of uncertain gesture boundaries part of the recognition method.

Recorded keystroke experiment: distance distributions for matching and other activity.
MethodGesture distance
mean ± SD
Other activity
mean ± SD
Separation
Basic DTW1,403 ± 2944,743 ± 2,2061.3
Penalized subsequence578 ± 341,554 ± 6671.4

Separation is the difference between the two means divided by the sum of their standard deviations. Both methods separated the recorded classes; the penalized subsequence method gave a modest increase in this measure. The experiment established a sequence-matching approach alongside the real-time muscle-state and activation outputs.

Putting muscle control to work

The PC and Android software shared a useful division of responsibility. A backend received and decoded the Bluetooth stream, collected labelled training examples, built models, and delivered predictions. Applications used those outputs to define an interaction.

Muscle-controlled helicopter game with cave boundaries and activation meter
Continuous control: muscle activation changed the helicopter’s vertical acceleration.

Helicopter game

The player trained at three effort levels, then controlled ascent and descent by contracting and relaxing a chosen muscle. An on-screen power meter exposed the estimated activation. The narrowing cave made response timing and smooth control tangible.

Android Colour Changer training interface with red screen
Training input
Android Colour Changer interface showing touch-labelled state
Labelled state

Android interfaces

Colour Changer and Tone Generator connected muscle-state predictions to screen colour and sound. Touch input supplied training labels. Bluetooth acquisition and model computation ran alongside the interface, with synchronization managing the transition from training to prediction.

Presentation control

Binary muscle outputs mapped to forward and backward slide commands. A one-second interval between changes converted sustained activation into deliberate navigation. This exposed an application-level design question: the cost of an unintended slide change differs from the cost of waiting slightly longer for a deliberate command.

Related work in myoelectric interfaces places these continuous-control and gesture-command applications in their broader technical context.

From capstone to wearable research

The capstone joined an end-to-end acquisition instrument with trainable software and working applications. Students could follow a change in electrode contact through the analog circuit, inspect its effect in the frequency features, and observe the resulting application response. That connection between the physical signal and the user’s action became central to my subsequent wearable research.

The team received the Department of Electronics awards for best oral presentation and best poster, then first place in the Carleton Student IEEE and IEEE Eastern Ontario paper competitions. First place in the Faculty capstone competition brought $40,000 for continued development.

We subsequently expanded from three to eight channels and developed an armband with removable electrodes. Dedicated hardware used an ADS1298 eight-channel, 24-bit acquisition device, AD8222 instrumentation amplifiers, an LPC1343 processor, Bluetooth, and battery/USB power management. The work grew into textile-integrated muscle sensing, electrode calibration, and combined muscle and motion analysis.