I am using an Arduino Zero, along with a TB6600 to drive a NEMA 17 stepper motor, to drive a pulley / belt. When I run the code below, without anything attached to the pulley, there is some slight pausing / reversing. However when I attach a belt to the pulley, the motor rotates somewhat slower, and a bit more erratically (more pausing / reversing).
Here's a video to demonstrate:
If it's not clear from the video, this stuttering seems to result in about a 30% slowdown in rotation. (1.09 seconds per revolution under load compared to 0.69 (nice) seconds per revolution when not under load).
Here is the code I am using:
// Define stepper motor connections:
#define dirPin 2
#define stepPin 5
void setup() {
// Declare pins as output:
pinMode(stepPin, OUTPUT);
pinMode(dirPin, OUTPUT);
// Set the spinning direction CW/CCW:
digitalWrite(dirPin, HIGH);
}
void loop() {
// These four lines result in 1 step:
digitalWrite(stepPin, HIGH);
delayMicroseconds(483);
digitalWrite(stepPin, LOW);
delayMicroseconds(483);
}
This is lightly modified sample code which I've changed the number of microseconds from 500. Testing with a loose binary search between 200 - 800, this was the value that seems to produce the most smooth operation, other values (even 10-20 less) would decrease total revolution speed by 30% or more just due to erratic direction changing.
Here are my questions:
1. Does anyone know why this direction changing is happening? Are there changes in design that you would suggest to deliver power more efficiently? (Next step in the project is to attack the pulley to curtains, so that the arduino can close / open the curtains.)
2. Do these values for delay make sense? Is there a more straightforward way to calculate what the timing should be? I have only ever kept the delays after high and low as the same value, should those be differentiated? A quick google search of "delayMicroseconds(483);" shows a number of results (in Chinese) which happen to use that as a value as well, which may not be a coincidence.
A copy of the spec sheet for the specific NEMA 17 stepper I'm using is here: https://www.mybotonline.com/download/17HS15-1704S.pdf
Additional requested info:
Pictures of the TB6600 switch diagram, and my current settings should be attached. I have the "microstep" "pulse/rev" set to 4 / 800 respectively, and the current set to 1.5A. (1.5A I believe I pulled from the datasheet of the motor, 4/800 was chosen just via trial and error with many settings to get the motor to spin at all, as otherwise it would just vibrate, although I haven't done exhaustive testing between different pulse settings and different timings).