MC_TableBasedPositionCompensation
The MC_TableBasedPositionCompensation function block is used to correct the axis position with a correction factor depending on the current axis position. The correction values must be stored in an equidistant, monotonically increasing table.
 Inputs
 Inputs
VAR_INPUT
    Enable         : BOOL;
    pTable         : POINTER To ST_PositionCompensationTableElement;
    TableSize      : UDINT;
    TableParameter : ST_PositionCompensationTableParameter;
    Ramp           : LREAL;
    DisableMode    : E_DisableMode;
    Options        : ST_PositionCompensationOptions;
END_VAR| Name | Type | Description | 
|---|---|---|
| Enable | BOOL | The command is executed as long as Enable is active. | 
| pTable | POINTER To ST_PositionCompensationTableElement | Pointer to the compensation table, which is an array of the type St_PositionCompensationTableElement. | 
| TableSize | UDINT | Size of the compensation table | 
| TableParameter | Data structure with additional parameters for the compensation table. | |
| Ramp | LREAL | Velocity limit for the entered compensation (constant velocity and linear position as subprofiles for table compensation [mm/s]). | 
| DisableMode | E_DisableMode | Disable mode: | 
| Options | ST_PositionCompensationOptions | Optional parameters (not implemented) | 
 Inputs/outputs
 Inputs/outputs
VAR_IN_OUT
    Axis : AXIS_REF;
END_VAR| Name | Type | Description | 
|---|---|---|
| Axis | Axis data structure that unambiguously addresses an axis in the system. Among other parameters it contains the current axis status, including position, velocity or error state. | 
 Outputs
 Outputs
VAR_OUTPUT
    Enabled           : BOOL;
    Busy              : BOOL;
    Error             : BOOL;
    ErrorID           : UDINT;
    CurrentCorrection : LREAL;
    Limiting          : BOOL;
END_VAR| Name | Type | Description | 
|---|---|---|
| Enabled | BOOL | This output becomes TRUE when the table compensation was enabled without errors. | 
| Busy | BOOL | This output becomes TRUE when the command is started with Enable and remains so as long as the function block executes the command. | 
| Error | BOOL | This output becomes TRUE if an error has occurred during command execution. | 
| ErrorID | UDINT | Contains the command-specific error code of the last executed command. Details of the error code can be found in the ADS error documentation or in the NC error documentation (error codes 0x4nnn and 0x8nnn). | 
| CurrentCorrection | LREAL | Current compensation value, in the unit of the axis. | 
| Limiting | BOOL | This output is TRUE if the correction value associated with the position has not yet been fully applied. | 
Further information
The following is an example of a position table and the corresponding table parameters:
VAR_INPUT
    …
    stParameter : ST_PositionCompensationTableParameter 
                  := (MinPosition := -10.0, MaxPosition := 10.0, 
                      NoOfTableElements := 21, Direction := WorkDirectionBoth);
    stPosTable  : ARRAY[0..20] OF ST_PositionCompensationTableElement 
                  := [ ( Position := -10.0, Compensation := 1.0 ),
                       ( Position :=  -9.0, Compensation := 0.9 ),
                       ( Position :=  -8.0, Compensation := 0.8 ),
                       ( Position :=  -7.0, Compensation := 0.7 ),
                       ( Position :=  -6.0, Compensation := 0.6 ),
                       ( Position :=  -5.0, Compensation := 0.5 ),
                       ( Position :=  -4.0, Compensation := 0.4 ),
                       ( Position :=  -3.0, Compensation := 0.3 ),
                       ( Position :=  -2.0, Compensation := 0.2 ),
                       ( Position :=  -1.0, Compensation := 0.1 ),
                       ( Position :=   0.0, Compensation := 0.0 ),
                       ( Position :=   1.0, Compensation := 0.1 ),
                       ( Position :=   2.0, Compensation := 0.2 ),
                       ( Position :=   3.0, Compensation := 0.3 ),
                       ( Position :=   4.0, Compensation := 0.4 ),
                       ( Position :=   5.0, Compensation := 0.5 ),
                       ( Position :=   6.0, Compensation := 0.4 ),
                       ( Position :=   7.0, Compensation := 0.3 ),
                       ( Position :=   8.0, Compensation := 0.2 ),
                       ( Position :=   9.0, Compensation := 0.1 ),
                       ( Position :=  10.0, Compensation := 0.0 )
                      ];
    …
END_VARAs shown graphically, the table results in the following correction behavior:

Requirements
| Development environment | Target platform | PLC libraries to include | 
|---|---|---|
| TwinCAT v3.1.4024 | PC or CX (x86/x64) | Tc2_MC2 |