Stepper Motors the Singers

Spread the love

Stepper motors are a very common motor that have been used heavily in our life. It is a simple motor that have at least two coils that inter-switching to drive the movement. As the result, these motor are well controlled with high accuracy and use less complicated circuit compared to encoder-based servo motor. However it does lose step easily because it is an open loop system, unlike servos have encoder as feedback system, so it is not highly practiced in industry uses.

I have made it 4 years ago using floppy drive, forget about the record quality, I’m sorry. However if you are interested on floppy music, do let me know in the comment section.

Stepper have been used in printers, hard disk, floppy disk drive, CNC, robots and etc. Have you realise when these appliance running, it produce some weird sound? Maybe you aren’t because life is so busy and you don’t have such free time like me to appreciate these splendid music that sound like symphony.

As you can hear, 3D printers produce very noisy sound.

I have few 3D printers that are producing damn noisy sound when it is operating. These sound are varying when the moving speed changes. I comes out an idea to make them a singing machine. This idea was like an adrenaline to me, I feels my spirits was burning.

“These sound are varying when the moving speed changes.”, sound like very physics? Yeah, I quickly realise that this is related to a physics formula, which is

    \[Time = \frac{1}{frequency}\]

. With this, we can merely produce any sound of any frequency by calculate the time required and spin the motors with it. For an example, let say we need to generate C4 tone, which is 262Hz, the time per step should be 0.003818 seconds.

To bring the ideology to reality, I used a micro-controller to realise it. Arduino is a great option here as it is simple to be programmed, with plenty of library and abundant of source code available online. Beside that, to drive the stepper, we need stepper motor driver too(like Pololu A4988 that have been used in 3D printers), because the power of micro-controller is too low to drive the stepper(12V needed). Stepper motor driver also driving the motor using sinusoidal wave while receiving digital input of steps from micro-controller. With turning on and off the step signal of the driver with specific timing, we are able to control the speed of the stepper, and we are closer to made the dream into reality.

Manufacturer suggested wiring. Source: https://www.pololu.com/product/1182
Playing A3 220HZ on stepper motor

As a realist, I don’t like to reinvent the wheels, I believe there would be related open source projects available online. Why not we just grab it and use it with little modification to suit our works. I found a useful repo that use simple code to implement this. This repo have complete source code on interpreting midi signal from computer and driving the stepper motor which save me a lot of time.

Arduino read the serial data stream from computer that contain music notes that to be played. To convert the midi into serial streams, we have to take few steps. loopMIDI are used to create a virtual MIDI interface on windows, and Hairless Midi are used to convert MIDI from virtual interface and transmit to Arduino’s serial stream.

loopMIDI
Hairless MIDI

From the aforementioned Github repository, there is a fully functional Arduino code for use to upload to our own Arduino. Upload the sketch to the micro-controller is simple with Arduino IDE, just open the ino sketch and click upload and you are done.

When we playing midi music, the motor will moving and generate beautiful tones. Any midi player will worked, I using Windows Media Player here, classic enough. Did I recall your childhood memory?

Here are the stepper motors connected to Arduino, prepared to sing to me. Four motors are playing different tones that ensembles a beautiful song. By the ways, these are the motors that scraped from 3D printer, there are still gears and pulleys haven’t been removed, haha.

The formation of the stepper orchestra.
Playing Super Mario Theme song on the stepper

The journey doesn’t end here, stepper music sound interesting, but it still missing something, why not we play the songs with more instruments? The Tesla coil (refer my previous blog post) are a great candidates too :D. This time, I managed to ask one of my friends to enrich the stepper music with her mesmerising piano, is this consider an extra bonus for this week post? Hope you like it.

Leave a Reply