I have been following this tutorial using the same hardware, TB6600 driver, 42HS48-1704A (yes I think its supposed to be 42hs40 but thats not what it says the sticker) stepper but am controlling via a Nano.
The code,
const int stepPin = 5;
const int dirPin = 2;
const int enPin = 8;
int num_steps = 200;
int dt = 1000;
void setup() {
pinMode(stepPin, OUTPUT);
pinMode(dirPin, OUTPUT);
pinMode(enPin, OUTPUT);
digitalWrite(enPin, LOW);
}
void loop() {
digitalWrite(dirPin, HIGH); // Enables the motor to move in a particular direction
for(int x = 0; x < num_steps; x++) {
digitalWrite(stepPin, HIGH);
delayMicroseconds(dt);
digitalWrite(stepPin, LOW);
delayMicroseconds(dt);
}
delay(1000); // One second delay
digitalWrite(dirPin, LOW); //Changes the direction of rotation
for(int x = 0; x < num_steps; x++) {
digitalWrite(stepPin, HIGH);
delayMicroseconds(dt);
digitalWrite(stepPin, LOW);
delayMicroseconds(dt);
}
delay(1000);
}
I added dt
so I could control the step speed but its not behaving as I thought it would.
The original code has dt = 500
which needed 15V to run & runs not quite chunky movement but bordering on it & just over 1 revolution when num_steps = 2000
I changed to dt = 1000
& now its got really smooth faster motion & doing quite a few revolutions (too fast for me to count with my eyes) but if reduce num_steps = 200
that results in 1 revolution & now only needs 9V to run.
So, how come when I increase the delay it runs faster? Is this some kind of clocking/synching issue?