2

I'm trying to read the speed of a manual treadmill (the York Pacer 2120 - manual: http://www.yorkfitness.com.au/uploaded/pdf_40Pacer%202120%20Treadmill_5500.pdf) by intercepting the wire that comes out of its speed sensor. My understanding that I've garnered by taking apart as much of the treadmill as I can is that the speed sensor is basically a magnet attached to a big disk attached to the belt of the treadmill that generates current every time it passes a coil of wire.

The wire that comes out of the speed sensor ends in a 3.5mm jack. I plugged this into my laptop's microphone port and recorded the "sound" of me walking at both high and low speeds. I've attached images of the waveform recorded in Audacity for low and high speed respectively.

Slow Fast

My aim is to measure the speed of the treadmill in real time so that I can pass it as input into my game engine and control the speed of a character in game. I'm not sure what the best method to do this is but at the moment I'm trying to measure the distance between the "beats" in python using PyAudio.

To do this I've copied the beat detection code from the answer to another question (Detect beat and play (wav) file in a syncronised manner) but that gave me an usably high level of false positives.

Does anyone have any ideas as to how else I could go about getting a usable speed out of this signal? If you do, a code example would be very much appreciated. Other than that, how else would people go about trying to measure the speed off a manual treadmill? I've tried everything from using a camera to measure the distance between pieces of tape stuck to the treadmill belt to physically sticking a mouse to the treadmill to measure the speed of the belt.

The sound files are here:

And the audacity projects here: https://www.dropbox.com/s/3cjvo3m2ln2ldet/AudacityFiles.zip?dl=0

Ben Elgar
  • 715
  • 10
  • 23
  • Very intresting question/approach. Unfortunatelly I cannot help with python/audio. The way I would probably be going is to use an Arduino or other simple Microcontroller and plugging in your signal there, reading the voltage of the input pin you're using, and giving a signal via usb/serial to the computer from there on every beat. Requires additional hardware, though. – inVader Feb 26 '15 at 15:40
  • I actually tried that. I borrowed an Arduino and tried to tackle it that way but didn't get very far. I didn't completely understand why it wasn't working but I hooked it up to an oscilloscope to get a better idea but the signal was so noisy I couldn't make anything out. – Ben Elgar Feb 26 '15 at 15:46

2 Answers2

1

I might look here Convert multi-channel PyAudio into NumPy array

From looking at the audio, you just need a simple trigger for when the signal is <0, you can likely modify the callback method to detect when the amplitude was positive and has been negative for N samples, then count the occurrences per second to retrieve the speed

tolster710
  • 36
  • 1
1

I did eventually solve this but I gave up on PyAudio and used a Raspberry Pi instead. I open sourced the code if anyone happens to be interested: https://bitbucket.org/grootteam/gpio-treadmill-speed/

Ben Elgar
  • 715
  • 10
  • 23