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:
- External setpoint specification can be used for implementing an individual new setpoint profile, which is not available in TwinCAT NC. This profile can be mathematically very simple or as complex as necessary. Since the externally generated setpoint profile can also be superimposed on the standard profile, corrective functions can thus also be supplemented.
In this way, a position-based setpoint profile can be implemented for systems that are difficult to control or non-linear, for example a position-based deceleration ramp for hydraulic axes. - One application for the superposition (mixing) of two internal setpoint sources is the combination of interpolating path processing (NCI) and the 'flying saw' function (PTP slave). Multi-dimensional machining, e.g. a circle, on a moving workpiece is thus possible, which previously was only possible with stationary workpieces. This measure increases the efficiency of a machine.
- External setpoint generation can also be used in order to enable a certain lead time (in the multi-digit second range) between the unit generating the setpoints (e.g. the execution of a DIN-NC program feeding virtual axes) and the real axes. Collision monitoring and strategies for collision avoidance can then be realized.
- Another important use case is coordinate transformations (restricted to regular and unique transformations without singularities). E.g. geometries like a 'two-bar linkage' or conversion between rotatory and translatory coordinates.
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).
![]() | To be observed:
|
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 ).
![]() | 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.
![]() | To be observed:
|
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).