当前位置:网站首页>Arduino controls tb6600 driver +42 stepper motor

Arduino controls tb6600 driver +42 stepper motor

2022-06-13 00:35:00 Flying husky

 

int PUL = 7; // Define the pulse pin 
int DIR = 6; // Define direction pins 
int ENA = 5; // Define enable pin 
int RESET = 4; // Define reset sensor 

/**
 * TB6600 Driver  . 42 Two phase four wire stepping motor 
 */
void setup() {
  pinMode (PUL, OUTPUT);
  pinMode (DIR, OUTPUT);
  pinMode (ENA, OUTPUT);
  pinMode (RESET,INPUT);
  Serial.begin(9600);
  //  Initialize reset  -  turn 3 circle 
  for (int i = 0; i < 4800; i++) // Forward 4800 Step  SW1=OFF,SW2=ON,SW3=OFF( Every lap 1600 pulse )
  {
    digitalWrite(DIR, LOW); //  Define forward rotation 
    digitalWrite(ENA, HIGH);//  start-up 
    digitalWrite(PUL, HIGH);//  Output pulse 
    delayMicroseconds(2000);
    digitalWrite(PUL, LOW);
    //  Reset the sensor 
    int reset = digitalRead(RESET);
    if(c == 0) {
      //  Stop the rotation after the monitoring reaches the reset position 
      break;
    }
    delayMicroseconds(2000);
  }
}

void loop() {
  for (int i = 0; i < 1600; i++) // Positive rotation 1 circle 
  {
    digitalWrite(DIR, LOW);
    digitalWrite(ENA, HIGH);
    digitalWrite(PUL, HIGH);
    delayMicroseconds(50);
    digitalWrite(PUL, LOW);
    delayMicroseconds(50);
  }
  delay(10000); //  Pause 10 second 
  for (int i = 0; i < 1600; i++) // Reverse 1 circle 
  {
    digitalWrite(DIR, HIGH);
    digitalWrite(ENA, HIGH);
    digitalWrite(PUL, HIGH);
    delayMicroseconds(50);
    digitalWrite(PUL, LOW);
    delayMicroseconds(50);
  }
}

原网站

版权声明
本文为[Flying husky]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202280600042380.html