External set value generation

External setpoint generation (external setpoint specification) enables the implementation of individual setpoint generators within the PLC, or appropriate connection of existing internal and external generators, and their simple and transparent integration into the TwinCAT system. Axes can be positioned either with an external setpoint generator alone, or superposition (mixing) of existing internal generators and external setpoint sources is possible.

These new characteristics and the fact that an axis can change its operating modes at runtime (e.g. interpolating path axis (NCI), master PTP axis, slave axis, external setpoint generation) further enhance the flexibility of a TwinCAT axis.
In general, the superimposition of internal and external setpoint sources enables a multitude of new applications and solutions. 

Examples of use:

This new function is available with the PLC function blocks MC_ExtSetPointGenEnable and MC_ExtSetPointGenDisable in the TcMc.lib library. Furthermore, there is an example for an external setpoint generator (3-phase profile with acceleration rectangle), see section TwinCAT NC-PTP Examples

Activation of the external setpoint generation:

The adoption of the external setpoint specifications is initiated by an ADS axis function from the PLC with the function block MC_ExtSetPointGenEnable. The axis start types absolute (1) or relative (2) and, if sensible and required, the target position of the axis, are specified as parameters. This target position has either an absolute or relative effect, depending on the starting mode, and enables position and target position window monitoring (PEH). The activation of the external setpoint specification is thus similar to a conventional axis start.
A status bit from the status double word of the cyclic axis interface from the NC to the PLC provides information about the state, i.e. whether the external setpoint generation is active or inactive (see function AxisHasExtSetPointGen in TcNc.lib).

In order for the activation to be accepted without error, no axis error must be present, the controller and feed releases must be granted, the drive hardware must be ready to run and the axis must not be coupled (no slave).

External set value generation 1:

To be observed:

  • In case of an axis error (runtime error of the axis) or an axis reset (including edge change of the software controller enable) the external setpoint specification is automatically disabled (similar to an abortion of PTP axis positioning in case of a runtime error or axis reset).
  • If only external setpoint generation is carried out, both absolute and relative start types are permitted.
    If external setpoint generation is started in parallel or in addition to internal setpoint generation (PTP), only the relative starting mode is possible, since the internal positioning is ultimately always converted to an absolute start, and it is not possible to have two absolute positions simultaneously.
  • Whilst external positioning can be activated during an active internal PTP positioning via the relative start type, the opposite case is not permitted.
  • If the external setpoint generation is already active and this is activated for the repeated time, then the start types must match, otherwise this is answered with an error.
    The repeated activation of the external setpoint generation can be useful insofar as here the target position is taken over each time and thus the target position window monitoring (PEH) is updated.

Disabling the external setpoint generation:

External setpoint specification is switched off from the PLC via the function block MC_ExtSetPointGenDisable. The above-mentioned status bit from the status double word of the cyclic axis interface from the NC to the PLC provides feedback (see function AxisHasExtSetPointGen in TcNc.lib ).

External set value generation 2:

After the deactivation of the external setpoint generation, the external set position is taken over for exactly one more cycle.

Specification of setpoints via the cyclic axis interface:

After faultless activation of the external setpoint generation, in each PLC cycle a setpoint packet can now be created at the axis interface. A setpoint package consists of the external set position, target velocity, set acceleration and set direction (-1, 0, +1).
The set direction is of particular importance here, because setpoints are only accepted and applied internally if this is not equal to zero (0: no movement). For the complete range of external setpoint generation, the direction flag therefore has to be set quasi-overlapping at the start and at the end.

External set value generation 3:

To be observed:

  • After resetting of the set direction to zero, the external set position is taken over for exactly one further SAF cycle.
  • The set direction should already be set to a value not equal zero (i.e. -1 or +1) one cycle before and for one more cycle after the motion. This provides a safe time frame that is guaranteed to prevent a value being ignored, either at the start or at the end. 

Settings of the PLC task:

Ideally, the PLC task that generates and specifies the setpoints should run synchronously, i.e. with the same cycle time as the NC-SAF task (port 501). This PLC task also has to have the same high priority, perhaps an even higher one, than the NC-SVB task (port 511). 

Optimization options:

The dead time generated due to the transport via the cyclic axis interface (also, the input information leading to the calculation of the external setpoints may be one cycle old) can be compensated for an axis that is operated in the velocity interface. This dead time compensation can be set in the TwinCAT System Manager via the global axis parameter delay time between velocity and position (default value: 0.0 s).