Arduino MIDI Stepper Synth

Turn MIDI data into stepper motor music!

Apr 22, 2018

75157 views

52 respects

Components and supplies

1

Arduino CNC Shield V3

1

12V 6A Power Supply

4

NEMA 17 Stepper Motor

1

Arduino UNO

4

A4988 Stepper Driver

Tools and machines

1

3D Printer (generic)

Project description

Code

GitHub Repo

Simply go to my GitHub. I have instructions on how to configure and install the Code on your Arduino.

/

0
0
Latest commit to the master branch on Invalid date

GitHub Repo

Simply go to my GitHub. I have instructions on how to configure and install the Code on your Arduino.

/

0
0
Latest commit to the master branch on Invalid date

Downloadable files

Breadboard Wiring Schematic

Schematic if the Fritzing Breadboard Wiring. Includes some of the part values not given in the breadboard diagram.

Breadboard Wiring Schematic

Image

Breadboard Wiring with MIDI Jack

If you want to use a MIDI DIN Jack, use this layout.

Breadboard Wiring with MIDI Jack

Image

Breadboard Wiring

If you want to wire it on a breadboard, then here it is

Breadboard Wiring

Image

Breadboard Wiring

If you want to wire it on a breadboard, then here it is

Breadboard Wiring

Image

CNC Shield Pinout

Location for jumpers should you want to use this Shield.

CNC Shield Pinout

Image

Breadboard Wiring Schematic

Schematic if the Fritzing Breadboard Wiring. Includes some of the part values not given in the breadboard diagram.

Breadboard Wiring Schematic

Image

Breadboard Wiring with MIDI Jack

If you want to use a MIDI DIN Jack, use this layout.

Breadboard Wiring with MIDI Jack

Image

Documentation

Stepper Holder

Holds the stepper motors in place

Stepper Holder

Stepper Hand

Adds a "finger" to the motor. Purely for aesthetic purposes.

Stepper Hand

Stepper Hand

Adds a "finger" to the motor. Purely for aesthetic purposes.

Stepper Hand

Stepper Holder

Holds the stepper motors in place

Stepper Holder

Comments

Only logged in users can leave comments

Image
Image

that_dood137

a year ago

Is there a way to make this work with 2 motors, and using l293d drivers instead?

Image
Image

superduperposition

2 years ago

Probably far too late to get a response, but figured I'd try anyway. This is a fantastic project and I have managed to get a simple test working, but I was wondering if there was a way to tweak this to instead read midi files off of an sd card? I want to try creating a standalone "Music box" type of project with an attached sd card reader module that I can insert an sd card with some midi files on it into, and have the device play from these files. It seems from this project code and the included libraries that it may only work with live midi data from a pc/midi controller, but I wanted to ask in case I was mistaken and my idea is in fact possible. Do you/anyone reading this know of a way to achieve this?

Image
Image

Anonymous user

2 years ago

Are other settings necessary? The motor does not move. Help me

Image
Image

Anonymous user

2 years ago

The enable pin is connected directly with a jumper. Really in all the tests nothing happened. I will try to disable the enable physically and let the code activate it.

Image
Image

Anonymous user

2 years ago

I managed to find the problem, but I still haven't been able to solve it. For some reason "motorSpeed ​​= pitchVals [midiNote]" is 0. I did a test with tone () and another list of pitches.h and it worked perfectly. it seems that the code is not correctly interpreting this pithes.h and cannot find the note I send. so motorSpeed ​​= 0. Do you have any idea what it might be?

Image
Image

Anonymous user

2 years ago

I did the test by letting the code activate enable and it still didn't work. In fact, I inform the note on the serial monitor, the code is executed, the note recognizes the motor speed, then the message is repeated with note and speed RESET and the motor simply does not respond. I would love to make them work, I have an interesting project that depends on it.

Image
Image

Anonymous user

2 years ago

I have the same problem that you reported, testing the stepper motor everything works fine. however, in the tune stepper and the serial stepper nothing happens. Could you explain to me what you did to resolve it?

Image
Image

Anonymous user

2 years ago

Yes, I am using the serial monitor to send a note when using the Serial stepper, and the speed when using the Tune stepper. but nothing happens. the RX led flashes, but the engine doesn't move, doesn't even emit a sound ...

Image
Image

JonJonKayne

2 years ago

The speed that the stepper is tuned to shouldn't be motor specific. If you use tone(stepPin, 440) you should get an A440 note. What I am essentially saying is that the pitch values in pitches.h are the note periods in microseconds. Try using a number from the pitches.h file. Also, you could run the MIDI Serial Test (Serial_Stepper.ino) and see if that produces a sound. The difference between the TuneStepper and SerialStepper is that one takes a speed and the other takes the actual MIDI note. So Speed value 2273 should give you an A4 (440 Hz), MIDI note 69. I also found that my pitches.h was an outdated version in the test code, so I have updated it on the GitHub.

Image
Image

JonJonKayne

2 years ago

What you need to make sure is that the step pin is being pulsed by the arduino. If there isn't a step signal getting to the A4988 it will not spin. Unfortunately I am not able to see everything in your setup so I have absolutely no way to give you a straight up fix. My only recommendation is to use troubleshooting techniques and make sure you understand what the code is doing. read through the explanation and make sure you understand it and that you wired everything exactly is specified. If it doesn't work properly then you either didn't follow the configuration or something is broken.

Image
Image

JonJonKayne

2 years ago

Glad to hear that it's working! Yes, I do believe 12V 20A would be sufficient to drive 10 stepper motors. I assume that each motor draws 1.5A. They probably draw less since they don't have any load on then, but better to have more current than not enough...

Image
Image

JonJonKayne

2 years ago

Try running the Stepper Test code that I have on my GitHub. I just added it. I have a few test codes that help troubleshoot the setup. - Stepper Test simply spins a single stepper. If it doesn't work, there is a wiring issue. - Tune Stepper ensures that entering a MIDI note plays the correct sound. If all the test code works, then the actual code should work fine. It could also be due to your method of sending MIDI to the arduino. If you don't have mocuLUFA flashed onto the Arduino, then you need to have serial enabled and use the loopMIDI and hairlessMIDI to communicate. Hope that helps!

Image
Image

JonJonKayne

2 years ago

Are you using the serial monitor? Those codes are purely for testing the tone playback of the stepper motors. In Tune Stepper, you enter the motor speed value (the values used in pitches.h for the main program) and make sure it sounds as you want it. Serial Stepper is the same as Tune Stepper, but instead of inputting the motor speed value, you put in the MIDI note number. Of course, these are for testing and troubleshooting so you don't really need to use them unless you are having issues with the main program, or are using a different motor from a NEMA 17.

Image
Image

JonJonKayne

2 years ago

make sure you are wired up properly and that the pin assignments are correct. If it isn't making any sounds then the motors might not be enabled. (I believe the enable pin needs to be pulled low) I have a feeling you might want to make sure that you understand the circuit and code and make sure everything is wired up properly and pin assignments are correct. Other then that, I have no clue.

Image
Image

JonJonKayne

2 years ago

