I had this nice step motor lying around and searched for a funny way to use it. Then I came across the idea of using a stepper as rotary encoder, a nice idea explained in detail on several sites:

Since I wanted to make this experiment as simple as possible, I thought about using my soundcard as input device. I came up with this really simple circuit:

interface circuit

In short, it just limits the voltage to the soundcard to about +-0.7 Volts. The resistor values shouldn't be critical.

Some pics of the pretty crappy mc-guyverish construction as well as screenshots of the waveforms while turning the knob:

construction1 construction2

wave 1 wave 2

One of the soundfiles I recorded to study the signal: stepper.wav

The algorithm used to analyze the audio data

This algorithm is implemented in the example python application, see below.

It basically goes like this:

A practical application

Now that the basic idea was working, I needed a practical application to use it.

I was a long time fan and listener of websdr. In short, it's a web controllable shortwave receiver (open to anyone, without registration etc.) A real physical tuning knob would be nice, so I started thinking.. The challenge was to remote control a web application without being able to change something on the server side. So I stumbled upon Greasmonkey This Firefox extension allows you to manipulate and access the html/javascript of specific sites. I wrote a Greasemonkey script which periodically fires up a http request to localhost and calls the websdr's javascript function to set the frequency with the passed value. On localhost, the server part of my software (written in python) calculates the actual increments from the soundcard's input and returns them to the Greasemonkey script with a simple build-in web server.

See a short video of the remote controlled websdr:

If you want to try this out, read below..

Control websdr with a real knob

You need:



known bugs: The Greasemonkey script _should_ add a custom menu to Firefox (allows setting of the host/port where the server part runs), but it doesn't..

UPDATE: With Greasemonkey 0.8.20091209.4 on Firefox 3.6 (Ubuntu 9.10) the menu DOES appear, it seems that MY Greasemonkey setup was broken. (Thanks for the feedback, David!)

This software is far from being perfect, any fixes/additions are welcome.

Comments, suggestions, additions? Drop me a line: srehm AT - English or German please.