jzkmath / Arduino-MIDI-Stepper-Motor-Instrument

This is an Arduino Project that uses A4988 stepper drivers with bipolar stepper motors along with the MIDI library to create sound.
GNU General Public License v3.0
79 stars 6 forks source link

General questions about this project #4

Open EpicLPer opened 3 years ago

EpicLPer commented 3 years ago

Heya!

As a first note, this isn't really an issue or anything related to this project per-se, tho thought you may have a bit more knowledge with these things and may be able to help me. It may even help others who are searching for the exact same solutions, don't know.

Here's an example video of what I'm describing below, it works but doesn't 100% satisfy me: https://twitter.com/epiclper/status/1407823499838767109?s=21

I've built myself a little stepper rig now too including the 3D printed mounts and everything, however I simply can't get all the notes to play perfectly fine. At some points it just "jerks" back and forth but isn't able to make a full proper step, but 2 or 3 notes lower/higher works fine again. My stepper drivers have little potentiometers to adjust the voltage (or amperage?) which I can somewhat fix some notes with, but ultimately will "destroy" other notes that played well before.
Is there any trick to get the whole note range to work flawlessly? I've tried 4 different AC adapters already and some yield better results than others, also tried a 24 Volt one but this only made it worse. I also made sure to use thick enough power wires, the first ones I tried got a little hot ;)

Second, is it normal for the motors to make a high pitched whining noise before the proper note starts playing? It sounds almost as if it tries to "start running", can't quite make it and then a few milliseconds later springs into life and works correctly. Is this just down to bad drivers or bad motors?

Thanks already for helping!

alana314 commented 3 years ago

Try putting a jumper on the M0 pins below each A4998 on the CNC shield. That puts it into half step mode. We found that microstepping is less likely for the motors to stall. (Sixteenth steps were the smoothest, but quietest.) https://www.zyltech.com/arduino-cnc-shield-instructions/
We also get the high pitched noises and find that they work the best when a note is held for at least a second.

alana314 commented 3 years ago

I'm actually still running into this too after a delay of about 20 minutes. It doesn't happen when I first power on the unit but once it sits idle for a while the motors squeal when I play a note and have a hard time moving. Resetting with the button on the CNC shield works, but a software reset (resetFunc) doesn't, so I can't use a watchdog timer. No number of microstepping seems to help. I tried ramping up the motors before singleStep() with something like this:

for(int i = 30; i > 7; i--) //ramp up the motor with 30ms pulses up to 7ms
      {
        delay(i);
        digitalWrite(stepPin_M1, HIGH);
        digitalWrite(stepPin_M1, LOW);
      }

but it doesn't seem to help. For now, the arduino is on an external motion sensor outlet that resets it ok enough for my purposes (art installation).

alana314 commented 3 years ago

The only way I found to fix this was to do a hardware reset every 30 seconds when idle using the reset pin, like this: https://arduinogetstarted.com/faq/how-to-reset-arduino-by-programming

PoleTransformer commented 2 years ago

I found a solution to this problem. Simply change line 108 in MIDI_Stepper_V1.ino to prevStepMicros[motorNum] = micros();.

alana314 commented 2 years ago

@WayneSeng thanks so much! Still testing this but it appears to be working.