So to answer your questions: 1. MIDI Performance supports up to 127 channels if I am not mistaken. If you look at the code, all you need to do is define the appropriate IO (#define stepPin # and pinMode(stepPin, OUTPUT); ) the array size, and call singleStep in the main loop. Let's say you want to have 10 stepper motors, The code would look like this: #define stepPin_M1 2 #define stepPin_M2 3 ..... #define stepPin_M10 11 unsigned long motorSpeeds[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; //eleven zeros unsigned long prevStepMicros[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; pinMode(stepPin_M1, OUTPUT); ... pinMode(stepPin_M10, OUTPUT); singleStep(1, stepPin_M1); .... singleStep(10, stepPin_M10); Hope that helps with that. 2. Unfortunately, as soon as a motor turns, the drivers are enabled and current is supplied, even when in idle. I usually press the reset button on the arduino as soon as I am done playing a song or when the motors are in idle for long periods on time. You might want to ensure that your current is set correctly on the driver. For me, I set VREF to 0.65V. You do this by measuring the voltage between ground and the SMD Pot on the A4988. Use an alligator clip to connect your multimeter probe to a screwdriver. I will note that these stepper motors can usually handle higher temperatures than "hot to the touch". They can handle temps above 100C, so you don't have to worry unless you are being burnt by your stepper motors. It should be noted that you should NEVER run a stepper driver without a motor attached, as it can damage the driver. All this being said, I was actually planning on adding a timeout to the motors so that they disable after being idle for a certain period of time. That is a challenge within itself, but I might figure it out and add to V2. 3. I added a folder on GitHub called MIDI files, where I will add the MIDI to all the songs I feature. I create these in a program called "MuseScore 2" (free and open source) then import the MIDI file into Ableton Live 9 and assign each voice to its own MIDI channel. Hope that helps!

Image
Image

Anonymous user

2 years ago

Stepper Test code result was tested in motor has confirmed that it works correctly. However, it is not possible to find the correct value in Tune Stepper. I could confirm the MIDI signal from arduino. Probably the motor specification you are using is different. So I can not TUNE well. motor spec; http://akizukidenshi.com/download/ds/mercurymotor/SM-42BYG011-25.pdf Continue to help

Image
Image

Anonymous user

2 years ago

Postscript Everyone's interest rises if you can perfectly play the song(Only my rail gun) in Japan

Image
Image

Anonymous user

2 years ago

I will report it. Since tuning relation does not react when entering a numerical value with a serial monitor, it was confirmed that a sound is output by directly entering a numerical value. I have a few questions. ① Does MIDI performance only support up to 4 channels? ② Motor / motor driver during playing is very hot. It gets hot enough to the touch. ③ I want you to share the sample MIDI file

Image
Image

Anonymous user

2 years ago

It was confirmed that the correct sound comes out!>ω< THANKS! I have this motor could be beautiful to play. http://amzn.asia/i5BkEGW It is necessary to mention one additional question. Do you need a 12 V 20 A power supply with 10 stepping motors?

Image
Image

Anonymous user

2 years ago

Hi! I am building this stepper synth for a school project, and your page has been very helpful. I was able to reflash the Arduino using MocuLUFA and it shows up in the device manager as MIDI Stepper. I seem to be having a problem actually sending MIDI data to the arduino. I downloaded Musescore and adjusted the I/O preferences as you said to someone else in the comments. I also made sure that the MIDI jack icon on the main screen is highlighted and assigned each staff to a midi channel. From there do I just need to press play, or is there something else to do? Alternatively, I tried using a MIDI file from the folder you provided, but it just opens in Windows Media Player and plays audio over my latop speakers. I can't seem to figure out how to direct the computer to send the file to the usb port. I would greatly appreciate any advice you have for this!

Image
Image

Anonymous user

2 years ago

Hello! currently at ASU for EE, and an avid musician myself. I have built your machine utilizing the midi din. I can use the serial stepper to play notes on all 4 motors after changing the "0" to a "1" here while(Serial.available() > 1) //taking in the speed value also, in MIDI_Stepper_V1.ino I enable the serial port 115200. With that enabled, I have a midi out connected to a piano, and a midi in connected to the midi din. I can view the serial port and can see the data coming from the piano into the RX port on the arduino, but the motors do nothing. I also have a midi connected to fruity loops output. When I play a song, I can see the data in the serial viewer 115200, but nothing goes to the motors. I think one issue could be, I originally tried using the arduino as the midi device, but I reverted everything back to try and make it a normal arduino again. do I need to update the hex file again? Any help would me much appreciated. I'm so close I can almost hear an 8-bit soundtrack.

Image
Image

Anonymous user

2 years ago

I have found the culprit. I used a midi din and was using the 115200 baud rate, but midi is 31250. for anyone having an issue of connection, use this in your MIDI_Stepper_V1 void setup. instead of this: Serial.begin(115200); //allows for serial MIDI communication, comment out if using HIDUINO or LUFA use: Serial.begin(31250); //allows for serial MIDI communication, comment out if using HIDUINO or LUFA

Image
Image

Anonymous user

2 years ago

I wound up getting the CNC Shield, working on making sure its not my wiring.

Image
Image

sammvths

2 years ago

How do you deal with chords in MIDI files or when two or more notes are sent to the controller at the same time on the same channel? I have created my own custom software for opening and uploading MIDI files to an Arduino that can then convert the notes to frequencies and play them on motors. Do you deal with chords by pre-parsing the MIDI files or by parsing the chords into notes on multiple motors at the microcontroller level?

Image
Image

JonJonKayne

2 years ago

When I want to do a chord, I split it along the 4 channels. There is a tool in MuseScore called "Explode" that does it for me. So for example if I had a C-major triad (CEG) then channel 1 would play C, channel 2 would play E and channel 3 would play the G.

Image
Image

Anonymous user

2 years ago

I have to admit, I had no idea what you were building until I watched the video. This is really cool! Thanks for sharing.

Image
Image

Anonymous user

2 years ago

I introduce you a very similar project. https://www.hackster.io/45036/making-music-using-a-step-motor-01f8e6

Image
Image

Anonymous user

2 years ago

Nice to meet you, my name is Masa. Currently, I am making a machine by referring to this article. However, although the sound is produced, it often makes a sound or movement as if the stepping motor is stepping out. I haven't changed the characters in the program. Should I change the value in the pitches.h file? The motor used is 17HS4401S. Also, I saw the YouTube video, and I feel that the rotation speed of the motor is faster than my own. Is the rotation speed changed? If it's better to change it, could you please tell me where and what value to use? Thank you.

Image
Image

Studioguard

2 years ago

Great stuff, but for sound enhancement use piezo pickups with bluetack on each stepper, then you can even mix, amplify and put effects on it :) Several years ago I did a similar thing with my CNC mill, not with MIDI but with vector graphics I drew and milled without the milling motor being switched on. Thanks for sharing!

Image
Image

Anonymous user

2 years ago

Hello, When I run Serial Stepper and Tune Stepper , Motor can not run. But thr Motor can run with Stepper Test. Thanks for your sharing and I hope you can help me.

Image
Image

Anonymous user

2 years ago

I came across the issue today. It took a while to get to the bottom of this. The solution is "No line ending" in the serial monitor. Anything else and the serial buffer will keep an extra 0. It then presents it the next time around loop; which results in halting it. Thanks JK for the project. I'm enjoying it so far. I personally marked this as a comment in the code, as one tends to forget these findings 'next time' round ; )

Image
Image

Anonymous user

2 years ago

I had a similar issue. Stepper Test worked fine, however, the Tune_Stepper.ino did not work. When I input a 2000 value into the serial window this is what I'd get back. 14:42:39.297 -> Please Enter a Stepper Motor Speed Value. 14:42:56.036 -> Stepper Motor Speed set to: 2000 14:42:56.103 -> 14:42:56.103 -> Please Enter a Stepper Motor Speed Value. 14:42:57.054 -> Stepper Motor Speed set to: 0 14:42:57.089 -> 14:42:57.089 -> Please Enter a Stepper Motor Speed Value. No motor function. I was able to get it to work by changing line 45 from this: while(Serial.available() > 0) //taking in the speed value to this: while(Serial.available() > 1) //taking in the speed value. Changing the value from 0 to 1 allowed me to input a value that that be passed on to the motor. However, I'm a bit confused because a higher numerical value results in lower speed and tone. Since it is referred to as a speed number I expected the reverse. The higher the number the faster the speed. Maybe someone could answer that for me.

