Hi, I just wanted to share a method for calibrating a rotary axis using the surface map function in MACH4.
I am going to mill some quite long pieces on a rotary axis, and I need them to be proportional along the whole length. The bed of my homemade router is not particularly even or flat, and the rotary axis is a low cost model – I do not really know how precise it is.
First I milled a square profile without any calibration applied, and checked the difference between the two ends – see attached PIC1. The width at end A was 0.7mm larger than the width at end B. To make it even all along the profile, the z position shall be 0.7 / 2 = 0.35mm lower at point A.
The next step is to define a working grid that shall be used by the surface map function. I use a minimal 2x2 grid, always given in machine coordinates. It is only inside the grid the surface map is active, so one needs to define it so that it contains the whole working piece in the x-y-plane. Outside the grid MACH4 will slide (up) to a non-compensated z-plane.
One needs to identify two points, P1 and P2 – see attached PIC2.
I have my machine origin at the upper right corner, so all my x/y-coordinates are negative. As my rotary axis lines up with the y-axis, I start defining the min/max y-values in the grid. When milling the pieces, the y-axis will move between -425 to -15 (i.e. A and B in PIC1). But I add a few millimetres at both ends, to safely stay inside the grid. So the final min/max y-values will be -428 to -12. This will have an unnoticeable effect on the calibration for my purpose. The min/max x-values need not be very precise for this setup, I use a wide range between -300 to 0.
The two grid points will be:
P1 = [-300,-428]
P2 = [0,-12]
Now I create a new map file called ‘rotary-axis.dat’. The file can be named whatever you like, but it must end with ‘.dat’ or ‘.map’ to be recognized by the surface map function. It is a plain text file and can be edited with any common text editor.
The file contents shall be as follows:
-300.0,0.0 ,2,
-428.0,-12.0,2,
-0.35,-0.35,
-0.0,0.0
Then I loaded the newly created file into the surface map function, and milled a square profile again. Now the difference in width was within 0.1mm all the way, so it worked very well for my purpose.
I have reverse-engineered the definition of the surface map files myself, so there is no guarantee it is 100% correct. But here is my interpretation of the file format.
xmin,xmax,nx,
ymin,ymax,ny,
z1,z2,. . .
. . .
. . .
. . . , zN-1,zN
The xmin/ymin and xmax/ymax values define the lower-left vs. upper-right grid (machine) coordinates (P1 and P2 in my example above). nx is the number of grid points along the x-axis, and ny is the number of grid points along the y-axis. Then follows [ny] rows with [nx] z-values in each row. The values of each row go from left to right, and the first row in the file is at the bottom part of the grid going upwards to the top of the grid. All values are separated by a comma, but not after the final value (the file will probably fail to load then).
In my manually edited example I had the top z-value set to 0.0. I think (not totally proven) that the surface map function scans all the z-values in the files and use the highest value found as ‘non-compensated’ z-level (as when moving outside the grid). All other z-values are automatically adjusted to the highest value.
Please note that it is important that all axes are referenced properly, otherwise the surface map will not activate (there is no warning message). The map file must also be formatted correctly, otherwise it will just fail to activate in the same way. I usually do a test with some exaggerated z-values in the map file to check that it loads correctly.
I hope someone might find this method useful.
Henrik