Synchronizing Profibus

In TwinCAT Run mode the Profibus master is always synchronized with the highest priority task, with which variables are linked. Once the mapping was created, the cycle time of the corresponding task is displayed under Cycle Time on the CCAT PBM tab of the master. It is possible to set for the task whether the "I/O at task begin" should be updated or not.

Prerequisites for this step:

  • A task created in TwinCAT, with which variables from the PLC project are linked.

The option "I/O at task begin" can be activated as follows:

1. Click on the corresponding task in the tree view on the left.
2. Click on the Task tab, then select the option "I/O at task begin".
Synchronizing Profibus 1:
  • You have successfully activated the option "I/O at task begin". The following section explains the effect of this setting on the task time and the DP cycle.

 

I/O at Task Start

If the setting I/O at task begin is activated (default for NC task), before the task starts the system checks whether the previous DP cycle was completed. The inputs and outputs are then copied (the outputs from the last task cycle are used), and the DP cycle is started.

Sample: Task cycle time 2 ms, real-time resources 80%.

Synchronizing Profibus 2:

If copying of the inputs and outputs and the task computing time of 0.8 ms is exceeded, task execution is interrupted, since the 80% real-time resources limit is reached:

Synchronizing Profibus 3:

This case would still not be a problem, because the DP cycle was completed within the available time.

If the setting I/O at task begin is not activated, the sequence is somewhat more critical. The next example shows the effects.

I/O not at Task Start

If the setting I/O at task begin is not selected for the task (default for PLC task), before the task starts the system checks whether the previous DP cycle was completed, and the inputs are copied. Task processing then commences. At the end of the task the outputs are copied, and the DP cycle is started.

Sample: Task cycle time 2 ms, real-time resources 80%.

Synchronizing Profibus 4:

Since in this case the task and the PROFIBUS have to share the bandwidth, exceedance of the real-time resources has a stronger effect than in the case "I/O at task begin":

Synchronizing Profibus 5:

The DP cycle starts later and is not completed in time before the next cycle. The system detects that the last DP cycle could not be completed. No inputs are copied before the start of the next task (the task uses the old inputs), and no outputs are copied after the task has been processed. The DP cycle is not restarted, which mean that a DP cycle is omitted.

The variable CycleCounter is used to indicate an omitted DP cycle (see: Master diagnostics).

Comparison of I/O at task start and I/O not at task start

The advantage of the I/O at task begin setting is that the task and the DP cycle do not have to share the available bandwidth. The DP cycle starts very constant (the jitter corresponds to the TwinCAT jitter). If the setting I/O at task begin is not activated, it can easily happen that a DP cycle is omitted, and the temporal constancy of the DP cycle additionally depends on the jitter of the task processing.

The disadvantage of the I/O at task begin setting is that the dead time, i.e. the system reaction time, increases.

Sync/Freeze functionality

Sync is used for the simultaneous outputting of outputs for several slaves, Freeze is used for reading in inputs from several slaves simultaneously.

The TwinCAT process is as follows:

  • The outputs are written at the beginning (I/O at the start of the task) or the end (I/O not at the start of the task) of the task cycle
  • This will start the PROFIBUS cycle
  • A Sync/Freeze telegram is sent at the start of the PROFIBUS cycle
  • This will cause the Bus Couplers to start a K-Bus cycle with the outputs from the last task cycle and transfer the inputs from the last K-Bus cycle
  • The master will then send the current outputs to each slave and pick up the transferred inputs
  • The inputs are read at the start of the next task cycle
  • etc.

Outputs and inputs are therefore always one cycle old.

Synchronizing Profibus 6:


For a master that is to be operated in Sync/Freeze mode, the option DP/MC (Equidistant) must be set in the CCAT PBM tab under Operation Mode (see: CCAT PBM).

For a slave that is to be operated in Sync/Freeze mode, the option Sync/Freeze enable must be selected on the Profibus tab (see: Profibus). The master always uses group 1 for the Sync/Freeze synchronization.