Acceleration over time for a hand-held walk, shown raw, after filtering, and with each counted step marked by a red triangle.

Pedometer.

  • Sensor Systems
  • MATLAB
  • Butterworth filter
  • 97.6% accuracy

A step counter built from a smartphone's accelerometer. Walking data is recorded in MATLAB Mobile, the walking rhythm is isolated with a Fourier transform and a band-pass filter tuned to each walker's cadence, and peak detection counts the steps with 97.6% accuracy.

Reports

Highlights

Acceleration on the phone's x, y and z axes over a recorded walk.

Sampling.

Walks were recorded at 10 Hz in MATLAB Mobile, with the phone either in a trouser pocket or held flat against the body. Taking the norm of the three axes makes a step show up however the phone is held, and subtracting its mean removes gravity and centres the signal on zero.

Single-sided amplitude spectrum of a walk before and after filtering, with one peak near 1.8 Hz left.

Filtering.

A discrete Fourier transform finds the walking frequency as the tallest peak in the spectrum. A second-order Butterworth band-pass filter is then centred on it, with cut-offs scaled from each walk's own cadence rather than fixed, so the surrounding noise falls away.

Acceleration over time for a walk with the phone in a pocket, shown raw, filtered, and with counted steps marked.

Counting.

MATLAB's findpeaks counts a step at every filtered peak above a threshold set from the signal's standard deviation. Across six test walks of 17 to 60 steps, both carrying methods reached 97.6% accuracy. Taking the phone in and out of a pocket still registers as steps, and shorter, shuffling steps could fall under the threshold, so more walkers and longer walks are needed to prove it.