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 characteristics and the fact that an axis can change its different operation modes at runtime (e.g. interpolating path axis (NCI), master PTP axis, slave axis, external setpoint generation) further increase the flexibility of a TwinCAT axis.
The superimposition of internal and external setpoint sources generally enables a wide range 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 Tc2_MC2 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). Thus, enabling the external setpoint generation is similar to a conventional axis start.
A status bit of the axis reference Axis.Status.ExtSetPointGenEnabled informs about the status, namely whether the external setpoint generation, is enabled or disabled.

So that enabling is accepted without errors:

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. A feedback is given by the already mentioned status bit of the axis reference Axis.Status.ExtSetPointGenEnabled.

External set value generation 2:

After disabling the external setpoint generation, the external target 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 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 target 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:

The PLC task that generates and specifies the setpoints must operate 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:

Dead time caused by transport via the cyclic axis interface can be compensated for an axis. This dead time compensation can be set by means of the dialogs on the encoder and drive of the NC axis (ON (with velocity)).