Distance control (M3)

1.1 Distance control PAGEREF _Toc307300893 \h4

1.2 Description 8

1.3 Programming 9

1.4 PLC interface 11

1.4.1 Distance control states and transitions 11

1.4.2 Control command for distance control 14

1.5 Parameters 15

1.5.1 Overview 15

1.5.2 Description 19

1.6 Error messages 20

1.6.1 Overview 20

1.7 Test example with drive simulation 21

More:

button Distance control

button Description

button Programming

button PLC interface

button Parameters

button Error messages

button Test example with drive simulation


Distance control

Task

By means of electronic probe systems or sensors, movements are generated that are to superimpose the axes' programmed positions during interpolation of an NC program.

As a result, it is possible to easily implement distance control (e.g. touching a curved surface of a plate) or height control (e.g. compensation for thickness tolerances of the workpiece) with the control system.

Characteristics

A second measurement system is connected to the control system via a sensor. By means of this measurement system, axis-specific compensation values can be output to an axis in addition to the interpolated setpoint, thus correcting the actual position of the axis.

Distance control is activated or deactivated in the NC program.

Variables relevant to distance control can be parameterised via the axis machine data.

Distance control operates in the control system's interpolation cycle.

Distance control currently is available for SERCOS, Profidrive or CANopen drives only.

Parameterisation overview

The movement generated via the distance control can be influenced via machine data.

- Activation of an average filter

- Maximum permissible correction value

- Maximum additive speed of the axis

- Maximum permissible actual value change of the probe system

- Maximum top axis position

- Minimum bottom axis position

- Tolerance value

These are activated or deactivated via the NC program.

Configuration overview

The sensor of the electronic probe system is connected to the controlled axis as a actual value sensor 2. Make sure that the first configured sensor is used for position control of the axis, and the second sensor for distance control.

Figure 1-1: TwinCAT configuration example for SERCOS (Ident S-0-0053)

Figure 1-2: TwinCAT configuration example for CANopen DS402 (PDO 0x60E4, Subindex 1)

Figure 1-3: TwinCAT configuration example for ProfiDrive (G1_XIST2)

The axis-specific override acts on distance control. When override is 0, distance control is no longer active, and the current value is frozen.


Description

Operating mode of distance control

Distance control is integrated after interpolation and, if necessary, superimposes the programmed movement. Distance control acts independently of the interpolator's current status, and is active even when waiting for acknowledgements (e.g. M functions).

Distance control determines the actual absolute position of the workpiece surface with the aid of the motor encoder of the axis and an additional sensor. The two sensors are coupled to one another, i.e. the two sensors' values always change in mutual opposition when the axis moves.

Figure 1-4: Probing the workpiece surface

Calculation of
deviation

With the aid of electronic probing, the deviation of the real workpiece surface from the specified set position (SET_POS) is determined in each cycle. It results from:

Deviation = sensor 1 + sensor 2 - set position (SET_POS)

= actual workpiece surface position - set position (SET_POS)

To compensate for the workpiece surface deviation, the drive position is additionally moved by the calculated offset of the distance control:

Drive setpoint = programmed setpoint (PCS) + distance control offset

Figure 1-5: Block diagram of distance control

Selecting and
cancelling via the
NC program

Distance control is activated or deactivated, or the current correction value is also frozen, via the NC program.

Example:

N10 Z[DIST_CTRL SET_POS=30] Set position

N10 Z[DIST_CTRL ON] Selection

Nxx Z[DIST_CTRL OFF] Cancellation

N999 M30

The complete CNC syntax is described in chapter 1.3 .

Typical sequence

Typical sequence when activating distance control:

- The tool is loaded.

- X and Y axes move to machining position

- Distance control is activated and the workpiece's set position is set

- Z axis moves down

- Sensor or probe ring reports distance

- Distance control is active; thickness tolerances or position differences are compensated

Deactivating distance control:

- Distance control is deactivated via the NC program

- Distance control is inactive, thickness tolerances or position differences are no longer compensated, and the current offset remains active until the next position request.

Principle of operation

With distance control, deviations in the position of the workpiece surface (actual position) with respect to a specified set position can be corrected:

Figure 1-6: Ideal workpiece

Deviation

A deviation from the ideal workpiece surface (e.g. in the case of a thinner workpiece) is detected by the sensor (sensor 2):

Figure 1-7: Real workpiece without distance control

Offset compensation

After activation of distance control with SET_POS=20 mm (expected workpiece height), the offset is compensated by the distance control. As a result, there is no need to adapt the NC program (PCS position):

Figure 1-8: Real workpiece with distance control

In case of an axis error, CNC reset or at program end of the NC channel, which did instruct the axis, the distance control is automatically deselected.


Programming

<Axis_name> [ DIST_CTRL [ON | OFF] | [CHECK_POS | FREEZE | REF] SET_POS<expr>
 [VAL1<expr> -VAL5<expr>] ]

<Axis_name> Name of the axis carrying the tool

DIST_CTRL Identifier for the "sensed spindles" functionality. This must always be programmed as the first key word.

ON Activate distance control. A set position (SET_POS) must be set before activation

OFF Deactivate distance control.

CHECK_POS Check whether position is in the tolerance window.

FREEZE Freeze the control distance over the workpiece. The axis position or the output correction value is maintained, i.e. readjustment of the axis depending on the workpiece surface is interrupted.

REF Measurement system (sensor) referencing (only if there is no absolute measuring system)

SET_POS<expr> Specification of the workpiece surface [mm] (absolute position). At the end of the program or in the event of a reset, the set position is reset, i.e. a new set position must be specified before distance control is activated.

VAL1<expr>-VAL5<expr> Freely assignable values (5)

The key words ON/OFF, FREEZE, CHECK_POS and REF are mutually excusive in the same command. The key words SET_POS and VAL1-VAL5 can always be included in the programming in combination. If the function is still active at the end of the program, it is cancelled automatically (implicit "OFF").

Programming examples

%DIST_1

N10 Z[DIST_CTRL SET_POS=30] Set required position of the workpiece surface

N20 Z[DIST_CTRL ON] Selection

:

Nxx Z[DIST_CTRL OFF] Cancellation

N999 M30

%DIST_2

N10 Z[DIST_CTRL ON SET_POS=30] Selection + set expected position of workpiece surface

:

Nxx Z[DIST_CTRL FREEZE] Hold position. End readjustment.

:

Nxx Z[DIST_CTRL OFF] Cancellation

N999 M30


PLC interface

More:

button Distance control states and transitions

button Control command for distance control


Distance control states and transitions

Alternative
commanding via
PLC interface

In addition to the NC program, distance control can also be commanded via the PLC interface (see [HLI]) by specifying the required status transitions (e.g. activating or deactivating) and set positions via the DistanceControl control unit. The prerequisite is that distance control is activated for the axis (see P-AXIS-00328).

The current status of distance control can be viewed in the status of the DistanceControlcontrol unit. The control unit's status also includes the current actual position of the workpiece surface and the currently output position offset.

Distance control has five internal states, which are shown in Figure 1-9 together with the permissible transitions. Transitions shown with a dashed line, for example a transition to the error state, take place automatically and cannot be commanded.

Figure 1-9: Distance control state graph and transitions

The following tables contain a detailed description of the states and possible transitions.

Table 1-1: Distance control states

State | Meaning
HLI_DIST_CTRL_STATE_INACTIVE | Distance control is deactivated. The output offset (ActualOffset) is zero.
HLI_DIST_CTRL_STATE_TURNING_OFF | Distance control has been deactivated. The currently active offset (ActualOffset) is moved to. As soon as it is zero, the program switches automatically to the INACTIVE state.
HLI_DIST_CTRL_STATE_FREEZE | Distance control is active. The offset (ActualOffset) is frozen, i.e. the axis is not adjusted to the workpiece surface.
HLI_DIST_CTRL_STATE_ACTIVE | Distance control is active and adjusts the axis to the workpiece surface.
HLI_DIST_CTRL_STATE_ERROR | Distance control is in the error state, e.g. due to an incorrect state transition or due to an error in the position controller. Only a transition to TURNING OFF is possible out of this state.

Table 1-2: Permissible transitions