Image
Image

Anonymous user

2 years ago

I’m having some trouble actually sending MIDI data to the Arduino. I flashed mocaLUFA onto the chip, and the Arduino appears in the device manager as a MIDI device. What next?

Image
Image

JonJonKayne

2 years ago

Hi Peyton, Now that your device is seen as a MIDI device, you simply need to send MIDI data to it. There are a plethora of programs capable of doing this, and they are all (usually) music programs. I use Ableton Live 9, but I also know that MuseScore 2 works too. MuseScore is free and open source, so it would probably be your best bet. That's actually what I use to make the MIDI files for the Synth. You just assign a staff to each of the MIDI channels, and press play!

Image
Image

JonJonKayne

2 years ago

Peyton, It shouldn't show up specifically as a MIDI input or output, only as a MIDI device (called MIDI Stepper Synth). Like I said before, you need an application that can send the MIDI data out such as MuseScore. In MuseScore, go to Edit>Preferences, then select "I/O". Set the MIDI Output device to MIDI Stepper Synth and click Apply. There is an Icon in the main screen that looks like a MIDI connector that you will want to make sure is enabled. when you play back MIDI, the stepper will play too. If it isn't playing, check the Arduino and see if the Serial LED is flashing as data is being sent over.

Image
Image

Anonymous user

2 years ago

The device doesn’t seem to be recognized as a MIDI output. If appears in the device manager, but that’s it. I can’t figure out how to set it so that the computer sends the midi data to it.

Image
Image

Anonymous user

2 years ago

How can I reduce the number of motors from 4 to 3?

Image
Image

Anonymous user

2 years ago

Such a great project, Jonathan! I take it this would work with a turntable (vinyl records) motor? Just a matter of commenting out the unwanted 3 extra motors in the script etc?

Image
Image

Anonymous user

2 years ago

Ingenious. Great use of arrays too!

Image
Image

Anonymous user

2 years ago

Ok so after a couple of weeks working on this in my spare time I have gotten this thing to work with the arduino mega with the ramps 1.4 shield. I have gotten it to play all the midis in the folder, But I am having trouble with when the notes stop on the stepper track it sounds like it is killing a cat when its supposed to not be playing any note on that channel. I was wondering if there is a code I did not fill out to make them shut up when they are supposed to be quiet

Image
Image

Anonymous user

2 years ago

I found the problem I accidentally Had the motor speed set to 2 instead of 0. Now I just need to find out why the steppers BEEP when they play the first note. I have noticed in the video The steppers do the same thing on Totos Africa But if anyone needs the pin layout for ramps v1.4 here it is. Arduino mega 2560 with Ramps V1.4 Pin layout Motor Step Dir En X 54 55 38 Y 60 61 56 Z 46 48 62 E0 26 28 24 E1 36 34 30

Image
Image

Anonymous user

2 years ago

Hey, I am super new to arduino wiring and coding and have a couple of questions: 1. In the simple breadboard wiring, the orange wire, that runs from the 12v power input to the steppers, how is it connected? Are those single wires jumping from stepper to stepper and the last one to the input or are those individual wires all going from each stepper to the imput and are somehow all connected their? 2. I have been trying to understand the simple stepper test code and am trying to run all 4 steppers individually by just inputing a set amoutn of steps. Can i just copy over the entire code from the setup to the bottom at the end of the code 3 times? Help would be super appreciated! Carl

Image
Image

JonJonKayne

2 years ago

Hi Carl, The A4988 has two pins that get the power for the motors (VMOT and GND). You would want to make sure each driver gets the 12V that way. If you look up A4988 wiring you should see how to wire everything. The Test Stepper code simply moves the stepper a certain amount clockwise then counterclockwise. Basically, when you make the step pin on the A4988 driver go from low to high, the stepper motor will move one "step". In the default setting this is exactly 1/200th of a revolution or 1.8 degrees. If you want to make it work for more than one motor simultaneously, define more step and direction pins and then duplicate the digitalWrite() for each of the step pins. I put some comments to show where to modify the code below. It might be a good idea to check out this video as it will give you a better understanding of stepper motors: https://www.youtube.com/watch?v=5CmjB4WF5XA

Image
Image

JonJonKayne

2 years ago

#define stepPin 2 #define dirPin 5 #define enPin 8 // DEFINE THE OTHER STEP, DIR, and EN pins const int Time_1 = 5000; const int Time_2 = 5000; const int step_1 = 200; const int step_2 = 200; void setup() { pinMode(stepPin, OUTPUT); pinMode(dirPin, OUTPUT); pinMode(enPin, OUTPUT); digitalWrite(enPin, LOW); //DUPLICATE THE ABOVE 4 LINES FOR EACH MOTOR } void loop() { digitalWrite(dirPin, HIGH); // DUPLICATE FOR THE OTHER MOTORS for (int i = 0; i < step_1; i++) { digitalWrite(stepPin, HIGH); // DUPLICATE FOR THE OTHER MOTORS //delayMicroseconds(Time_1); digitalWrite(stepPin, LOW); // DUPLICATE FOR THE OTHER MOTORS delayMicroseconds(Time_1); } delayMicroseconds(2000); digitalWrite(dirPin, LOW); // DUPLICATE FOR THE OTHER MOTORS for (int i = 0; i < step_2; i++) { digitalWrite(stepPin, HIGH); // DUPLICATE FOR THE OTHER MOTORS //delayMicroseconds(Time_2); digitalWrite(stepPin, LOW); // DUPLICATE FOR THE OTHER MOTORS delayMicroseconds(Time_2); } digitalWrite(enPin, HIGH); // DUPLICATE FOR THE OTHER MOTORS while(1); //stop loop } Hope that helps! -Jonathan

