# Distance control (sensed spindles) (DIST_CTRL)

## Release Note

The availability of this function depends on the configuration and on the version scope.

If the tool-supporting axis (spindle axis) is equipped with the necessary hardware, this function specifies the distance of the tool to an uneven workpiece surface. The distance is detected by a measuring system and is continuously tracked by the NC on the uneven surface.

The distance control for a sensed spindle is enabled by the parameter P-AXIS-00328. It is activated by the following NC command. For more information please refer to the functional description "Distance control” [FCT-M3]

Syntax:
<axis_name> [DIST_CTRL [ON [ DRYRUN ] [ CONST_DIST ]] | [OFF | CHECK_POS | FREEZE | REF] SET_POS=.. SET_DIST=.. [ KP=.. ] [ I_TN=.. ] [ D_TV=.. ] [ FILTER_TYPE=.. ] [ N_CYCLES=.. ] [ FG_F0=.. ] [ ORDER=.. ] [ SMOOTH_FACT=.. ] [ KALMAN_SIGMA=.. ] [ NO_MOVE ] [ VAL1=.. - VAL5=.. ] { \ } ]

<axis_name> | Name of the axis supporting the tool.
DIST_CTRL | Identifier for the "Sensed spindles” function. Must always be programmed as the first keyword.
ON | Distance control on when workpiece surface is specified. A set position (SET_POS) must be set at switch-on.
CONST_DIST | Activate distance control (ON) when a constant distance to the workpiece surface is specified. A distance must be set with SET_DIST at switch-on. [as of Build V2.11.2804.03]
OFF | Deactivate distance control.
CHECK_POS | Check whether position is within the tolerance window.
FREEZE | Freeze the control distance across the workpiece. The axis position or the output correction value is maintained. Axis tracking is interrupted.
DRYRUN | In combination with ON, the axis is not tracked in DRYRUN mode when there are changes in the workpiece surface. This allows data to be evaluated without feedback from the controller (e.g. filter effect). [as of V3.1.3079.23] When distance control is activated, a set position must be set with SET_POS if the workpiece surface is specified.

When distance control is activated, a set distance must be set with SET_DIST if a constant distance from the workpiece surface is specified.

REF | Reference measuring system (sensor) (only if there is no absolute measuring system).

SET_POS=.. | Specify the workpiece surface in [mm, inch] (absolute position). In the event of reset or program end, the set position is reset, i.e. a new set position must be specified before distance control is reactivated.
SET_DIST=.. | Specify the constant distance to the workpiece surface in [mm, inch]. In the event of reset or program end, the distance is reset, i.e. a new distance must be specified before distance control is reactivated.
KP=.. | Weighting the distance control output values. Parameterisation can be executed analogous to P-AXIS-00759. The value range is limited to 0.0 < KP <= 2.0. For KP values less than 1.0, the distance control dynamics are reduced; for KP values greater than 1.0, the dynamics are increased.

A KP factor less than 1.0 reduces 1 possible distance control oscillation and steadies control in the event of minor distance errors. [as of V2.11.2809.06 or V3.1.3079.06]

I_TN=.. | Integral action time of the PID controller in [s]. The integral action time defines the time after which the P and I components of the manipulated variable are equal. Parameterisation can be executed analogous to P-AXIS-00764. The value range is limited to 0.0 <= I_TN <= 50.0. A large integral action time produces greater control stability. The shorter the integration action time, the greater the I component and the faster the control. A short integral action time excites oscillations more strongly. [as of V2.11.2809.06 or V3.1.3079.06]
D_TV=.. | Derivative action time of the PID controller in [s]. The derivative action time defines the time after which the P and D components of the manipulated variable are equal. Parameterisation can be executed analogous to P-AXIS-00765. The value range is limited to 0.0 <= D_TV <= 2.0. The larger the derivative action time, the stronger the D component. [as of V2.11.2809.06 or V3.1.3079.06]
FILTER_TYPE=.. | Filter type to filter sensor values according to P-AXIS-00782. [as of V3.1.3079.23]
N_CYCLES=.. | Number the measured values used for filtering according to P-AXIS-00413. [as of V3.1.3079.23]
FG_F0=.. | Cut-off frequency for the low-pass filter in [Hz] according to P-AXIS-00508. [as of V3.1.3079.23]
ORDER=.. | Order of the low-pass filter according to P-AXIS-00507. [as of V3.1.3079.23]
SMOOTH_FACT=.. | Smoothing factor of the exponential averaging filter according to P-AXIS-00784. Specifies the weighting of the current measured value.
KALMAN_SIGMA=.. | Uncertainty of the included measured values according to P-AXIS-00783. [as of V3.1.3079.23]
NO_MOVE | By default, the resulting correction offset is deactivated when distance control is switched off. This motion can be suppressed by specifying NO_MOVE in combination with OFF. The channel is initialised with the changed axis position. The position offset is only deactivated at the next axis motion programmed in the NC program.
VAL1=..-VAL5=.. | Five freely assignable values in real format.
\ | Separator ("backslash") for clear programming of the command over multiple lines.

The keywords ON/OFF, FREEZE, DRYRUN, CHECK_POS and REF in the same command sequence mutually cancel each other out.

The keywords SET_POS, SET_DIST and VAL1-VAL5 can always be programmed in combination with each other.

## Notice

If distance control is still active at program end, it is not automatically deselected.

When a reset or axis error occurs, active distance control is always deselected automatically.

## Notice

Parameters of the PID controller are not reset at program end.

## Programing Example

Programming examples for distance control

%DIST_1

; Set expected position of the workpiece surface

N10 Z[DIST_CTRL SET_POS=30]

N20 Z[DIST_CTRL ON] ;Select

; …

Nxx Z[DIST_CTRL OFF] ;Deselect

N999 M30

%DIST_2

; Select + set expected position of the workpiece surface

N10 Z[DIST_CTRL ON SET_POS=30]

; …

Nxx Z[DIST_CTRL FREEZE] ;Hold position

; …

Nxx Z[DIST_CTRL OFF] ;Deselect

N999 M30

%DIST_3

; Select + set expected position of the workpiece surface

N10 Z[DIST_CTRL ON SET_POS=50]

; Deactivate distance control; Z axis does not move

Nxx Z[DIST_CTRL OFF NO_MOVE]

; The generated compensation offset is included for motion to the target point
; 100.

Nxx G0 Z100

N999 M30

%DIST_4

; Set distance parameters

N10 Z[DIST_CTRL SET_POS=30 SET_DIST=10]

; Select with specified workpiece surface (SET_POS)

N20 Z[DIST_CTRL ON]

; …

Nxx Z[DIST_CTRL OFF] ;Deselect

; …

; Select with specified workpiece surface (SET_DIST)

Nxx Z[DIST_CTRL ON CONST_DIST]

; …

Nxx Z[DIST_CTRL OFF ;Deselect

N999 M30

%DIST_5

N10 Z[DIST_CTRL FILTER_TYPE=KALMAN_MA] ;Select filter type

; Parametrise filter

N20 Z[DIST_CTRL N_CYCLES=30 KALMAN_SIGMA=1000]

; Activate distance control

N30 Z[DIST_CTRL ON CONST_DIST SET_DIST=1].

; …

; Change filter

Nxx Z[DIST_CTRL FILTER_TYPE=KALMAN_EXPO SMOOTH_FACT=0.3]

.

.

Nxx Z[DIST_CTRL OFF]; Deselect

N999 M30