Arduino and TB6600 driver

Hi,

I have set up my “pick and place” machine, and it runs fine. I am using this motor shield L293D to control 2 Nema 17 stepper motors (56 oz.in). Now I want to add one more stepper motor and increase the holding torque. So my new set up will have 3 Nema 23 stepper motors (269 oz.in). I have 3 motor drivers TB6600 ready for them. I am using the AF_Motor.h for the current set up, and it seems like won’t work with the TB6600. I am testing the Nema 23 with the AccelStepper.h. The speed is really slow when I try the MultiStepper example. But when I use this sketch

int i;
int j;

const int dir1 = 8;
const int en1 =7;
const int pul1 =9;
const int dir2 = 5;
const int en2 = 4;
const int pul2 = 6;

void setup() {
  // put your setup code here, to run once:
pinMode(dir1, OUTPUT);
pinMode(pul1, OUTPUT);

digitalWrite(en1, HIGH);

pinMode(dir2, OUTPUT);
pinMode(pul2, OUTPUT);

digitalWrite(en2, HIGH);

 stepper1();
   digitalWrite(en1, LOW);
 stepper2();
 digitalWrite(en2, LOW);
}

void stepper1()
{
  digitalWrite(dir1, HIGH);
  delay(100);
  for (i=0;i<20000;i++)
  {
    digitalWrite(pul1, LOW);
    delayMicroseconds(25);
    digitalWrite(pul1, HIGH);
    delayMicroseconds(25);
  }
}

void stepper2()
{
  digitalWrite(dir2, HIGH);
  delay(100);
  for (j=0;j<20000;j++)
{ 
digitalWrite(pul2, LOW);
delayMicroseconds(25);
digitalWrite(pul2, HIGH);
delayMicroseconds(25);
}

  }
void loop() {
 
  // put your main code here, to run repeatedly:


}

The steppers run really fast.

Here what I have in the MultiStepper sketch:

// MultiStepper.pde
// -*- mode: C++ -*-
//
// Shows how to multiple simultaneous steppers
// Runs one stepper forwards and backwards, accelerating and decelerating
// at the limits. Runs other steppers at the same time
//
// Copyright (C) 2009 Mike McCauley
// $Id: HRFMessage.h,v 1.1 2009/08/15 05:32:58 mikem Exp mikem $

#include <AccelStepper.h>

// Define some steppers and the pins the will use
AccelStepper stepper1(1, 9, 8);
AccelStepper stepper2(1, 6, 5);


void setup()
{  
    stepper1.setSpeed(120000);
    stepper1.moveTo(4000);
    
    stepper2.setSpeed(120000);
    stepper2.moveTo(1000000);
    
}

void loop()
{
    stepper1.runSpeed();
    stepper2.runSpeed();

}

Even when I increase the setSpeed, the stepper motors still run slow. What should I do to have it run fast like the sketch with pin high and low?

hnguyen91:
Even when I increase the setSpeed, the stepper motors still run slow. What should I do to have it run fast like the sketch with pin high and low?

I don't know the multiStepper version of AccelStepper, but why not just use the code that works at the speed you require.

Have a look at this Simple Stepper Code. I believe people have got the second version to work at high pulse speeds and it could easily be extended to multiple motors.

How many steps per second do you need for all the motors combined?

...R
Stepper Motor Basics

When you post code here that supposedly illustrates a problem, there is no point in having commented out code. That code is obviously not related to the problem, so DELETE IT!

Use Tools + Auto Format BEFORE posting code.

Sorry for the messy code. I have cleaned it up. Both codes can run the steppers. The difference is one use the AccelStepper library (slow speed) and the other doesn't (fast speed). How can I set up the code with AccelStepper library so that the steppers can run as fast as the code without the library?

I want to use the AccelStepper.h because I want to control 2 steppers at the same time.

Robin2:
How many steps per second do you need for all the motors combined?

I think 4000 steps per second (not sure). When I set delayMicroseconds(25), I got probably the highest speed. If I set 20 or 30, the stepper spins slower. When I try to change the speed for the steppers in the code with AccelStepper.h, nothing changes much.

Also, is it possible to control 2 steppers independently at the same time? For example, one stepper moves until the limit switch reads HIGH, while the other stepper just moves a certain number of steps.

I don't think that is a correct multi-stepper program. Have a look at the example on the website

Have you looked at my Simple Stepper Code - especially the second example that uses millis() and micros() rather than delay().

...R

i am new at coding .Can u provide a code to make 2 stepper motors move together .I am using TBB6600 stepper driver and 4 wire stepper motor.Please do provide the pin config

These links may help
Stepper Motor Basics
Simple Stepper Code

also look up the AccelStepper library

...R