Transition | Meaning
HLI_DIST_CTRL_ON | Distance control is activated. On activation, a set position for the workpiece surface must be passed on. If no absolute position sensor is used, distance control must be referenced beforehand.
HLI_DIST_CTRL_OFF | Distance control is deactivated. The program switches to the TURNING OFF state, in which the position offset is travelled out. The program then switches automatically to the INACTIVE state.
HLI_DIST_CTRL_FREEZE | The current position offset is frozen. Adjustment of the axis to the actual workpiece surface is ended.
HLI_DIST_CTRL_REF | Referencing of distance control if no absolute position sensor is used. Referencing is allowed only in the INACTIVE state. A reference position must also be passed on for this transition.


Control command for distance control

Commanding distance control

Description

Distance control of the axis can be influenced via this control unit (see [HLI - ] ). The prerequisite is that it is activated in the axis parameters (see P-AXIS-00328).

Data type

MCControlDistCtrlUnit, see description: [HLI - Control unit with usage check]

Access

PLC reads State and Writes Command + Enable

ST path

pAC[axis_idx]^.addr^.McControlLr_Data.MCControl_DistanceControl

Usage check

ST element

. X_CommandSemaphor

Signal flow

PLC -> CNC

Data type

BOOL

Access

CNC takes over the commanded value, if this element is TRUE. After successful take-over CNC sets this value on FALSE.

PLC sets this value on TRUE, if the commanded value is released by the CNC for take-over. An actualization of commanded values by the PLC is only possible, if this element value is FALSE.

Commanded value

ST element

.Command

Signal flow

PLC -> CNC

Data type

HLIDistanceControlCommand

Access

PLC writes

Distance control state

ST element

.State

Signal flow

CNC -> PLC

Data type

HLIDistanceControlState

Access

PLC reads

Redirection

ST element

. X_Enable

Distance control status
Description | The status of distance control can be read in this entry.
Signal flow | PLC -> CNC
Data type | HLIDistanceControlState
ST path | pAC[axis_idx]^.addr^.McControlLr_Data.MCControl_DistanceControl.State
Access | PLC reads
Elements of the data type
Element | .D_State
Data type | UDINT
Access | PLC reads
Value range | 0 = HLI_DIST_CTRL_STATE_INACTIVE 1 = HLI_DIST_CTRL_STATE_ACTIVE 2 = HLI_DIST_CTRL_STATE_FREEZE 3 = HLI_DIST_CTRL_STATE_TURNING_OFF 4 = HLI_DIST_CTRL_STATE_ERROR
Description | · ..INACTIVE: distance control is off · ..ACTIVE: distance control is active, axis is adjusted to the workpiece surface · ..FREEZE: distance control is active, but the position offset is frozen. No adjustment to workpiece surface · ..TURNING_OFF: distance control is being deactivated · ..ERROR: error state
Element | .D_ActualPosition
Data type | DINT
Access | PLC reads
Value range | 0.1 µm or 0.0001°
Description | This data item indicates the current actual position of the workpiece surface that sensing control has determined.
Peculiarities | This data item is entered only if distance control is activated in the axis parameters (see P-AXIS-00328).
Element | .D_ActualOffset
Data type | DINT
Access | PLC reads
Value range | 0.1 µm or 0.0001°
Description | This data item indicates the current position offset of distance control by which the axis has been moved due to deviations between the actual workpiece surface and the specified position (SET_POS). The following applies in the stationary state (constant workpiece surface and position offset completely travelled out): position offset = SET_POS  D_ActualPosition.
Peculiarities | This data item is entered only if distance control is activated in the axis parameters (see P-AXIS-00328).

Command for distance control

Description

Distance control can be commanded in this entry.

Signal flow

PLC -> CNC

Data type

HLIDistanceControlCommand

ST path

pAC[axis_idx]^.addr^.McControlLr_Data.MCControl_DistanceControl.Command

Access

PLC writes

Elements of the data type

Element

.D_ Transition

Data type

UDINT

Access

PLC writes

Value range

0 = HLI_DIST_CTRL_OFF

1 = HLI_DIST_CTRL_ON

2 = HLI_DIST_CTRL_FREEZE

3 = HLI_DIST_CTRL_REF

Description

· HLI_DIST_CTRL_OFF: distance control is deactivated

· HLI_DIST_CTRL_ON: set position is set and distance control is activated. On activation, a set position must also always be passed on in the "Position" data item.

· HLI_DIST_CTRL_FREEZE: position offset of distance control is frozen and adjustment of the axis to the actual workpiece surface is ended.

· HLI_DIST_CTRL_REF: reference position of the sensor (position) is set. The reference position must also be passed on in the "Position" data item.

ST element

.D_Position

Data type

DINT

Value range

[DINT_MIN, DINT_MAX]

Description

The meaning depends on the commanded transition:

HLI_DIST_CTRL_ON: set position of the workpiece surface (SET_POS)

HLI_DIST_CTRL_REF: reference position of the workpiece surface (REF_POS)


Parameters

More:

button Overview

button Description


Overview

ID | Parameter | Description
P-AXIS-00328 | lr_param.distance_control_on | Activates the distance control functionality
P-AXIS-00413 | kenngr.distc.n_cycles | Number of points for average filter of the sensor signal
P-AXIS-00414 | kenngr.distc.max_deviation | Maximum permissible correction value [0.1 µ m]
P-AXIS-00415 | kenngr.distc.v_max | Maximum permissible speed for distance control [ µ m/s]
P-AXIS-00416 | kenngr.distc.a_max | Maximum permissible acceleration for distance control [mm/s^2]
P-AXIS-00417 | kenngr.distc.max_act_value_change | Maximum permissible change of the sampling signal within one cycle [0.1 µ m/cycle]
P-AXIS-00418 | kenngr.distc.ref_offset | Offset to the reference point
P-AXIS-00419 | kenngr.distc.max_pos | Sensor's high limit
P-AXIS-00420 | kenngr.distc.min_pos | Sensor's low limit
P-AXIS-00421 | kenngr.distc.tolerance | Tolerance band
P-AXIS-00428 | kenngr.distc.check_sw_limit_switch | Consideration of the calculated offset of distance control in software limit switch monitoring.
P-AXIS-00422 | lr_hw[1].encoder_resolution_num | Distance resolution of the sensor measuring system (numerator) [increments]
P-AXIS-00423 | lr_hw[1].encoder_resolution_denom | Distance resolution of the sensor measuring system (denominator) [0.1 µ m]
P-AXIS-00230 | lr_hw[1].vz_istw | Sign reversal of actual sensor values
P-AXIS-00424 | lr_hw[1].mode_act_pos | Definition of the sensor value range: linear scale or modulo handling of sensor values

Parameter example

kenngr.distc.n_cycles 10 # Cycle number, moving average filter probing sensor

kenngr.distc.max_deviation 2000000 # [0.1µm] Max. permissible deviation

kenngr.distc.v_max 1000 # [µm/s] Max. velocity of distance control

kenngr.distc.a_max 5000 # [mm/s2] Max. acceleration

kenngr.distc.max_act_value_change 5000000 # Max. change of sampling signal/cycle

kenngr.distc.ref_offset 0 # Offset reference point

kenngr.distc.max_pos 1000000 # [0.1µm] Max. position

kenngr.distc.min_pos -1000000 # [0.1µm] Min. position

kenngr.distc.tolerance 50000 # [0.1µm] Tolerance value of probing depth

kenngr.distc.check_sw_limit_switch 1 # Check dist. ctrl off. in sw. limit monit.


Description

P-AXIS-00328 | Activates the distance control functionality
Parameter | lr_param.distance_control_on
Description | This functionality must always be activated in the axis configuration to be able to activate distance control at all via the NC program.
Data type | BOOLEAN
Data range | TRUE / FALSE
Dimension | Translatory: - | Rotatory: -
Default | FALSE
Remarks | -

P-AXIS-00413 | Filtering of sensor values for distance control
Parameter | kenngr.distc.n_cycles
Description | In some cases, the sensor values are noisy. To keep excitation of the machine low, the setpoints for distance control can be smoothed via an average filter.
Data type | UNS32
Data range | 0 <= value < 10
Dimension | Translatory: - | Rotatory: -
Default | 4
Remarks | -

P-AXIS-00414 | Maximum position offset by distance control
Parameter | kenngr.distc.max_deviation
Description | The correction value of the axis that has been calculated via distance control must not exceed this machine data item. An error message is issued if this value is exceeded. The correction value is limited.
Data type | UNS32
Data range | 0 <= value < MAX_UNS32
Dimension | Translatory: 0.1 µ m | Rotatory: 1/10000 °
Default | 50000, is equivalent to 5 mm
Remarks | -

P-AXIS-00415 | Maximum speed at which a position offset is travelled out
Parameter | kenngr.distc.v_max
Description | Correction of the distance is limited dynamically with respect to the maximum speed to limit the resulting excitation.
Data type | UNS32
Data range | 0 <= value < MAX_UNS32
Dimension | Translatory: 1/1000 mm/s | Rotatory: 1/1000 ° /s
Default | 5000, is equivalent to 5 mm/s
Remarks | -

P-AXIS-00416 | Maximum acceleration at which a position offset is travelled out
Parameter | kenngr.distc.a_max
Description | Correction of the distance is limited dynamically with respect to the maximum acceleration to limit the resulting excitation. If no acceleration is specified, the maximum axis acceleration is used automatically (see P-AXIS-00008)
Data type | UNS32
Data range | 0 <= value < MAX_UNS32
Dimension | Translatory: 1 mm/s^2 | Rotatory: 1 ° /s^2
Default | 0, the maximum axis acceleration is used (see P-AXIS-00008)
Remarks | -

P-AXIS-00417 | Maximum permissible change of the measured distance within one cycle
Parameter | kenngr.distc.max_act_value_change
Description | After activation of distance control, the sensor's actual values are monitored for change. Actual value detection problems can be detected by setting a maximum value.
Data type | UNS32
Data range | 0 <= value < MAX_UNS32
Dimension | Translatory: 0.1 µ m | Rotatory: 1/10000 °
Default | 5000, is equivalent to 0.5 mm
Remarks | -

P-AXIS-00418 | Reference point offset for distance control measuring system
Parameter | kenngr.distc.ref_offset
Description | The value range of the sensor measuring system can be moved by an offset via this machine data item. This is necessary in the case of absolute position sensors, for example, to define the reference point, i.e. the sensor position that sets in if the spindle touches the ideal workpiece surface.
Data type | UNS32
Data range | 0 <= value < MAX_UNS32
Dimension | Translatory: 0.1 µ m | Rotatory: 1/10000 °
Default | 0, no position offset
Remarks | -

P-AXIS-00419 | Upper limit for measuring system
Parameter | kenngr.distc.max_pos
Description | The following value defines the upper limit of the sensor. An error message is generated if it is exceeded while distance control is active.
Data type | UNS32
Data range | 0 <= value < MAX_UNS32
Dimension | Translatory: 0.1 µ m | Rotatory: 1/10000 °
Default | 50000, is equivalent to 5 mm
Remarks | -

P-AXIS-00420 | Lower limit for measuring system
Parameter | kenngr.distc.min_pos
Description | The following value defines the lower limit of the sensor. An error message is generated if it is exceeded while distance control is active.
Data type | UNS32
Data range | 0 <= value < MAX_UNS32
Dimension | Translatory: 0.1 µ m | Rotatory: 1/10000 °
Default | -50000, is equivalent to - 5 mm
Remarks | -

P-AXIS-00421 | Tolerance band for limits
Parameter | kenngr.distc.tolerance
Description | Recording of actual values always returns changing values. Due to the tolerance band, values are also permissible that might be outside the configured limits. An error message is not generated.
Data type | UNS32
Data range | 0 <= value < MAX_UNS32
Dimension | Translatory: 0.1 µ m | Rotatory: 1/10000 °
Default | 0, is equivalent to 0 mm
Remarks | -

P-AXIS-00428 | Consideration of distance control in software limit switch monitoring
Parameter | kenngr.distc.check_sw_limit_switch
Description | This parameter defines, whether the calculated offset of distance control is considered in software limit switch monitoring (see [FCT-A2])
Data type | BOOLEAN
Data range | TRUE / FALSE
Dimension | Translatory: - | Rotatory: -
Default | FALSE, Offset of distance control is not considered in software limit switch monitoring.
Remarks | -

P-AXIS-00422 | Distance resolution of the sensor measuring system (numerator)
Parameter | lr_hw[1].encoder_resolution_num
Description | The sensor measuring system's distance resolution is specified as the quotient P-AXIS-00422/P-AXIS-00423 in the [increments/0.1 µ m] dimension for translatory axes or [increments/10^-4 ° ] for rotational axes. The number of sensor increments must be specified in P-AXIS-00422.
Data type | UNS32
Data range | 0 <= value < MAX_UNS32
Dimension | Translatory: increments | Rotatory: increments
Default | 1
Remarks | -

P-AXIS-00423 | Distance resolution of the sensor measuring system (denominator)
Parameter | lr_hw[1].encoder_resolution_denom
Description | The sensor measuring system's distance resolution is specified as the quotient P-AXIS-00422/P-AXIS-00423 in the [increments/0.1 µ m] dimension for translatory axes or [increments/10^-4 ° ] for rotational axes. The amount of the travel range must be specified in P-AXIS-00423.
Data type | UNS32
Data range | 0 <= value < MAX_UNS32
Dimension | Translatory: 0.1 µ m | Rotatory: 1/10000 °
Default | 1
Remarks | -

P-AXIS-00230 | Sign reversal of the sensor values
Parameter | lr_hw[1].vz_istw
Description | The sign of the sensor's encoder values can be inverted with this parameter
Data type | BOOLEAN
Data range | TRUE/FALSE
Dimension | Translatory: - | Rotatory: -
Default | FALSE
Remarks | FALSE = no inversion, TRUE = sign inversion of actual sensor values

P-AXIS-00424 | Definition of the sensor value range
Parameter | lr_hw[1].mode_act_pos
Description | In this parameter you can define whether the sensor positions are to be considered as linear or modulo values. By default, it can be handled according to the axis type or an individual default can be defined. When sensor values are handling according to the set axis type (see P-AXIS-00018), values are considered in a linear fashion for the TRANSLATOR axis type, while modulo handling applies to the ROTATOR axis type.
Data type | BOOLEAN
Data range | 0 / 1 / 2
Dimension | Translatory: - | Rotatory: -
Default | 0
Remarks | 0: according to axis type (default) 1: linear 2: modulo


Error messages

More:

button Overview


Overview

The following error messages can occur when distance control is active:

70329

70330

70331

70332

70333

70334

70335

70336

Actual value change of sensor signal greater than limit

Sensor extended completely

Excessive sensing deviation

Distance control still active at end of program

Distance control active for axis that is to be submitted.

On renewed selection, cancellation of distance control not yet complete

Distance control selected without programmed position

Functionality is not available


Test example with drive simulation

PLC test environment

Configuration of CAN drive

Simulation in PLC

Distance control from TwinCAT-CNC Build V2.10.1505.22

Configuration of a Z axis according to CANopen DS402 drive with additional distance sensor (0x60E4_01).

Simulation of CAN-PDO via PLC inputs/outputs

In PLC the drive encoder and also the distance sensor additionally are charged with a small random noise.

Turning on the drives

Moving on a set position

After setting of drive permission (drive on, torque, feedhold off) drive can be moved.

Referencing of
sensor,  sensor zero 

Entering the set position

Position=400000

Selection of distance control

Transition=1 (ON)

For the transmitted set position (SET_POS) the distance sensor delivers value = 0.

Changing the
surface position
  Surface offset 

The changed surface position results in a changing of the measured distance sensor.

This causes a re-adjusting of the real axis position until the distance sensor delivers the value = 0 again. In this case the desired distance to surface is reached.

 Froozing  of the
current hight

Transition=2 (FREEZE)

If distance control is interrupted (Transition = FREEZE = 2), in this time a changed sensor value (  20000) has no influence on the axis correction.

After re-activation of distance control the current sensor value is considered again.

Deselection

Transition=0 (OFF)

After deselection of distance control (Transition = OFF = 0) the position offset caused by the distance sensor is cancelled.