CoreXY using MultiStepper

437 views
Skip to first unread message

Stijn Verhelst

unread,
Jan 31, 2018, 9:00:32 AM1/31/18
to accelstepper
Hey 
For my end-project for school I'm making a 3d-printer. For the firmness I'm using the CoreXY principle.
















This means that we have 2 motors on one side of the printer that are controlling the whole XY-movements.

I'm planning to use the AccelStepper library to do the movements. But how can I achieve this? At myself I was thinking about using the MultiStepper function but I don't know if can work.

Any help is appreciated!

Best regards
Stijn

gregor

unread,
Jan 31, 2018, 3:04:03 PM1/31/18
to accelstepper
Hi, 

it is possible. Below is some code based off the MultiStepper.pde example file:
// MultiStepper.pde
// -*- mode: C++ -*-
// Use MultiStepper class to manage multiple steppers and make them all move to 
// the same position at the same time for linear 2d (or 3d) motion.

#include <AccelStepper.h>
#include <MultiStepper.h>

// EG X-Y position bed driven by 2 steppers
// Alas its not possible to build an array of these with different pins for each :-(
AccelStepper stepper1(AccelStepper::FULL4WIRE, 2, 3, 4, 5);
AccelStepper stepper2(AccelStepper::FULL4WIRE, 8, 9, 10, 11);

// Up to 10 steppers can be handled as a group by MultiStepper
MultiStepper steppers;

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() {
    if (/*new target positions are available*/)
    {
        long positions[2]; // Array of desired stepper positions

        //MultiStepper::moveTo takes absolute positions only
        positions[0] = stepper1.currentPosition() + deltaX;
        positions[1] = stepper2.currentPosition() + deltaY;

        steppers.moveTo(positions);
    }

    steppers.run();
}

Stijn Verhelst

unread,
Feb 1, 2018, 1:23:08 PM2/1/18
to accelstepper
Hey Gregor
Thanks for your help! But there is one problem: with this code can we calculate the X and Y positions of our printer, but what about the speed of the steppers. Does the speed need to be the same for by both the stepper motors achieving the correct position at the correct time?

Best regards
Stijn

gregor

unread,
Feb 1, 2018, 2:07:13 PM2/1/18
to accelstepper
MultiStepper is made for this - all steppers reaching their respective targets at the same time. You don't need to calculate the speeds yourself.

Stijn Verhelst

unread,
Feb 2, 2018, 1:13:50 AM2/2/18
to accelstepper
Thanks for your help!

Op donderdag 1 februari 2018 20:07:13 UTC+1 schreef gregor:
Reply all
Reply to author
Forward
0 new messages