Hi there,
I've got a really simple program running to control a stepper motor with a potentiometer. My plan here is to actually use a stepper as a hub motor for an RC vehicle (Yes, I know that they are very power hungry etc.) With that being the case, I need the motors to shut off when I stop the vehicle to save power. I have gotten the stepper turning nicely with the pot but I can't seem to shut it off with the "enable" pin. Any idea what I'm doing wrong?
Bonus question:
I swapped out the A4988 driver for a TMC2209 and it is much quieter, however, it spins at a much slower speed, even if I make the delay time tiny (as shown in code). Why could this be?
const int StepX = 2;
const int DirX = 5;
const int StepY = 3;
const int DirY = 6;
const int StepZ = 4;
const int DirZ = 7;
const int enable = 8;
int potpin = A1;
int pot;
int spd;
void setup() {
pinMode(StepX,OUTPUT);
pinMode(DirX,OUTPUT);
pinMode(StepY,OUTPUT);
pinMode(DirY,OUTPUT);
pinMode(StepZ,OUTPUT);
pinMode( DirZ,OUTPUT);
}
void loop() {
pot = analogRead(potpin);
if (pot > 1){
digitalWrite(enable, LOW);
spd = map(pot, 0, 1023,3000, 1);
digitalWrite(DirX, HIGH);
digitalWrite(StepX,HIGH);
delayMicroseconds(spd);
digitalWrite(StepX,LOW);
delayMicroseconds(spd);
}
else{
digitalWrite(enable,HIGH); // This should disable the stepper, right????
}
}