Stepper motor with TB6000 Microstep driver

We have the 42BYGHM809 Stepper motors with the TB6600 Stepper motor microstep driver to the Arduino using the BasicStepperDriver.h library.

  1. Connect the stepper and driver as shown: steppercabling.png

  2. Download and install the driver to arduino from here. (If you need help, check the manual library installation wiki page here).

  3. Try this stepper Motor 42BYGHM809 / TB6600 Test Program note the steps are 12800 for a 360 turn (guestimated!).

/*
   Simple demo, should work with any driver board

   Connect STEP, DIR as indicated

   Copyright (C)2015-2017 Laurentiu Badea

   This file may be redistributed under the terms of the MIT license.
   A copy of this license has been included with this distribution in the file LICENSE.

   Modified for CCI by Matt Jarvis
*/
#include <Arduino.h>
#include "BasicStepperDriver.h"

// Motor steps per revolution. Most steppers are 200 steps or 1.8 degrees/step
#define MOTOR_STEPS 12800
#define RPM 120

// Since microstepping is set externally, make sure this matches the selected mode
// If it doesn't, the motor will move at a different RPM than chosen
// 1=full step, 2=half step etc.
#define MICROSTEPS 1

// All the wires needed for full functionality
#define DIR 6
#define STEP 7
//Comment or uncomment line to use enable/disable ENABLE functionality
#define ENABLE 5

// 2-wire basic config, microstepping is hardwired on the driver (use this if not needing to use the enable pin)
//BasicStepperDriver stepper(MOTOR_STEPS, DIR, STEP);

//Uncomment line to use enable/disable functionality
BasicStepperDriver stepper(MOTOR_STEPS, DIR, STEP, ENABLE);

void setup() {
  stepper.begin(RPM, MICROSTEPS);
  // if using enable/disable on ENABLE pin (active LOW) instead of SLEEP uncomment next line
  stepper.setEnableActiveState(HIGH);
}

void loop() {

  // energize the coils
  stepper.enable();

  /*
     Moving motor one full revolution using the degree notation
     and wait for 2 seconds
  */
  stepper.rotate(360);
  delay(2000);
  /*
     Moving motor to original position using steps
  */
  stepper.move(-MOTOR_STEPS * MICROSTEPS);

  // release the coils, (disable motor and allow the motor to be moved by hand)
  stepper.disable();

  // delay 5 seconds
  delay(5000);
}

Revision #7
Created 21 February 2023 10:19:47 by Matt Jarvis
Updated 21 February 2023 11:52:38 by Matt Jarvis