Part 1: MIDI 3-phase motor controller

Making a MIDI to play music on a 3-phase motor (independent of the motor speed). My dream would be to use this MIDI to play music on a flying quad drone.

electronicsmotors
Part 1: MIDI 3-phase motor controller

Do you ever think about the sounds that the machines around you make?

This fall, I got a coffee machine for free. It was a brand new Autobarista from Sharkninja. It was an EU unit, so like any normal human being in the US, I found a 220 outlet, made an adapter into an EU outlet that I now have in the kitchen. The machine has been working great since!

The fun thing about any machines, whether its an automatic coffee machine or a cnc mill are the sounds the machines made as they operate. Every morning as I make my coffee, I listen to the usual "beep-boop wheeeeeee grrrrrrrrrrrrrrr gr gr bop bop ..... fshhhhhhhh.... BEEP BEEP", indicating that my coffee has been ground and extracted, my milk has been frothed.

My coffee machine next to some of my other past projects, namely an end grain cutting board and a quilted pot holder.

All this music to my ears has gotten me thinking how I can turn conventional, useful tools into musical instruments. This idea is not without its great precedents:

- Super Mario Bros on a motorized CNC

- Freebird on a CNC mill during cutting

- the hardcore coffee machine music

- Windows startup sounds sung by a dog

I've been thinking about building my own drone for some time to learn about 3-phase motor control and remind myself the control principles I learned in undergrad. This was just the motivation I needed: what if my drone could not only fly (boring), but also make funny noises as it flew around (fun, yay)?

CNC motors are typically brushed and the sound they emit is related to their speed, but this can be decoupled for brushless motors.

In fact, a fellow MIT person did so ~15 years ago on a scooter. On a drone, you get 3 phases x 4 motors = 12 potential notes + each propeller can play its own base sound :D I was sold on this project.

Below is my progress on writing a controller and a MIDI for the motor.

**The hardware:**

  • Motor: Hobbystar C2208, 1000 kv
  • Board: STM32G431
  • A bench supply at 12 V with a 1 A current limit

Step 1: A (safe-enough) motor controller

- the goal here is to be able to spin a motor at a chosen speed, and drive each of the three wires at its own frequency to make tones. A watchdog monitors sensor readouts and stops the motor to avoid damaging the motor.

-duty = 0.5 + swing × sin(2π × (position + offset)). When the waves from the three phases don't line up into a rotation, the field just pulses and the motor vibrates and makes sound.

- Pitch is controlled by the frequency of the sign wave. For example, 440 Hz gives you an A4.

- Volume is controlled by the strength of the signal, which in this case is voltage. Note that in reality, the observed volume depends a lot more on the acoustics around the motor. A bare motor is a poor speaker.

Step 2: MIDI

To spin, each of the motor's three wires carries a slow wave, staggered so the magnetic field rotates. To play a note, the program makes the strength of that wave pulse at the note's pitch: 440 times a second for an A. The motor keeps turning, while its torque flutters fast enough to hear.

- give a song as an input and feed it to the controller to play music

- every 1ms, the code checks the sensors and performs safety checks, and moves the song along and then updates the motor.

Video or a song playing on the motor (irrespective of its RPM): https://youtube.com/shorts/_3TnMo1oK14

The motor sits over the power supply, which acts as a resonance box. Notice how much quieter the motor gets when its lifted off the power supply mid-video. Its similar to playing on an electric vs acoustic guitar without an amp!

Next steps for me in this project are to assemble a small quad drone, write controls for it, and merge it with the MIDI controller.

← All blog posts