Hi
I'm trying to make a NEMA 23 (19kg.cm)(just one motor) move clockwise and counterclockwise by pushing 2 buttons( when I push the button it will rotate/do a certain amount of steps which i will define later on), and another 3erd button to reset it's position.
I don't need for it to be fast ( 40mm/seg ; the total distance it has to do 80mm), but I do need to have as much torque as possible
This is the hardware I have, but i do not know if it's the correct hardware or if I need something else.
-Arduino UNO
-NEMA 23 ( datasheet https://www.gizmojo.com.ar/system/datasheets/57BYGH633.pdf )
-CNC SHIELD ( I know it's to control 3 xis even though i only need one)
-DRV8825
-3 push buttons / analog stick ( like the Play Stations ones).
-Power supply: 12V/5A for the stepper
-Power supply: 12v for the Arduino
I can't figure out how to/where to connect the pins for the analog stick/or push buttons
So far this is the code I have ( which will only make it go CW and CCW automatically)
#define EN 8
//Direction pin
#define X_DIR 5
#define Y_DIR 6
#define Z_DIR 7
//Step pin
#define X_STP 2
#define Y_STP 3
#define Z_STP 4
//DRV8825
int delayTime=30; //Delay between each pause (uS)
int stps=6400;// Steps to move
void step(boolean dir, byte dirPin, byte stepperPin, int steps)
{
digitalWrite(dirPin, dir);
delay(100);
for (int i = 0; i < steps; i++) {
digitalWrite(stepperPin, HIGH);
delayMicroseconds(delayTime);
digitalWrite(stepperPin, LOW);
delayMicroseconds(delayTime);
}
}
void setup(){
pinMode(X_DIR, OUTPUT); pinMode(X_STP, OUTPUT);
pinMode(Y_DIR, OUTPUT); pinMode(Y_STP, OUTPUT);
pinMode(Z_DIR, OUTPUT); pinMode(Z_STP, OUTPUT);
pinMode(EN, OUTPUT);
digitalWrite(EN, LOW);
}
void loop(){
step(false, X_DIR, X_STP, stps); //X, Clockwise
step(false, Y_DIR, Y_STP, stps); //Y, Clockwise
step(false, Z_DIR, Z_STP, stps); //Z, Clockwise
delay(100);
step(true, X_DIR, X_STP, stps); //X, Counterclockwise
step(true, Y_DIR, Y_STP, stps); //Y, Counterclockwise
step(true, Z_DIR, Z_STP, stps); //X, Counterclockwise
delay(100);
}
Could somebody please help me?
Thanks in advance