# 3 Axis Interpolation

• posted

Hi,

I'm making a PIC controlled CNC machine and I encountered a problem with simultaneous axis movement. Foe example I need to move the X axis 20mm, Y

41mm and Z 123mm at the same time. There are two modes:
1. all of the axes arrive at their endpoints at the same time
2. they step together and when each of them arrives at their destination they stop while the others continue

#1 is more important!

If anyone knowes of an algorithm, please share it Thanx

• posted

In short you Compare the size of X & Y. Set up a loop counter the same size as the Larger. Step the Larger axis on each iteration of the loop. Step the smaller axis every 'n' iterations, where n is the Integer of the larger divided by the smaller. Hope that makes sense...

Take a look at

for a useful resource.

Good luck with it, J>

• posted

Assuming the point you are at is P1, and point you wanna get to is P2, find the largest coordinate difference: dX = Px2 - Px1 dY = Py2 - Py1 dZ = Pz2 - Pz1 dMax = MAX(MAX(dX,dY),dZ);

Calculate the step size for each direction stepX = dX / dMax; stepY = dY / dMax; stepZ = dZ / dMax;

initialize loop variables and perform motion: x = Px1;y = Py1;z = Pz1; for (i = 1;i < dMax; i++ ) { x = x + stepX; y = y + stepX; z = z + stepX; setPosition(x,y,z); }

Note that this can be done with fixed-point arithmetic, "stepN" variable size in floating point is always between 0.0 - 1.0 If you want to compute constant speed for motion properly, you need to use real vector magnitude instead of simply dMax, thats SQRT((Px2-Px1)^2 + (Py2-Py1)^2 + (Pz2-Pz1)^2 )

-kert

PolyTech Forum website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.