SimpleFOC playing Sweet Music

I’ve been wasting far too much time over the last few weeks on a silly tone-player arduino library for brushless DC motors. It turns your bldc motor into a speaker!

It, of course, uses SimpleFOC underneath. It can play polytones (with two motors) and has some jukebox functionality.

I can finally get back to doing some proper robotics!

(A shout out to @blackblue007 who wrote a nice post which describes most of the storm32 pins. Thanks!)


That’s amazing! You’re getting a great tone out of those motors :smiley:

I love it! :smiley:

Are you using the SimpleFOClibrary at the end?
We should add this as an example code or as a project if you are motivated to create it:D

It is using SimpleFOC - velocity_openloop with setPhaseVoltage. It can oscillate using square or sinusoidal wave. Square is louder and uses less cpu.
I’d be happy for it to get moved under SimpleFOC umbrella.

And of course @Antun_Skuric, your croatia national anthem and my welsh national anthem are available on the jukebox!

1 Like

@Owen_Williams Have you tested your library with other microcontrollers?

@David_Gonzalez - I’ve just tested it on esp32. Works fine (although don’t have capability of testing polyphony).

I’ve also retested on atmega328p - I’ve pushed a couple of fixes to repo. Now the first 4 examples work but the last 2 do not (only so much you can fit in 2K SRAM). It’s possible that there might be a timer issue on atmega328p - I’ve got a dual bgc gimbal controller and it works on one driver (BLDCMotor(9, 10, 11, 7) but not the other (BLDCMotor(3, 5, 6, 7)).

I’ve done most of my testing on stm32f103rc (storm32 triple gimbal controller).

My testing is on a wooden bench - for smaller motors it works best on something that resonates. Increasing voltage_limit typically makes it louder. The hoverboard motor is MUCH louder than gimbals!


I love it :slight_smile:

8 years ago I made a similar thing using a PIC18F4550 as a midi interface to drive a stepper :

sorry video is in french (but who cares for music !)

It was a lot of (useless ?) fun !

1 Like