Stepper Gauge


Today seemed like a good day for cleaning out junk drawers, and I’m proud to say I successfully completed half that job!  While looking through the heaps of crap I absolutely need, I came across a questionable stepper motor driver and stepper motor. Odds are the reason I had it is because it doesn’t work, but of course I’m not going to throw it out without testing, and with a three year old repeatedly asking “what’s that?” it seemed like I had no choice but to hook it up and start screwing around.

2017-03-16 09.02.372017-03-16 09.02.19

The stepper driver is a pretty standard type, it takes two input signals, one tells it which way and the other says how many. Steps that is. So where do I get these signals? I have a raspberry pi that floats around my bench that I can make use of when I need some GPIO. Ignore the rainbow of other wires going to the right in the photo, they’re from another project that I can’t disconnect because I’m totally going to finish it someday. The only ones that matter here are the three wires going southbound. Those three wires are STEP, DIR, and GND.

2017-03-16 09.04.28

The only thing left was motor power. If you’re looking for something to add to your test bench at home, go to ebay and pick up one of these XL6009 step up DC-DC converters and stick a couple 2.1mm barrel connectors on each end. (pick up a couple 10 packs of 2.1mm barrel connectors too while you’re there.) So handy. It turns any wall wart you have kicking around into an adjustable voltage source. I used mine to boost from my 12v adapter to the 24vdc that this motor requires.

2017-03-16 09.03.53

Here’s the whole package assembled. Nothing to it really.

2017-03-16 09.09.44

The other only thing left was to hack up some software. Toggling the outputs manually proved that the drive and the motor worked. I can move the motor. But then what? Steppers are so easy, all you need to do in order to make them move is turn that STEP line  on and off a bunch of times and the motor will move 0.1 degree that same bunch of times, so the code is kind of boring. The fun had to come from what numbers to send. The pi was connected to the same wifi that my thermostat/gaslogger/powelogger was on, so I had plenty of numbers to choose from. Using my socket for realtime power monitoring  seemed like the most logical choice, so the code below was the result. It polls the power consumption every two seconds and moves the stepper 1 step per watt. I threw a little cardboard pointer on it to make it easier to see the movement.

2017-03-16 18.19.10

Then I added a cardboard backing to make it even more gauge like….. This is the gif from before my assistant helped out with some decorations. Aww yeah, that’s some awesome, shoddy ass gauge at work.


I was really entertained by this bout of screwing around, it made for a fun afternoon. More entertained than my kid it seems….something about having to turn on the microwave, or wait for the furnace to start before seeing anything happen wasn’t compatible with her attention span I guess. Maybe I’ll hook a joystick up to it or something for a bit more instant gratification, or I’ll just cut up more cardboard for drawing on…yeah, probably the cardboard thing.

It is worth noting that you can make up something like this really damn cheap these days. On ebay, an equivalent stepper driver can be had for around 2$, stepper motors anywhere from 5$ to 20$ depending on how much you need to move. Stick a 5$ esp8266 based controller on there and you can have a wifi connected stepper, or steppers, somewhere in your house doing…. I dunno… something!?

The python code is pretty simple, but it’s available here if you’re interested


Tags: , , ,

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: