How to use...

Milling un-even surfaces / Z-heigh compensation

11min


automatically un-even surfaces

Intended use

The compensation is intended for relatively small compensation with natural smooth behavior. The compensation profile is directly added to the motion of the Z axis. The acceleration profile therefore is determined by the shape of the compensation.

If the compensation is not continuous, then depending of the quantity of it and the speed in which the moves are done this may lead to position loss with open-loop stepper motor systems or position following error with closed loop systems. relatively

Milling PCB’s is one example:

Milling PCB with Z-compensation
Milling PCB with Z-compensation




The Coordinates TAB contains the functionality to measure the unevenness:

Document image


Start measurement

Will pop up an interpreter dialog for explained measurement using a touch automatically.

Move to start position.

Will move X and Y to the first measured position, where the compensation is zero.

Save measurement

It will open a file-save dialog and allow you to save the measurement data.ow you to save the measurement data. allows to save the mesurement data.

“Load"

Shows Wil shows some statics of the measured data, the max and minimum correction values, and at which place they are. file-open dialog to load existing measurement data.

“Check measurement”

Will shows some statics of the measured data, the max and minimum correction values, and at which place they are.

“ZheightComp ON”

Wil switch the compensation ON/OFF.

It will be shown in the position read out, the compensation value is shown above the normal work position of Z.

Now you can do normal XY engraving and while the Z is compensated using the measurement values.

Starting the measurement

You specify the number of measurements in X and Y.The height to which the probe should move to when going to the next point.

The minimum Z value to which the probe should move to during the measurement (G38.2).

The size of the grid, distance between the measuring points.And the feed for the down movement during G38.2. All other moves use G0 for highest speed.

The measurement starts at WORK X0 Y0. Max Z and Min Z are also WORK coordinates.The measurement data itself is in machine coordinates, so after the measurement you can freely zero anywhere else on the work piece.

This is the subroutine to be added in the standard macro.cnc for this purpose.

If you have a self-modified macro.cnc, you can copy from default_macro.cnc to your own macro.cnc

sub zhcmgrid ;;;;;;;;;;;;; ;probe scanning routine for eneven surface milling ;scanning starts at x=0, y=0 if [#4100 == 0] #4100 = 10 ;nx #4101 = 5 ;ny #4102 = 40 ;max z #4103 = 10 ;min z #4104 = 1.0 ;step size #4105 = 100 ;probing feed endif #110 = 0 ;Actual nx #111 = 0 ;Actual ny #112 = 0 ;Missed measurements counter #113 = 0 ;Number of points added #114 = 1 ;0: odd x row, 1: even xrow ;Dialog dlgmsg "gridMeas" "nx" 4100 "ny" 4101 "maxZ" 4102 "minZ" 4103 "gridSize" 4104 "Feed" 4105 if [#5398 == 1] ; user pressed OK ;Move to startpoint g0 z[#4102];to upper Z g0 x0 y0 ;to start point ;ZHCINIT gridSize nx ny ZHCINIT [#4104] [#4100] [#4101] #111 = 0 ;Actual ny value while [#111 < #4101] if [#114 == 1] ;even x row, go from 0 to nx #110 = 0 ;start nx while [#110 < #4100] ;Go up, goto xy, measure g0 z[#4102];to upper Z g0 x[#110 * #4104] y[#111 * #4104] ;to new scan point g38.2 F[#4105] z[#4103];probe down until touch ;Add point to internal table if probe has touched if [#5067 == 1] ZHCADDPOINT msg "nx="[#110 +1]" ny="[#111+1]" added" #113 = [#113+1] else ;ZHCADDPOINT msg "nx="[#110 +1]" ny="[#111+1]" not added" #112 = [#112+1] endif #110 = [#110 + 1] ;next nx endwhile #114=0 else ;odd x row, go from nx to 0 #110 = [#4100 - 1] ;start nx while [#110 > -1] ;Go up, goto xy, measure g0 z[#4102];to upper Z g0 x[#110 * #4104] y[#111 * #4104] ;to new scan point g38.2 F[#4105] z[#4103];probe down until touch ;Add point to internal table if probe has touched if [#5067 == 1] ZHCADDPOINT msg "nx="[#110 +1]" ny="[#111+1]" added" #113 = [#113+1] else ;ZHCADDPOINT msg "nx="[#110 +1]" ny="[#111+1]" not added" #112 = [#112+1] endif #110 = [#110 - 1] ;next nx endwhile #114=1 endif #111 = [#111 + 1] ;next ny endwhile g0 z[#4102];to upper Z ;Save measured table ZHCS zHeightCompTable.txt msg "Done, "#113" points added, "#112" not added" else ;user pressed cancel in dialog msg "Operation canceled" endif endsub
;Add point to internal table if probe has touched
#110 = [#110 + 1] ;next nx
;odd x row, go from nx to 0
#110 = [#4100 - 1] ;start nx
while [#110 > -1]
;Go up, goto xy, measure
g0 z[#4102];to upper Z
g0 x[#110 * #4104] y[#111 * #4104] ;to new scan point
g38.2 F[#4105] z[#4103];probe down until touch
if [#5067 == 1]
msg "nx="[#110 +1]" ny="[#111+1]" added"
endif
endwhile

Milling un-even cylinders with y->a mapping on also works.In that case the measurement must be done using with y->a mapping on.

The compensation works only in the measured range. So of the mapping is measured between 0-360 degrees for A, it will not compensate for e.g. 370 degrees.

The Z height compensation interpreter commands

For your own use if you want to customize the working:

ZHCINIT <grid size in mm> <number of points in X> <number of points in Y>

This is the first command required before starting a measurement, it will reserve the correct amount of memory to store the measured points.

ZHCINITEX <grid sizeX> <grid sizeY> <n of points in X> <n of points in Y>

Instead of ZHCINIT you can use ZHCINITEX.

The difference with ZHCINIT is that this allows different grid sizes for X and Y.

Using G38.2 will do the actual measurement.

ZHCADDPOINT will add the last measured point to the data.

ZHCS <fileName> will store the data to a file.

ZHCL <fileName> will load the data from a file.

ZHC [ON | OFF] will switch the compensation on.

#5151 contains 1 if ZHC is ON and 0 if OFF. This can be used for run time checks if the compensation is on. In case of tool change, you will probably want to switch it off and switch it back ON after the tool change.