TB6600 Stepper Motor Driver with Arduino schematic.
Fig. 1 TB6600 Stepper Motor Driver with Arduino schematic.

TB6600 Stepper Motor Driver with Arduino


TB6600 is a CNC Single Axis, 0.2-5A Two Phase Hybrid Stepper Motor Driver Control module.

The device has three optocoupler inputs that require 8-15mA. I connected mine as shown in Fig. 1. The Arduino program is shown below.

What causes confusion is the "EN" connection. To quote the manual:

Note: When "EN" is in the valid state, the motor is in a free states (Off-line mode). In this mode, you can adjust the motor shaft position manually. When "EN" is in the invalid state, the motor will be in an automatic control mode.

It never defined what "valid" or "invalid" means.

Further down the manual we get this:

If you turn on the Off-line function, the motor will enter a free state. You can adjust the motor shaft freely, and the pulse signal will be no response. If you turn it off, it will be back into automatic control mode

Note: Generally, EN terminal is not connected.

This is nonsense. If EN is not connected or (LOW) if connected the motor is locked at all times unless stepping! The motor gets HOT!

I wrote my program with this in mind. "EN" is connected in my circuit. "EN" is turned on unless I have a reason to lock the motor.

The original program was programmed for 100 R.P.M. or 20,000 steps per minute. The motor was 1.8 degrees per step or 200 steps for 360 degree rotation.

The step delay is 3.3 mSec. or 3300 uSec. My particular test motor requires minimum 2 mSec. or it stalls.

TB6600 Stepper Motor Driver case.
Fig. 2 TB6600 Stepper Motor Driver case.



// if ENA is LOW motor is locked at last position
// this can lead to overheating of motor
// program assumes common cathode connection

#define SW1 2
#define SW2 3
#define SW3 4
#define DIR 5
#define PUL 6
#define ENA 7 // HIGH disables motor power

#define CW 1
#define CCW 0

// indicates motor is on
// this is built in LED on DP13.
#define motorOn 13

// sets how many pulses for 360 degrees
#define rot360 200

// HIGH on PUL will keep motor locked in position
// note motor will get hot after some time.

int x, y;

// this sets the motor speed
int pulseDelay = 3300; // in uSec.

void setup() {
  // DP13 LED
  pinMode(motorOn, OUTPUT);
  digitalWrite(motorOn, LOW);

  pinMode(SW1, INPUT_PULLUP);
  pinMode(SW2, INPUT_PULLUP);
  pinMode(SW3, INPUT_PULLUP);
  pinMode(DIR, OUTPUT);
  digitalWrite(DIR, LOW);
  pinMode(PUL, OUTPUT);
  digitalWrite(PUL, LOW);
  pinMode(ENA, OUTPUT);
  digitalWrite(ENA, HIGH); 

}

void loop() {


  // manual CW when pushed
  while (digitalRead(SW1) == 0) {
    digitalWrite(motorOn, HIGH); // motor LED On
    digitalWrite(ENA, LOW); // enable motor power
    digitalWrite(DIR, CW);
    digitalWrite(PUL, 1);
    digitalWrite(PUL, 0);
    delayMicroseconds(pulseDelay * 2);
  } // end while

  // manual CCW when pushed
  while (digitalRead(SW2) == 0) {
    digitalWrite(motorOn, HIGH); // motor LED On
    digitalWrite(ENA, LOW); // enable motor power
    digitalWrite(DIR, CCW);
    digitalWrite(PUL, 1);
    digitalWrite(PUL, 0);
    delayMicroseconds(pulseDelay * 2);
  } // end while

  if (digitalRead(SW1) && digitalRead(SW2)) digitalWrite(motorOn, LOW);

  if (digitalRead(SW3) == 0) {
    lockMotor();
  }
  else {
    unlockMotor();
  }
  delay(100);

} // end loop

void motorRun(int count, byte dir_local )   {
  digitalWrite(motorOn, HIGH); // DP13 LED
  digitalWrite(ENA, LOW); // motor power ON
  digitalWrite(DIR, dir_local);
  count = count * rot360;
  for (int x = 0; x < count; x++)   {
    digitalWrite(PUL, 1);
    digitalWrite(PUL, 0);
    delayMicroseconds(pulseDelay);
  } // end for
  digitalWrite(ENA, HIGH); // motor power OFF
  digitalWrite(motorOn, LOW);
}

void lockMotor(void) {
  digitalWrite(motorOn, HIGH);
  digitalWrite(ENA, LOW);
}

void unlockMotor(void) {
  digitalWrite(ENA, HIGH);
}

/*
Ex.
motorRun(10, CW);
motorRun(10, CCW);
motorRun(100, CW);
motorRun(50, CCW);
motorRun(50, CCW);

*/

Related links:

Web site Copyright Lewis Loflin, All rights reserved.
If using this material on another site, please provide a link back to my site.