Image
Image

Anonymous user

2 years ago

Hi THis is Cool.. I am not a Programmer. but I had a Favorite Horn thats not available now.. https://www.youtube.com/watch?v=TcLO76OQLq8 I Wished if ESP-12 D1 Mini V2 Board ESP-12F ESP8266 WEMOS ESP8266 D1 Pro mini-16 https://robu.in/product/d1-tf-module-tf-card-expansion-board/ Espressif System’s ESP8266 WROOM-02 Wi-Fi module (with 4Mb flash) CJMCU-4051 74HC4051 8 Channel Analog Multiplexer/Demultiplexer Breakout Board for Arduino https://robu.in/product/cjmcu-4051-74hc4051-8-channel-analog-multiplexerdemultiplexer-sensor-module-breakout-board-arduino/ can be used to Generate HIGH TONE : 500Hz MID TONE : 480Hz LOW TONE : 420Hz and be able to Adjust the HT MT and LT Frequencies Switch to 2 tone or 3 tone Change the Fading delay Change the Delay Time Change the Pattern Change the Waveform Width Change Saw to Triangle Assign HT MT and LT to any of the Parameters through the Mobile and set a Default for ever unless we select. with https://robu.in/product/waveshare-pico-1-14-inch-lcd-display-module/ i know this can be done but Im not a Programmer. the 3 d1 analogue outputs can be sent to a 60w Amplifier i am a Power Circuits Designer im good at IGBT type Power Circuits. Can you Please Help ME ? im rajivd1@gmail.com and +91 815 000 2222 on whatsapp. Please

Image
Image

Anonymous user

4 years ago

How can I reduce the number of motors from 4 to 3?

Image
Image

Anonymous user

4 years ago

Nice to meet you, my name is Masa. Currently, I am making a machine by referring to this article. However, although the sound is produced, it often makes a sound or movement as if the stepping motor is stepping out. I haven't changed the characters in the program. Should I change the value in the pitches.h file? The motor used is 17HS4401S. Also, I saw the YouTube video, and I feel that the rotation speed of the motor is faster than my own. Is the rotation speed changed? If it's better to change it, could you please tell me where and what value to use? Thank you.

Image
Image

Anonymous user

4 years ago

Hello! currently at ASU for EE, and an avid musician myself. I have built your machine utilizing the midi din. I can use the serial stepper to play notes on all 4 motors after changing the "0" to a "1" here while(Serial.available() > 1) //taking in the speed value also, in MIDI_Stepper_V1.ino I enable the serial port 115200. With that enabled, I have a midi out connected to a piano, and a midi in connected to the midi din. I can view the serial port and can see the data coming from the piano into the RX port on the arduino, but the motors do nothing. I also have a midi connected to fruity loops output. When I play a song, I can see the data in the serial viewer 115200, but nothing goes to the motors. I think one issue could be, I originally tried using the arduino as the midi device, but I reverted everything back to try and make it a normal arduino again. do I need to update the hex file again? Any help would me much appreciated. I'm so close I can almost hear an 8-bit soundtrack.

Image
Image

Anonymous user

2 years ago

I have found the culprit. I used a midi din and was using the 115200 baud rate, but midi is 31250. for anyone having an issue of connection, use this in your MIDI_Stepper_V1 void setup. instead of this: Serial.begin(115200); //allows for serial MIDI communication, comment out if using HIDUINO or LUFA use: Serial.begin(31250); //allows for serial MIDI communication, comment out if using HIDUINO or LUFA

Image
Image

Anonymous user

2 years ago

I wound up getting the CNC Shield, working on making sure its not my wiring.

Image
Image

Anonymous user

4 years ago

Hey, I am super new to arduino wiring and coding and have a couple of questions: 1. In the simple breadboard wiring, the orange wire, that runs from the 12v power input to the steppers, how is it connected? Are those single wires jumping from stepper to stepper and the last one to the input or are those individual wires all going from each stepper to the imput and are somehow all connected their? 2. I have been trying to understand the simple stepper test code and am trying to run all 4 steppers individually by just inputing a set amoutn of steps. Can i just copy over the entire code from the setup to the bottom at the end of the code 3 times? Help would be super appreciated! Carl

Image
Image

JonJonKayne

2 years ago

