Arduino motor shields -- How many and how fast can they run steppers

954 views
Skip to first unread message

Xiaoping Hu

unread,
Feb 4, 2017, 2:22:01 AM2/4/17
to accelstepper
I am trying to run up to 48 motors with Arduino.  Originally I thought I can just stack up to 24 Adafruit motor shields on an Arduino UNO because they are 5-bit addressable (up to 32 shields).  But when I started to test more than one motor shields, I ran into problems. The more motors I ran simultaneously, the slower they get.

I now understand (with help from gregor), that the limitation on the speed is the I2C bus speed, or overhead (even with tweaked speed of 400kHz).  What I did was call onestep() for each motor in succession in a loop, and the combined top speed is about 1000 steps/sec (1000 for one motor, 500 each for two, and so on).  That is the best utilization of all the resources in this setting, I guess?

What I need is for each motor to run at least 1000 steps per second.  If one UNO can only give me 1000 steps/sec, I would need 48 of them, and that's really excessive.  So what choices do I have?  Can someone give me a suggestion?  Some other motor shields that don't run on I2C bus and using the digital pins instead?

I have another question: The Adafruit motor shield has its own PWM chip on board, but it's only used for DC motor speed control, not for stepper.  Why can't we use the PWM to control the H bridges to drive step motors?  If we can do this, then we are not using the micro controller and I2C bus for every step, maybe we can drive faster.  The reason I am thinking this is: first, I am driving pretty small motors and don't need very fast speed, so I don't have to accelerate and decelerate; constant speed is fine.  Second, I don't need precise speed control, just some, fast enough speed.  I am no electrical engineer, if my guess is completely absurd, I apologize in advance.

Thank you all,
XP




gregor

unread,
Feb 4, 2017, 5:11:55 AM2/4/17
to accelstepper
Hi,


On Saturday, February 4, 2017 at 8:22:01 AM UTC+1, Xiaoping Hu wrote:
I am trying to run up to 48 motors with Arduino.  Originally I thought I can just stack up to 24 Adafruit motor shields on an Arduino UNO because they are 5-bit addressable (up to 32 shields).  But when I started to test more than one motor shields, I ran into problems. The more motors I ran simultaneously, the slower they get.

I now understand (with help from gregor), that the limitation on the speed is the I2C bus speed, or overhead (even with tweaked speed of 400kHz).  What I did was call onestep() for each motor in succession in a loop, and the combined top speed is about 1000 steps/sec (1000 for one motor, 500 each for two, and so on).  That is the best utilization of all the resources in this setting, I guess?
correct.
 

What I need is for each motor to run at least 1000 steps per second.  If one UNO can only give me 1000 steps/sec, I would need 48 of them, and that's really excessive.  So what choices do I have?  Can someone give me a suggestion?  Some other motor shields that don't run on I2C bus and using the digital pins instead?
you could try an Arduino with a faster Microcontroller, like the Due, and A4988 / DRV8825 / ... stepper drivers. You will still need multiple Arduinos (you need at least 2 output pins per driver, and the Due's maximum speed is limited: https://groups.google.com/forum/#!msg/accelstepper/IpwyCOzZNY4/hmKfsk5KBAAJ )


I have another question: The Adafruit motor shield has its own PWM chip on board, but it's only used for DC motor speed control, not for stepper.  Why can't we use the PWM to control the H bridges to drive step motors?  If we can do this, then we are not using the micro controller and I2C bus for every step, maybe we can drive faster.  The reason I am thinking this is: first, I am driving pretty small motors and don't need very fast speed, so I don't have to accelerate and decelerate; constant speed is fine.  Second, I don't need precise speed control, just some, fast enough speed.  I am no electrical engineer, if my guess is completely absurd, I apologize in advance.
the PWM feature is actually used for steppers, if you choose to microstep. 
This is the PWM controller on the AFMSv2: https://cdn-shop.adafruit.com/datasheets/PCA9685.pdf both PWM frequency and phase shift are programmable, so it should be possible to program the PCA9685 to step the motors at a fixed step frequency, but you would have to rewrite the AFMS library from scratch. Also, you would loose compatibility with AccelStepper (there's no way AccelStepper's internal position counter will still work unless you hack that too)


Thank you all,
XP




Xiaoping Hu

unread,
Feb 4, 2017, 10:49:36 AM2/4/17
to accelstepper
Thank you Gregor!  

A problem with driving from digital pins is wiring: it's messy with 48 motors.  That makes the Adafruit motor shields option very attractive.  If I still want to use the these shields, will the Arduino Due make it any faster?  Or is there any way to make I2C bus any faster?  I don't need it very fast; all I need is 1000 steps/sec for each motor.

XP

gregor christandl

unread,
Feb 4, 2017, 11:02:12 AM2/4/17
to accelstepper
1000 steps/ second is already very fast for the AFMSv2. You could try to increase the I2C clock even further to squeeze out some more steps. If I remember correctly, the maximum speed achieved by an Adafruit developer was about 1200 steps / second (posted in the Adafruit forums). 

Currently the AFMSv2 library does not work correctly on the Due, if you try to use more than 1 motor shield the sketch will lock up (I experienced this myself. It's also documented in the Adafruit documentation for the AFMSv2)

--
You received this message because you are subscribed to the Google Groups "accelstepper" group.
To unsubscribe from this group and stop receiving emails from it, send an email to accelstepper...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Xiaoping Hu

unread,
Feb 4, 2017, 2:40:45 PM2/4/17
to accelstepper
Gregor,
Thank you again for your reply.  I found this shield online: 


It looks pretty neat as far as wiring is concerned, and it can drive 4 motors.  It uses the digital pins to drive the drivers?  If that's the case, would it be faster than the I2C bus driven shields (since the microcontroller is 16mHz)?

Thanks,
XP

On Saturday, February 4, 2017 at 2:22:01 AM UTC-5, Xiaoping Hu wrote:

Xiaoping Hu

unread,
Feb 4, 2017, 2:54:44 PM2/4/17
to accelstepper
Another question is: Can I use the accelstepper to drive this shield?  Thanks again.

Mike McCauley

unread,
Feb 4, 2017, 4:21:39 PM2/4/17
to accels...@googlegroups.com, Xiaoping Hu
I think the most efficient way to connect meany steppers in terms of how many
wires are needed) would be to use stepper drivers with a Step and a Direction
pin. They could all share the Direction output, and each have a separate Step
output.

Do get a high combined stepping speed from several motors you would still need
to use the fastest processor you can.

Cheers.
--
Mike McCauley VK4AMM mi...@airspayce.com
Airspayce Pty Ltd 9 Bulbul Place Currumbin Waters QLD 4223 Australia
http://www.airspayce.com
Phone +61 7 5598-7474

Brian Schmalz

unread,
Feb 4, 2017, 4:30:47 PM2/4/17
to accels...@googlegroups.com, Xiaoping Hu
Many years ago I designed the electronics for an art project that used several hundred small stepper motors. The artist used a small Arduino board to control all of them. It was very easy. I designed a small board with four step/direction driver chips and a serial to parallel shift register. All of the boards got daisy-chained together and we hung the whole chain off the SPI port. We set up code to clock out the whole set of bits (a step and a direction for each of the motors) every 1ms or so. Then, any time he wanted to take a step on a motor, he just filled in that motor's step bit with a 1 and the SPI port clocked it out.

Advantage: many many motors can be run from just a couple pins this way (2 pins - Data and Latch)
Disadvantage: low maximum step rates, although this could be overcome to a degree with higher speed SPI ports

The electronics for this type of system is very simple, although you have to watch the signal integrity of the latch signal primarily. This method would not work with out of the box Accelstepper, but the library could be modified to support it.

*Brian

--
You received this message because you are subscribed to the Google Groups "accelstepper" group.
To unsubscribe from this group and stop receiving emails from it, send an email to accelstepper+unsubscribe@googlegroups.com.

gregor

unread,
Feb 4, 2017, 5:28:40 PM2/4/17
to accelstepper
yes. use AccelStepper::DRIVER in the constructor. you only need to specify STEP and DIR pins, others are optional. you should be able to achieve speeds of a little less than 4000 steps / second in total with this shield, if you use a 16MHz arduino.

Xiaoping Hu

unread,
Feb 4, 2017, 10:28:54 PM2/4/17
to accelstepper
gregor,

The combine 4k steps sounds right to me, although I could use a higher rate.  I just ordered one set (1 knockoff Arduino, 1 motor shield + 4 DRV8825 breakouts) from RepRap.  If I want to achieve higher speeds, could I use this shield on an Arduino Due?

Thanks,
XP

Xiaoping Hu

unread,
Feb 5, 2017, 12:11:13 AM2/5/17
to accelstepper, hu.xiao...@gmail.com
Brian,
That approach sounded very attractive.  Where can I go get more info on how to build/run the setting you talked about?
Thanks,
XP
To unsubscribe from this group and stop receiving emails from it, send an email to accelstepper...@googlegroups.com.

Xiaoping Hu

unread,
Feb 5, 2017, 12:12:20 AM2/5/17
to accelstepper, hu.xiao...@gmail.com
Thank you, Mike.
I think the RepRap step motor shield might work for me, except I wish the speed can be a little higher.  I already ordered one (with 4 motor drivers).  So I wonder if I put them on Arduino Due's they might run faster?
XP

gregor christandl

unread,
Feb 5, 2017, 3:13:19 AM2/5/17
to accelstepper, hu.xiao...@gmail.com

I'm afraid you cannot use this shield on a Due. It seems run on 5V, but the Due's input pins can only handle 3.3V.


Brian Schmalz

unread,
Feb 5, 2017, 9:21:29 AM2/5/17
to accels...@googlegroups.com
XP,

Sure, This page : http://www.schmalzhaus.com/EasyDriverQuad/index.html has schematics and board layout files for the boards I designed. I was wrong about something I said earlier - we were getting 5K step rates out of the system, and could probably go higher. It can easily be extended to as many steppers as you want.

If you're trying to get higher step speeds with larger numbers of steppers using Accelstepper, I suggest going to the fastest Arduino compatible board you can. For example, a chipKIT board like the uC32 or Fubarino SD is a 32 bit processor running at 80Mhz and can easily do multiple steppers at 10K steps/s, or larger numbers of steppers at slower step rates. But you can also go up to the 200 Mhz WiFire chipKIT board, which (although I haven't directly tested it) will be able to support many more Accelstepper steppers at much faster speeds.

*Brian

To unsubscribe from this group and stop receiving emails from it, send an email to accelstepper+unsubscribe@googlegroups.com.

Xiaoping Hu

unread,
Feb 10, 2017, 8:16:36 PM2/10/17
to accelstepper
Everyone,
After all the discussion with the nice people in this group, I decided that the motor shields that each houses 4 stepstick from RepRapChampion or Protoneer is the way to go, because it gives me neatest wiring. Now I got the shields and stepsticks, and am programming.  But somehow I couldn't get it to work.  My sketch is below, but nothing happens when I run it (pin 2 is step pin; pin 5 is direction pin), please help:

#include <AccelStepper.h>

AccelStepper stepper3(AccelStepper::DRIVER, 2, 5);

void setup()
{   
    stepper3.setMaxSpeed(300.0);
    stepper3.setAcceleration(100.0);
    stepper3.moveTo(1000000); 
}

void loop()
{
    stepper3.run();
}


On Saturday, February 4, 2017 at 2:22:01 AM UTC-5, Xiaoping Hu wrote:

Mike McCauley

unread,
Feb 10, 2017, 10:05:06 PM2/10/17
to accels...@googlegroups.com
Hello,

that code looks basically OK, but you have not specfied exactly which driver
shield you have. Therefore we have no idea whether your driver shield pin
numbers are correct or whether your driver shield requires other input.

For example, this shield:
https://reprapchampion.com/products/arduino-cnc-v3-shield-for-mill-router-engraver-robot-4x-drv8825-uno-r3

appears to require the shield enable EN on pin 8 to be pulled low too.

Cheers.

Xiaoping Hu

unread,
Feb 10, 2017, 10:35:38 PM2/10/17
to accelstepper
Mike,

I am using the shield I bought on RepRapChampion: 
https://reprapchampion.com/collections/electronics/products/arduino-cnc-v3-shield-mill-router-engraver-robot-4x-a4988-uno-r3-micro-usb

The pin mapping is:  
Motor      StepPin      DirPin
X                  2               5
Y                  3               6
Z                  4               7
A                 12             13
Enable: 8

And the following sketch works, which runs a constant speed for a number of steps based on my input from serial port, but I would like to use the acceleration.  I will type in 4 numbers in the serial terminal after I see a "c" from the sketch.

#define EN 8 // stepper motor enable , active low 
#define ENABLE digitalWrite (EN, LOW); // enable all motors
#define DISABLE digitalWrite (EN, HIGH); //disable all motors

int delayUs = 80;

class stepper 
{
  private:
    int _stpPin;
    int _dirPin;
    int _steps = 0;
  public:
    stepper (int stpPin, int dirPin);
    void getSteps(int steps);
    void setDIR(void);
    void goHIGH(int);
    void goLOW (int);
};

stepper::stepper (int stpPin, int dirPin)
{
  _stpPin = stpPin;
  _dirPin = dirPin;
  pinMode (_stpPin, OUTPUT);
  pinMode (_dirPin, OUTPUT);
}

void stepper::getSteps(int steps)
{
  _steps = steps;
}

void stepper::setDIR (void)
{
  bool DIR;
  DIR = ( _steps > 0 );
  digitalWrite(_dirPin, DIR);  
  _steps = abs(_steps);
}

void stepper::goHIGH(int pos)
{
  if ( _steps > pos )
  {
    digitalWrite(_stpPin, HIGH);
  }
  delayMicroseconds(delayUs);
}

void stepper::goLOW(int pos)
{
  if ( _steps > pos )
  {
    digitalWrite(_stpPin, LOW);
  }
  delayMicroseconds(delayUs);
}

int maxSteps(int a, int b, int c, int d)
{
  int Max_ = a;
  Max_ = (Max_ > b)? Max_ : b;
  Max_ = (Max_ > c)? Max_ : c;
  Max_ = (Max_ > d)? Max_ : d;
  return Max_;
}

stepper stepper1(2,5);  //X-motor
stepper stepper2(3,6);  //Z-motor, not what you would think
stepper stepper3(4,7);  //Y-motor, not what you would think
stepper stepper4(12,13);//A-motor

void setup () 
{
  pinMode (EN, OUTPUT); 
  DISABLE;
  Serial.begin(250000);
  Serial.setTimeout(5);
  Serial.println("c");

int i =0, stepsMAX;
int Steps1, Steps2, Steps3, Steps4;

void loop () 
  if (Serial.available())
  {
    Steps1 = Serial.parseInt();
    Steps2 = Serial.parseInt();
    Steps3 = Serial.parseInt();
    Steps4 = Serial.parseInt();
    
    stepper1.getSteps(Steps1);
    stepper2.getSteps(Steps2);
    stepper3.getSteps(Steps2);
    stepper4.getSteps(Steps3);

    stepsMAX = maxSteps(abs(Steps1), abs(Steps2), abs(Steps3), abs(Steps4));

    stepper1.setDIR();
    stepper2.setDIR();
    stepper3.setDIR();
    stepper4.setDIR();

    ENABLE;

  int ms0 = millis();
  
    for (i = 0; i < stepsMAX; i++)
    {
      stepper1.goHIGH(i);
      stepper2.goHIGH(i);
      stepper3.goHIGH(i);
      stepper4.goHIGH(i);

      stepper1.goLOW(i);
      stepper2.goLOW(i);
      stepper3.goLOW(i);
      stepper4.goLOW(i);
    }

    DISABLE;
    Serial.println("c"); 
  }
}

The sketch I posted earlier was just trying to test the accelStepper library by driving one motor, but I don't know the reason why it's not working.

Thanks for your help,
XP

Xiaoping Hu

unread,
Feb 10, 2017, 11:04:41 PM2/10/17
to accelstepper
Mike,
Yes. I didn't pull the pin 8 LOW (I don't know anything about this library).  But I just added that to my sketch, still nothing happens.
Thanks,
XP

On Friday, February 10, 2017 at 10:05:06 PM UTC-5, mikem wrote:

Mike McCauley

unread,
Feb 10, 2017, 11:05:57 PM2/10/17
to accels...@googlegroups.com
I think you have to be sure to lower the EN pin 8.

Xiaoping Hu

unread,
Feb 10, 2017, 11:11:06 PM2/10/17
to accelstepper
Mike,
I just did it in setup(), but still no movement.  Really don't know what to do now.

Xiaoping Hu

unread,
Feb 11, 2017, 12:08:36 AM2/11/17
to accelstepper
Oh well, I didn't really do it right.  Now the EN pin is really pulled low and it's moving!  Thanks, Mike!


On Saturday, February 4, 2017 at 2:22:01 AM UTC-5, Xiaoping Hu wrote:

alex cohen

unread,
Jul 26, 2017, 4:10:00 PM7/26/17
to accelstepper
Hi Xiaoping,

Did you ever get this to work, and if so how fast did you get your motors to spin?

I am having a similar problem using the Adafruit motor shield for 14 stepper motors, and am thinking of trying out this CNC V3 Shield that you mentioned.

Thanks,

Alex 

Xiaoping Hu

unread,
Jul 26, 2017, 6:00:24 PM7/26/17
to accels...@googlegroups.com
Alex,

I don't want to disappoint you.  My solution may not apply to you.

My application involving driving dozens of steppers to a distance quickly and stop.  I of course have to accelerate, but no need to decelerate.  I can afford to just cut off at high speed and not worrying if there is a couple of steps overshoot or whatever.  And there is no coordination required among motors; they can all start and the same time and finish their individual distances and stop at different times (because subsequent moves will fix that).  After some thought, I thought this should be simple.  So I bought those "CNC motor shields", each can drive 4 step motors, wrote my own code (no library of any kind; it's so simple).  It was really fast.  I don't remember how fast it was, I think it was tens of thousands of steps per second for each motor.

The problem using the Adafruit mtor shield is the speed.  The I2C bus consumes too much resources, I was told.  Although the AccelStepper library is very nice, it can do all kind of motions, it slows down it as well.  My problem is unique, and my solution is unique.

Cheers,

Xiaoping

--
You received this message because you are subscribed to a topic in the Google Groups "accelstepper" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/accelstepper/3Jx9W1yzyRg/unsubscribe.
To unsubscribe from this group and all its topics, send an email to accelstepper+unsubscribe@googlegroups.com.

alex cohen

unread,
Aug 1, 2017, 9:28:38 AM8/1/17
to accelstepper
I understand as I am having the same problem with the Adafruit Motor Shield (I have stacked 7 of then, but cannot get even 1 rev/s for my 14 motors.

Can you share the code you used for the CNC Motor Shield? I just bought one and want to test it out.
To unsubscribe from this group and all its topics, send an email to accelstepper...@googlegroups.com.

Xiaoping Hu

unread,
Aug 1, 2017, 8:57:09 PM8/1/17
to accels...@googlegroups.com
Alex,

I paste the code down here.  Once it loaded, at serial port, you should see a character "c", which means the motors are ready.  To drive the motors, you need send command like this:  m100;200;300;400;  which turns motor 1 by 100 steps, 2 by 200 steps, and so on. Pay attention to the syntax.  You have to put in all an "m" followed by 4 numbers separated by ";" and end with a ";", even if you just want to run one motor.  Once the motors finish running the steps, you should see a "c", then you can issue command again.  Good luck.


#define EN 8                             // stepper motor enable , active low 
#define ENABLE digitalWrite(EN, LOW);    // enable all motors
#define DISABLE digitalWrite(EN, HIGH);  //disable all motors
#define START_DELAY 200   //This sets the start speed. Note the difference between this and ACCEL_STEPS sets the max speed.
#define ACCEL_STEPS 180   //This is when acceleration stops and max speed begins. This motion profile is "constant jerk".
#define CONST_STEPS 500   //If the max steps of this move is equal to or below this speed, it will run a constant low speed the whole move
#define CONST_DELAY 200   //This sets the constant speed
#define WRITE_TIME 5      //micro seconds to make up for the time when this motor is not moving
#define COUNTER_MAX 500000  //5000000 microseconds delay each cycle for about 10 seconds, probably should be shorter.

long stepsMAX, STEPS[] = {0, 0, 0, 0};  //distance each motor travels in one move.
unsigned long counter = 0;  //timeout counter
unsigned int delayUs, len;
String str, strSub;

class stepper 
{
  private:
    int _stpPin;
    int _dirPin;
    long _steps = 0;

  public:
    stepper (int stpPin, int dirPin);
    void getSteps(long steps);
    void goHIGH(long pos);
    void goLOW (long pos);
};

stepper::stepper (int stpPin, int dirPin)
{
  _stpPin = stpPin;
  _dirPin = dirPin;
  pinMode (_stpPin, OUTPUT);
  pinMode (_dirPin, OUTPUT);
}

void stepper::getSteps(long steps)
{
  digitalWrite(_dirPin,  steps > 0 ); //Sets direction
  _steps = abs(steps);
}

void stepper::goHIGH(long pos)    //This is the actual move
{
  if ( _steps > pos )
    digitalWrite(_stpPin, HIGH);
  else
    delayMicroseconds(WRITE_TIME);  //fill in time when other motors are moving
  delayMicroseconds(delayUs);
}

void stepper::goLOW(long pos)
{
  if ( _steps > pos )
    digitalWrite(_stpPin, LOW);
  else
    delayMicroseconds(WRITE_TIME); //fill in time when other motors are moving
  delayMicroseconds(delayUs);
}

stepper myStepper[] = {stepper(2,5), stepper(3,6), stepper(4,7), stepper(12,13) }; //This sets 4 motors

void setSteps(void)      //Assigns distances to each motor
{
  for (int i = 0; i < 4; i++)
    myStepper[i].getSteps(STEPS[i]);
  stepsMAX = maxSteps();
}

long maxSteps(void)      //To find the longest distance to travel of 4 motors
{
  for (int i = 0; i < 4; i++)
    STEPS[i] = abs(STEPS[i]);
  long MAX_STEPS = STEPS[0];
  for (int i = 1; i <4 ; i++)
    MAX_STEPS = MAX_STEPS > STEPS[i] ? MAX_STEPS : STEPS[i];
  return MAX_STEPS;
}

void oneStep(long i)    //moves one step for each motor
{
  for (int j = 0; j < 4; j++)
    myStepper[j].goHIGH(i);
  for (int j = 0; j < 4; j++)
    myStepper[j].goLOW(i);
}

void accelerate (void)
{
  long i;
  for (i = 0; i < ACCEL_STEPS; i++)
  {
    oneStep(i);
    delayUs--;  
  }
}

void runConst(void)
{
  long i;
  for (i = 0; i < stepsMAX; i++)
    oneStep(i);
}

void runMax(void)
{
  long i;
  for (i = ACCEL_STEPS; i < stepsMAX; i++)
    oneStep(i);
}

void runSteps(void)  //decides to run accelerate + maxSpeed or to run at a constant low speed for short distance
{
  ENABLE
  if (stepsMAX > CONST_STEPS)  
  {
    delayUs = START_DELAY;
    accelerate();
    runMax();
  }
  else
  {
    delayUs = CONST_DELAY;
    runConst();
  } 
  delay(50); //break the last motor
  DISABLE   
}

int get4numbers(int j, int L, int n) //recursive function to get steps from input string
{
  if ( n == 4 || ( j >= L ) ) //last run finished the job, or string is too short
    return n;                 //n==4, success; got all 4 numbers. Otherwise string too short.
  for (int i = j; i < L; i++)
  {
    if ( str[i] == ';' )
    {
      strSub = str.substring(j, i);
      if ( strSub.length() == 0 )
        return 0;
      STEPS[n] = strSub.toInt();
      strSub = "";
      i++;
      n++;
      return get4numbers(i, L, n);  //A successful run doesn't return its own number, but pass the job to the lower runs and will report their numbers
    }
  }  
  return 0;  //When all else fails
}

void setup () 
{
  pinMode (EN, OUTPUT); 
  DISABLE
  Serial.begin(250000);
  Serial.setTimeout(5);
  Serial.print('c');
  while ( Serial.available() <= 0 );
  Serial.print('c');

void loop()   //This is the main loop that will run forever
{
  if ( Serial.available() > 0)
  {
    str = Serial.readString();
    if ( str[0] = 'm' )
    {
      str = str.substring(1);  //take the leading 'm' away
      len = str.length();
      if ( get4numbers(0, len, 0) == 4 )
      {
        setSteps();
        runSteps();
        Serial.print('c');    //'c' means "complete"
      }
    delay(10);
    }else
      acknowlege();   
  }else
    acknowlege();
}

void acknowlege (void)
{       //for about 10 seconds of no activity, annouce "I am here" in case previous 'c' got lost:
  counter++;
  if (counter >= COUNTER_MAX) 
  {
    Serial.print('c');
    counter = 0;
  }  
}

To unsubscribe from this group and all its topics, send an email to accelstepper+unsubscribe@googlegroups.com.

Xiaoping Hu

unread,
Aug 2, 2017, 7:45:20 AM8/2/17
to accelstepper
Alex,
Please note that with this code, if the number of steps you want all motors to run is below 500, they will run at a constant speed without acceleration.  You can disable this feature by changing "#define CONST_STEPS 500" to 1 instead of 500.
Xiaoping

Xiaoping Hu

unread,
Aug 3, 2017, 12:40:12 PM8/3/17
to accelstepper
Alex,
Did you try the code?
Xiaoping

On Tuesday, August 1, 2017 at 9:28:38 AM UTC-4, alex cohen wrote:

alex cohen

unread,
Aug 7, 2017, 4:51:10 PM8/7/17
to accelstepper
Thank you so much for the code! 

Yes today I made some tweaks to adapt it to what I need and everything works perfectly :)

So this code works for 4 motors, how did you adapt it to control more than that with a single Arduino?

Xiaoping Hu

unread,
Aug 7, 2017, 5:00:31 PM8/7/17
to accels...@googlegroups.com
I used 4 arduinos

To unsubscribe from this group and all its topics, send an email to accelstepper+unsubscribe@googlegroups.com.

Xiaoping Hu

unread,
Aug 8, 2017, 7:00:15 AM8/8/17
to accels...@googlegroups.com
You know, another solution is to make a board on Arduino Mega yourself.  Arduino Mega has 54 digital pins, which means you could potentially drive 27 step sticks.  And this board is not difficult at all.  All the components are on the step sticks; this drive board only has connectors and capacitors.  I was thinking of doing it, but didn't do it because I didn't have that many motors to drive.  If I have more than 20 motors, I probably would have.  But I myself don't have the capability, I have to ask someone to do it for me, that was the main reason why I didn't do that.

To unsubscribe from this group and all its topics, send an email to accelstepper+unsubscribe@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages