Uncategorized

Adapting Makelangelo to CoreXY kinematics

Mike wrote in on our live chat to talk about his CoreXY kinematics. Seems there’s no open source Arduino code to drive his new system and – being a smart guy who does his homework – he reached out to the people with experience. Long time readers will know that I started a Jigsaw solving robot last year and that I intend to finish it in May. Seems like interest in CoreXY has just exploded since then, and this was a wake up call.

With the changes described below you should be able to draw images using the Makelangelo software on your CoreXY system. Video proof, too!

Video

For the uninitiated, this is what a CoreXY system looks like.

Differences

The Makelangelo firmware can be adapted to a CoreXY system without much trouble. The electronics and the motors stay the same (phew!)

The physical shape of the machine and the way the belts push/pull is very different. Fortunately there’s only one place in the code that cares about the physical shape. Both versions of the Makelangelo firmware have methods called IK() and FK().

Inverse Kinematics

Inverse kinematics is like asking “how do I get there?” You give an IK method “I want to be at coordinate X,Y” and it sends back “how many motor steps to get there from the starting spot”.

[code]void IK(float x, float y, long &l1, long &l2) {
// find length to M1
float dy = y – limit_top;
float dx = x – limit_left;
// steps for motor 1
l1 = floor( sqrt(dx*dx+dy*dy) / THREADPERSTEP1 );
// steps for motor 2
dx = limit_right – x;
l2 = floor( sqrt(dx*dx+dy*dy) / THREADPERSTEP2 );
}[/code]

This code is written for a polargraph machine, so the belt lengths have to use pythagoras’ theorem to find the right length. A CoreXY, on the other hand, is a lot more straightforward.

CoreXY reference

As we can see from the picture above (graciously permitted by corexy.com) the L1 is X+Y and the L2 = X-Y. In code, that would look like

[code]void IK_CoreXY(float x, float y, long &l1, long &l2) {
l1 = floor((x+y) / THREADPERSTEP1);
l2 = floor((x-y) / THREADPERSTEP2);
}[/code]

Forward Kinematics

Forward kinematics is the opposite of Inverse Kinematics. You give an FK method “this is how far I moved from the origin” and it says “then you are at X,Y.” If your routines are both correct then FK(IK(X,Y)) = for any X,Y.

[code]A = X + Y
B = X – Y

// therefore

X = A – Y
X = B + Y
Y = X – B

// replace Y

X = A – ( X – B )
2X = A + B
X = ( A + B ) / 2[/code]

…and we already have the solution for Y given X and B. Let’s put that into code!

[code]void FK_CoreXY(long l1, long l2, float &x, float &y) {
l1 *= THREADPERSTEP1;
l2 *= THREADPERSTEP2;

x = (float)( l1 + l2 ) / 2.0;
y = x – (float)l2;
}[/code]

Video

Final thoughts

Special thanks to Mike for the inspiration and the sweet follow up video.

See Also