Hi Carl, The A4988 has two pins that get the power for the motors (VMOT and GND). You would want to make sure each driver gets the 12V that way. If you look up A4988 wiring you should see how to wire everything. The Test Stepper code simply moves the stepper a certain amount clockwise then counterclockwise. Basically, when you make the step pin on the A4988 driver go from low to high, the stepper motor will move one "step". In the default setting this is exactly 1/200th of a revolution or 1.8 degrees. If you want to make it work for more than one motor simultaneously, define more step and direction pins and then duplicate the digitalWrite() for each of the step pins. I put some comments to show where to modify the code below. It might be a good idea to check out this video as it will give you a better understanding of stepper motors: https://www.youtube.com/watch?v=5CmjB4WF5XA

Image
Image

JonJonKayne

2 years ago

#define stepPin 2 #define dirPin 5 #define enPin 8 // DEFINE THE OTHER STEP, DIR, and EN pins const int Time_1 = 5000; const int Time_2 = 5000; const int step_1 = 200; const int step_2 = 200; void setup() { pinMode(stepPin, OUTPUT); pinMode(dirPin, OUTPUT); pinMode(enPin, OUTPUT); digitalWrite(enPin, LOW); //DUPLICATE THE ABOVE 4 LINES FOR EACH MOTOR } void loop() { digitalWrite(dirPin, HIGH); // DUPLICATE FOR THE OTHER MOTORS for (int i = 0; i < step_1; i++) { digitalWrite(stepPin, HIGH); // DUPLICATE FOR THE OTHER MOTORS //delayMicroseconds(Time_1); digitalWrite(stepPin, LOW); // DUPLICATE FOR THE OTHER MOTORS delayMicroseconds(Time_1); } delayMicroseconds(2000); digitalWrite(dirPin, LOW); // DUPLICATE FOR THE OTHER MOTORS for (int i = 0; i < step_2; i++) { digitalWrite(stepPin, HIGH); // DUPLICATE FOR THE OTHER MOTORS //delayMicroseconds(Time_2); digitalWrite(stepPin, LOW); // DUPLICATE FOR THE OTHER MOTORS delayMicroseconds(Time_2); } digitalWrite(enPin, HIGH); // DUPLICATE FOR THE OTHER MOTORS while(1); //stop loop } Hope that helps! -Jonathan

Image
Image

sammvths

5 years ago

How do you deal with chords in MIDI files or when two or more notes are sent to the controller at the same time on the same channel? I have created my own custom software for opening and uploading MIDI files to an Arduino that can then convert the notes to frequencies and play them on motors. Do you deal with chords by pre-parsing the MIDI files or by parsing the chords into notes on multiple motors at the microcontroller level?

Image
Image

JonJonKayne

2 years ago

When I want to do a chord, I split it along the 4 channels. There is a tool in MuseScore called "Explode" that does it for me. So for example if I had a C-major triad (CEG) then channel 1 would play C, channel 2 would play E and channel 3 would play the G.

Image
Image

HAMMERHEAD85

6 years ago

Ok so after a couple of weeks working on this in my spare time I have gotten this thing to work with the arduino mega with the ramps 1.4 shield. I have gotten it to play all the midis in the folder, But I am having trouble with when the notes stop on the stepper track it sounds like it is killing a cat when its supposed to not be playing any note on that channel. I was wondering if there is a code I did not fill out to make them shut up when they are supposed to be quiet

Image
Image

HAMMERHEAD85

2 years ago

I found the problem I accidentally Had the motor speed set to 2 instead of 0. Now I just need to find out why the steppers BEEP when they play the first note. I have noticed in the video The steppers do the same thing on Totos Africa But if anyone needs the pin layout for ramps v1.4 here it is. Arduino mega 2560 with Ramps V1.4 Pin layout Motor Step Dir En X 54 55 38 Y 60 61 56 Z 46 48 62 E0 26 28 24 E1 36 34 30

Image
Image

Anonymous user

6 years ago

Hi! I am building this stepper synth for a school project, and your page has been very helpful. I was able to reflash the Arduino using MocuLUFA and it shows up in the device manager as MIDI Stepper. I seem to be having a problem actually sending MIDI data to the arduino. I downloaded Musescore and adjusted the I/O preferences as you said to someone else in the comments. I also made sure that the MIDI jack icon on the main screen is highlighted and assigned each staff to a midi channel. From there do I just need to press play, or is there something else to do? Alternatively, I tried using a MIDI file from the folder you provided, but it just opens in Windows Media Player and plays audio over my latop speakers. I can't seem to figure out how to direct the computer to send the file to the usb port. I would greatly appreciate any advice you have for this!

Image
Image

Anonymous user

6 years ago

Hello, When I run Serial Stepper and Tune Stepper , Motor can not run. But thr Motor can run with Stepper Test. Thanks for your sharing and I hope you can help me.

Image
Image

srwilson58

2 years ago

