Arduino Uno R3 and TB6600 Connection Diagram

Hi again,

Thanks to MarkT , we changed Motorshield Rev3 with TB6600. But now we cant find an easy connection diagram to connect Uno R3 and TB6600 together. Would anyone care to direct me to proper link that I can easily connect these 2?

pwmA = 3; pwmB = 11; brakeA = 9; brakeB = 8;

These are the pin numbers I am using in my program. But TB6600 has En+,En+, DIR+,DUR-, PUL+ and PUL- signs on it. Some sources say connect all negatives (EN-,DUR-,PUL-) to GND pins of Ardunio. Any pin that GND sign on it can be used? What about positives + (EN+,PUL+ and DIR+) ?

Thanks

Can you help us to help you by posting a link to the TB6600 datasheet?

It would also be a good idea to post the code you are trying to use. Have you seen this simple stepper code and stepper motor basics?

...R

This is data of TB6600: http://www.thanksbuyer.com/download/TB6600.pdf

And this is my program. Not yet converted for 200 steps.

#include <Stepper.h>

const int stepsPerRevolution = 40; // change this to fit the number of steps per revolution
// for your motor

// initialize the stepper library on the motor shield
Stepper myStepper(stepsPerRevolution,12,13);

// give the motor control pins names:
const int pwmA = 3;
const int pwmB = 11;
const int brakeA = 9;
const int brakeB = 8;

int previous = 0;

void setup() {
Serial.begin(9600);
// set the PWM and brake pins so that the direction pins // can be used to control the motor:
pinMode(pwmA, OUTPUT);
pinMode(pwmB, OUTPUT);
pinMode(brakeA, OUTPUT);
pinMode(brakeB, OUTPUT);
digitalWrite(pwmA, HIGH);
digitalWrite(pwmB, HIGH);
digitalWrite(brakeA, LOW);
digitalWrite(brakeB, LOW);
// initialize the serial port:
Serial.begin(9600);
// set the motor speed (for multiple steps only):
//myStepper.setSpeed(500);
}


void loop() {

//Get Motor up to 500 speed and turn 500 times / Total turns 2030
myStepper.setSpeed(400);
myStepper.step(30);
myStepper.setSpeed(500);
myStepper.step(2000);
//Slow Motor down and stop
myStepper.setSpeed(300);
myStepper.step(10);
myStepper.setSpeed(200);
myStepper.step(10);
myStepper.setSpeed(100);
myStepper.step(10);
delay(1000);

//Get Motor up to 500 speed and turn 500 times / Total turns 2030
myStepper.setSpeed(400);
myStepper.step(-30);
myStepper.setSpeed(500);
myStepper.step(-2000);
//Slow Motor down and stop
myStepper.setSpeed(300);
myStepper.step(-10);
myStepper.setSpeed(200);
myStepper.step(-10);
myStepper.setSpeed(100);
myStepper.step(-10);
delay(1000);

}

Its a stepper driver, not an H-bridge, so you want step and direction outputs, AccelStepper does this if you use the DRIVER option.

Like this without led connection?

// testing a stepper motor with a Pololu A4988 driver board or equivalent
// on an Uno the onboard led will flash with each step
// as posted on Arduino Forum at http://forum.arduino.cc/index.php?topic=208905.0

byte directionPin = 9;
byte stepPin = 8;
int numberOfSteps = 100;
byte ledPin = 13;
int pulseWidthMicros = 20;  // microseconds
int millisbetweenSteps = 25; // milliseconds


void setup() 
{ 

  Serial.begin(9600);
  Serial.println("Starting StepperTest");
  digitalWrite(ledPin, LOW);
  
  delay(2000);

  pinMode(directionPin, OUTPUT);
  pinMode(stepPin, OUTPUT);
  pinMode(ledPin, OUTPUT);
  
 
  digitalWrite(directionPin, HIGH);
  for(int n = 0; n < numberOfSteps; n++) {
    digitalWrite(stepPin, HIGH);
    delayMicroseconds(pulseWidthMicros);
    digitalWrite(stepPin, LOW);
    
    delay(millisbetweenSteps);
    
    digitalWrite(ledPin, !digitalRead(ledPin));
  }
  
  delay(3000);
  

  digitalWrite(directionPin, LOW);
  for(int n = 0; n < numberOfSteps; n++) {
    digitalWrite(stepPin, HIGH);
    // delayMicroseconds(pulseWidthMicros); // probably not needed
    digitalWrite(stepPin, LOW);
    
    delay(millisbetweenSteps);
    
    digitalWrite(ledPin, !digitalRead(ledPin));
  }
  
}

void loop() 
{ 

}

(Thanks to Robin2)

MarkT ,if I am gonna use accelstepper then I need only to connect Pin 9 to DIR+ and Pin 8 to PUL+ and others to GND pins on Aurdino Uno R3?

And should I connect EN+ to anywhere on Aurdino Uno R3 board? Thanks

DenizYILDIZ: if I am gonna use accelstepper then I need only to connect Pin 9 to DIR+ and Pin 8 to PUL+ and others to GND pins on Aurdino Uno R3?

And should I connect EN+ to anywhere on Aurdino Uno R3 board? Thanks

Those pin connections should be correct for my code. You can use any pins you like (other than 0 and 1) as long as the code matches the connections.

The accelStepper setup would be myStepper(1,stepPin,dirPin)

I'm not sure from the gobbledygook in the data sheet whether EN+ needs to be connected or whether it should be connected to 5v or GND. You will need to experiment. Start without connecting it.

...R

Ok Robin thnx. I found this site that tells the connection between TB6600 and Raspberry Pi. And ofcourse Uno is different but the logic may be same with different pin numbers.

http://www.nlogn.com/blog/

He connected EN+ to 5V or GND ( he said doesnt matter even Raspberry works 3.3V) And he connected DIR+ to GPIO 18 which is direction pin of Raspberry Pi. and PUL+ was connected to GPIO 23 which is pulse pin of Raspberry Pi. Others were connected to GND

Before last check, I must be sure about Ardunio Uno R3's pin numbers for direction and pulse(step) pins. As you said pin 9 is for direction and pin 8 for pulse(step).

[u]TB6600[/u] [u]Ardunio UNO R3[/u]

DIR+ >>>>>>>>> PIN 9

PUL+ >>>>>>>>> PIN 8

EN+ >>>>>>>>> 5V or GND (Either will be tested)

DIR- >>>>>>>> GND

PUL- >>>>>>>> GND

EN- >>>>>>>> GND

Am I right with this connection table? And how Uno R3 gets its power? Do I need extra powersupply or PIN will do that?

His code for Raspberry Pi+TB6600+Stepper motor

#!/usr/bin/python
#
# Written by Haydn Huntley (huntley@nlogn.com) on 08/16/2013.
# Feel free to use this code any way you want.
# Runs on a Raspberry Pi and drives an HY-DIV268N-5A stepper motor controller.
#
# Note:  this program must be run as root in order to use the GPIO calls.

import time
import RPi.GPIO as GPIO

enablePin    =  4 # Note enable is active low!
directionPin = 18
pulsePin     = 23
pulseState = 0
delay = 0.000001 # 1 microsecond


def setup():
    GPIO.setmode(GPIO.BCM)

    GPIO.setup(enablePin,    GPIO.OUT)
    GPIO.setup(directionPin, GPIO.OUT)
    GPIO.setup(pulsePin,     GPIO.OUT)

    GPIO.output(enablePin, 0)
    return


def forward(steps):
    global pulseState
    print "forward delay=%0.3fms steps=%d" % (delay * 1000, steps)
    GPIO.output(directionPin, 1)
    for i in range(steps):
        pulseState += 1
        GPIO.output(pulsePin, pulseState % 2)
        time.sleep(delay)
    pulseState %= 2
    return


def backwards(steps):
    global pulseState
    print "backwards delay=%0.3fms steps=%d" % (delay * 1000, steps)
    GPIO.output(directionPin, 0)
    for i in range(steps):
        pulseState += 1
        GPIO.output(pulsePin, pulseState % 2)
        time.sleep(delay)
    pulseState %= 2
    return

  
def main():
    # For the NEMA 14 12v 350mA (#324) stepper motors from AdaFruit:
    # http://www.adafruit.com/products/324
    # Driving it with 12v using a delay of 1 microsecond.
    revolutions = 3
    steps = revolutions * 200 * 16
    setup()
    forward(steps)
    time.sleep(0.5)
    backwards(steps)
    GPIO.cleanup()
    return

try:
    main()
except:
    print "something went wrong!"
    GPIO.cleanup()
    raise
GPIO.cleanup()
exit(0)

Am I right with this connection table?

I think that is the second time of asking - try it and see if it works

And how Uno R3 gets its power? Do I need extra powersupply or PIN will do that?

From the USB cable, as usual ? Or from the barrel jack.

...R

Not working :frowning: I dunno what to do . Cant point the problem :frowning: Simple program but didnt work . Motor isnt spinning.

#include <AccelStepper.h>


AccelStepper stepper (1,8,9); // name of stepper motor (1 = driver, pin 3 = step, pin 9 = direction) 


void setup() {
 
    stepper.setMaxSpeed(400);
    stepper.setAcceleration(400);
}

void loop()
{
stepper.stop();
stepper.moveTo(stepper.currentPosition()+100);
stepper.run();
stepper.moveTo(stepper.currentPosition()-500);
stepper.run();
}

Then I found another code. This time driver sends pulses but no motor movement. Actually it is trying. It is trying to take a step but no spinning.

//Arduino Sketch based on easy driver
int dirpin = 8;
int steppin = 9;
int enable = 7;
void setup()
{
pinMode(dirpin, OUTPUT);
pinMode(steppin, OUTPUT);
digitalWrite(enable, LOW);
}
void loop()
{
 int i;
 digitalWrite(dirpin, HIGH); // Set the direction.
 delay(100);
 for (i = 0; i<4000; i++) // Iterate for 4000 microsteps.
 {
 digitalWrite(steppin, LOW); // This LOW to HIGH change is what creates the
 delayMicroseconds(400);
 digitalWrite(steppin, HIGH);
 delayMicroseconds(400); // This delay time is close to top speed for this
 } // particular motor. Any faster the motor stalls.
 digitalWrite(dirpin, LOW); // Change direction.
 delay(100);
 for (i = 0; i<4000; i++) // Iterate for 4000 microsteps
 {
 digitalWrite(steppin, LOW); // This LOW to HIGH change is what creates the
 delayMicroseconds(400);
 digitalWrite(steppin, HIGH);
 delayMicroseconds(400); // This delay time is close to top speed for this
 } // particular motor. Any faster the motor stalls.
}

Solved... Wrong connection. I chose wrong colors for jumpers. Need to buy more different coloers

DenizYILDIZ: Solved... Wrong connection. I chose wrong colors for jumpers. Need to buy more different coloers

Mine are all white - scraps of wire. Just be careful.

...R