Marko spent the past few weeks walking up and down the intern's lab. Criss-crossing the room hundreds of times, sometimes marching like a soldier, other times tottering like an old lady... all the while keeping a mikromedia in his pocket.
As every other intern, on his first day Marko received a spreadsheet with a list of projects to choose which one he will work on. He skipped the WiFi weather station… considered a software implementation of USB… then finally settled on a pedometer on a mikromedia for STM32 M4:
There was a bunch of interesting stuff on that list, but a pedometer looked to me like the most complete, all-round challenge. I studied Signal processing in college so I knew the theory. Making it work on a piece of hardware I was not familiar with looked like an opportunity to learn a lot.
Initially I assumed it would be a straightforward process. I mean how hard could it be? First I would acquire the signal from the accelerometer. Walking steps would obviously show up as a rhythmically reoccurring pattern, so I would just have to set up a proper threshold to separate the walking from the variety of background noises and that's basically a pedometer.
Man was I wrong.
The output from the accelerometer was a mess. No way to reliably tell apart steps from everything else just by looking at it.
It took a lot of digging through Google scholar to study previous implementations. Coming up with new assumptions, altering the code… then of course walking and walking… Step by step (pun intended) and the number of steps slowly started to correlate with the counter on the mikromedia display.
It's a great collaborative environment down here. We help each other all the time… throwing ideas back and forth… when we get stuck, a senior developer from upstairs shows up to nudge us in the right direction.
End result? You can download the code from Libstock and study the details; in short, Marko developed an algorithm that dynamically adapts to your particular pattern of walking:
As you walk with the mikromedia in your pocket, the accelerometer generates a jumble of signals; some of it is from walking, some is the interference from surrounding circuitry, some is from the board shifting in your pocket. The problem is, your pattern of walking is constantly fluctuating so it's impossible to set a fixed threshold that would separate your steps and discard all the surplus noise. To address this, I developed an algorithm that samples the accelerometer data every 0.5 seconds as you walk, and dynamically adapts this threshold. Additionally, to prevent the pedometer from counting steps as you're shuffling your feet while waiting for the bus or something, I've set fixed low and high gate values. These are based on statistical research on what constitutes walking (from Google Scholar). I'd say that I achieved a precision of about 90 percent. It's not the most sophisticated pedometer in the world, but it's pretty reliable.
More Intern projects coming up, including the above-mentioned Software USB implementation. Stay tuned.