I had a similar issue. Stepper Test worked fine, however, the Tune_Stepper.ino did not work. When I input a 2000 value into the serial window this is what I'd get back. 14:42:39.297 -> Please Enter a Stepper Motor Speed Value. 14:42:56.036 -> Stepper Motor Speed set to: 2000 14:42:56.103 -> 14:42:56.103 -> Please Enter a Stepper Motor Speed Value. 14:42:57.054 -> Stepper Motor Speed set to: 0 14:42:57.089 -> 14:42:57.089 -> Please Enter a Stepper Motor Speed Value. No motor function. I was able to get it to work by changing line 45 from this: while(Serial.available() > 0) //taking in the speed value to this: while(Serial.available() > 1) //taking in the speed value. Changing the value from 0 to 1 allowed me to input a value that that be passed on to the motor. However, I'm a bit confused because a higher numerical value results in lower speed and tone. Since it is referred to as a speed number I expected the reverse. The higher the number the faster the speed. Maybe someone could answer that for me.

Image
Image

Anonymous user

2 years ago

I came across the issue today. It took a while to get to the bottom of this. The solution is "No line ending" in the serial monitor. Anything else and the serial buffer will keep an extra 0. It then presents it the next time around loop; which results in halting it. Thanks JK for the project. I'm enjoying it so far. I personally marked this as a comment in the code, as one tends to forget these findings 'next time' round ; )

Image
Image

Anonymous user

7 years ago

Such a great project, Jonathan! I take it this would work with a turntable (vinyl records) motor? Just a matter of commenting out the unwanted 3 extra motors in the script etc?

Image
Image

Studioguard

7 years ago

Great stuff, but for sound enhancement use piezo pickups with bluetack on each stepper, then you can even mix, amplify and put effects on it :) Several years ago I did a similar thing with my CNC mill, not with MIDI but with vector graphics I drew and milled without the milling motor being switched on. Thanks for sharing!

Image
Image

Anonymous user

7 years ago

I’m having some trouble actually sending MIDI data to the Arduino. I flashed mocaLUFA onto the chip, and the Arduino appears in the device manager as a MIDI device. What next?

Image
Image

JonJonKayne

2 years ago

Hi Peyton, Now that your device is seen as a MIDI device, you simply need to send MIDI data to it. There are a plethora of programs capable of doing this, and they are all (usually) music programs. I use Ableton Live 9, but I also know that MuseScore 2 works too. MuseScore is free and open source, so it would probably be your best bet. That's actually what I use to make the MIDI files for the Synth. You just assign a staff to each of the MIDI channels, and press play!

Image
Image

JonJonKayne

2 years ago

Peyton, It shouldn't show up specifically as a MIDI input or output, only as a MIDI device (called MIDI Stepper Synth). Like I said before, you need an application that can send the MIDI data out such as MuseScore. In MuseScore, go to Edit>Preferences, then select "I/O". Set the MIDI Output device to MIDI Stepper Synth and click Apply. There is an Icon in the main screen that looks like a MIDI connector that you will want to make sure is enabled. when you play back MIDI, the stepper will play too. If it isn't playing, check the Arduino and see if the Serial LED is flashing as data is being sent over.

Image
Image

Anonymous user

2 years ago

The device doesn’t seem to be recognized as a MIDI output. If appears in the device manager, but that’s it. I can’t figure out how to set it so that the computer sends the midi data to it.

Image
Image

Anonymous user

7 years ago

Are other settings necessary? The motor does not move. Help me

Image
Image

Anonymous user

2 years ago

The enable pin is connected directly with a jumper. Really in all the tests nothing happened. I will try to disable the enable physically and let the code activate it.

Image
Image

JonJonKayne

2 years ago

So to answer your questions: 1. MIDI Performance supports up to 127 channels if I am not mistaken. If you look at the code, all you need to do is define the appropriate IO (#define stepPin # and pinMode(stepPin, OUTPUT); ) the array size, and call singleStep in the main loop. Let's say you want to have 10 stepper motors, The code would look like this: #define stepPin_M1 2 #define stepPin_M2 3 ..... #define stepPin_M10 11 unsigned long motorSpeeds[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; //eleven zeros unsigned long prevStepMicros[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; pinMode(stepPin_M1, OUTPUT); ... pinMode(stepPin_M10, OUTPUT); singleStep(1, stepPin_M1); .... singleStep(10, stepPin_M10); Hope that helps with that. 2. Unfortunately, as soon as a motor turns, the drivers are enabled and current is supplied, even when in idle. I usually press the reset button on the arduino as soon as I am done playing a song or when the motors are in idle for long periods on time. You might want to ensure that your current is set correctly on the driver. For me, I set VREF to 0.65V. You do this by measuring the voltage between ground and the SMD Pot on the A4988. Use an alligator clip to connect your multimeter probe to a screwdriver. I will note that these stepper motors can usually handle higher temperatures than "hot to the touch". They can handle temps above 100C, so you don't have to worry unless you are being burnt by your stepper motors. It should be noted that you should NEVER run a stepper driver without a motor attached, as it can damage the driver. All this being said, I was actually planning on adding a timeout to the motors so that they disable after being idle for a certain period of time. That is a challenge within itself, but I might figure it out and add to V2. 3. I added a folder on GitHub called MIDI files, where I will add the MIDI to all the songs I feature. I create these in a program called "MuseScore 2" (free and open source) then import the MIDI file into Ableton Live 9 and assign each voice to its own MIDI channel. Hope that helps!

Image
Image

JonJonKayne

2 years ago

Are you using the serial monitor? Those codes are purely for testing the tone playback of the stepper motors. In Tune Stepper, you enter the motor speed value (the values used in pitches.h for the main program) and make sure it sounds as you want it. Serial Stepper is the same as Tune Stepper, but instead of inputting the motor speed value, you put in the MIDI note number. Of course, these are for testing and troubleshooting so you don't really need to use them unless you are having issues with the main program, or are using a different motor from a NEMA 17.

Image
Image

JonJonKayne

2 years ago

What you need to make sure is that the step pin is being pulsed by the arduino. If there isn't a step signal getting to the A4988 it will not spin. Unfortunately I am not able to see everything in your setup so I have absolutely no way to give you a straight up fix. My only recommendation is to use troubleshooting techniques and make sure you understand what the code is doing. read through the explanation and make sure you understand it and that you wired everything exactly is specified. If it doesn't work properly then you either didn't follow the configuration or something is broken.

Image
Image

JonJonKayne

2 years ago

make sure you are wired up properly and that the pin assignments are correct. If it isn't making any sounds then the motors might not be enabled. (I believe the enable pin needs to be pulled low) I have a feeling you might want to make sure that you understand the circuit and code and make sure everything is wired up properly and pin assignments are correct. Other then that, I have no clue.

Image
Image

JonJonKayne

2 years ago

Glad to hear that it's working! Yes, I do believe 12V 20A would be sufficient to drive 10 stepper motors. I assume that each motor draws 1.5A. They probably draw less since they don't have any load on then, but better to have more current than not enough...

Image
Image

JonJonKayne

2 years ago

Try running the Stepper Test code that I have on my GitHub. I just added it. I have a few test codes that help troubleshoot the setup. - Stepper Test simply spins a single stepper. If it doesn't work, there is a wiring issue. - Tune Stepper ensures that entering a MIDI note plays the correct sound. If all the test code works, then the actual code should work fine. It could also be due to your method of sending MIDI to the arduino. If you don't have mocuLUFA flashed onto the Arduino, then you need to have serial enabled and use the loopMIDI and hairlessMIDI to communicate. Hope that helps!

Image
Image

Anonymous user

2 years ago

I managed to find the problem, but I still haven't been able to solve it. For some reason "motorSpeed ​​= pitchVals [midiNote]" is 0. I did a test with tone () and another list of pitches.h and it worked perfectly. it seems that the code is not correctly interpreting this pithes.h and cannot find the note I send. so motorSpeed ​​= 0. Do you have any idea what it might be?

Image
Image

JonJonKayne

2 years ago

The speed that the stepper is tuned to shouldn't be motor specific. If you use tone(stepPin, 440) you should get an A440 note. What I am essentially saying is that the pitch values in pitches.h are the note periods in microseconds. Try using a number from the pitches.h file. Also, you could run the MIDI Serial Test (Serial_Stepper.ino) and see if that produces a sound. The difference between the TuneStepper and SerialStepper is that one takes a speed and the other takes the actual MIDI note. So Speed value 2273 should give you an A4 (440 Hz), MIDI note 69. I also found that my pitches.h was an outdated version in the test code, so I have updated it on the GitHub.

Image
Image

Anonymous user

2 years ago

Stepper Test code result was tested in motor has confirmed that it works correctly. However, it is not possible to find the correct value in Tune Stepper. I could confirm the MIDI signal from arduino. Probably the motor specification you are using is different. So I can not TUNE well. motor spec; http://akizukidenshi.com/download/ds/mercurymotor/SM-42BYG011-25.pdf Continue to help

Image
Image

Anonymous user

2 years ago

I will report it. Since tuning relation does not react when entering a numerical value with a serial monitor, it was confirmed that a sound is output by directly entering a numerical value. I have a few questions. ① Does MIDI performance only support up to 4 channels? ② Motor / motor driver during playing is very hot. It gets hot enough to the touch. ③ I want you to share the sample MIDI file

Image
Image

Anonymous user

2 years ago

Postscript Everyone's interest rises if you can perfectly play the song(Only my rail gun) in Japan

Image
Image

Anonymous user

2 years ago

It was confirmed that the correct sound comes out!>ω< THANKS! I have this motor could be beautiful to play. http://amzn.asia/i5BkEGW It is necessary to mention one additional question. Do you need a 12 V 20 A power supply with 10 stepping motors?

Image
Image

Anonymous user

2 years ago

I did the test by letting the code activate enable and it still didn't work. In fact, I inform the note on the serial monitor, the code is executed, the note recognizes the motor speed, then the message is repeated with note and speed RESET and the motor simply does not respond. I would love to make them work, I have an interesting project that depends on it.

Image
Image

Anonymous user

2 years ago

I have the same problem that you reported, testing the stepper motor everything works fine. however, in the tune stepper and the serial stepper nothing happens. Could you explain to me what you did to resolve it?

Image
Image

Anonymous user

7 years ago

Ingenious. Great use of arrays too!

Image
Image

Anonymous user

7 years ago

I have to admit, I had no idea what you were building until I watched the video. This is really cool! Thanks for sharing.

Image
Image

Anonymous user

2 years ago

I introduce you a very similar project. https://www.hackster.io/45036/making-music-using-a-step-motor-01f8e6