Skip to content

An instrument that plays MIDI files using stepper motors.

Notifications You must be signed in to change notification settings

mmertc/Stepper-Motor-Instrument

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 

Repository files navigation

Stepper-Motor-Instrument

An instrument that plays MIDI files using stepper motors.

         

How Does It Work

The theory behind playing the notes using stepper motors is that they vibrate, and thus, produce the note at the frequency they are stepping at. So essentially what the design does to play notes is, stepping a motor at the frequency of the note that needs to be played at that time instant. A4988 stepper motor drives are used to control the motors and a BASYS3 FPGA as the controller. Also a 5V-3.3V logic converter is used since the drivers use 5V high while BASYS3 uses 3.3V high. 1N138 optical isolator is also used in a receiver circuit to read the incoming packets from the MIDI cable and decreasing them to 3.3V in the process.

MIDI has many different packets but the design makes use of only 2 particular ones: Note On and Note Off. They are 3 bytes long each and in the form of: 1001CCCC 0NNNNNNN 0VVVVVVV and 1000CCCC 0NNNNNNN 0VVVVVVV respectively. Here Cs denotes the channel, i.e. for which instrument this command is intended, which is in this case which motor, Ns denote the note number and Vs denote the velocity of the note, i.e. loudness. As the design has no use for the velocity, it only looks for the first 2 bytes of these commands.

a

Figure1: The schematic of the FPGA design.

 

The FPGA design first has a UART receiver module that receives the packets sent from the computer. Then the packet shifter module sticks the two consecutive packets together to assemble a possible command. Then the command executer module checks if the possible command is valid, and if it is then it executes it by writing into the register of the related motor controller module.

b

Figure2: The submodules of the motor controller module.

 

Each motor controller module has an 8 bit register that stores the number of the note that the motor needs to be playing at that time. Then the LUT produces the integer that needs to divide the BASYS3’s clock frequency, i.e. 100MHZ, to generate the frequency of the note that needs to be played at that instant. And the square wave generator module generates a square wave with that frequency. And finally all the motor controller outputs are connected to the step pins of the A4988 drivers.

Some Example Pieces

Tetris Main Theme

Turkish March

Flight of the Bumblebee

Rachmaninoff: Piano concerto No. 2 in C Minor, Op. 18: I. Moderato

P.S. Grinding noise that occasionally happens is because some notes hit the resonance frequency of the motors. It can be fixed simply by setting those notes one octave higher, but it is too much work to do for each one of them. ¯\_(ツ)_/¯

About

An instrument that plays MIDI files using stepper motors.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages