MultiStepper example 'positions' array

1,395 views
Skip to first unread message

krazyeg

unread,
Oct 18, 2016, 6:11:07 PM10/18/16
to accelstepper
Looking at the example included with the MultiStepper library

void setup() {
  Serial.begin(9600);

  // Configure each stepper
  stepper1.setMaxSpeed(100);
  stepper2.setMaxSpeed(100);

  // Then give them to MultiStepper to manage
  steppers.addStepper(stepper1);
  steppers.addStepper(stepper2);
}

void loop() {
  long positions[2]; // Array of desired stepper positions
  
  positions[0] = 1000;
  positions[1] = 50;
  steppers.moveTo(positions);
  steppers.runSpeedToPosition(); // Blocks until all are in position
  delay(1000);
  
  // Move to a different coordinate
  positions[0] = -100;
  positions[1] = 100;
  steppers.moveTo(positions);
  steppers.runSpeedToPosition(); // Blocks until all are in position
  delay(1000);
}

The steppers.moveTo(positions) command has me confused without specifying element numbers, especially since it's just one dimension and in this case dealing with 2 different values, Im guessing the element positions[0] refers to stepper1, and so on?...

Can I create something like positions[1000] and load it up with whatever; then create a loop to iterate through?

Thanks folks...

Mike McCauley

unread,
Oct 18, 2016, 6:24:25 PM10/18/16
to accels...@googlegroups.com
Hello,
Yes. This is described in the documentation.

>
> Can I create something like positions[1000] and load it up with whatever;
> then create a loop to iterate through?

Yes.

>
> Thanks folks...

--
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

krazyeg

unread,
Oct 18, 2016, 9:30:40 PM10/18/16
to accelstepper
Awesome!!!!! I finally got it, X-Y interpolation with a lookup table. Draws ellipses like a champ! More smooth than I expected.

francisco barcenas

unread,
Oct 23, 2016, 8:03:17 PM10/23/16
to accelstepper
my arduino does not recognize the #include <MultiStepper.h>, what did you do ?

Carlos Zurbriggen

unread,
May 29, 2020, 4:05:01 PM5/29/20
to accelstepper
tenes que instalar la libreria
Reply all
Reply to author
Forward
0 new messages