Part 1 PLCopen program

This program is used to calculate function block instances that were implemented in accordance with Part 1 of the PLCopen specifications

In the initialisation part, the relationship between axis references and function blocks shown in the figure in "PLCopen.pro: Test application for PLCopen function blocks" is re-established for function blocks referring to a single axis.

FOR Idx := 0 TO PLC_AX_MAXIDX DO

  IdxSingleAxFbs := Idx + g_axis_idx_offset;

  IF (IdxSingleAxFbs >= 0) AND

       (IdxSingleAxFbs <= PLC_AX_MAXIDX) THEN

    HomeAxRefIdx[IdxSingleAxFbs]     := IdxSingleAxFbs;

    …

       (* Calculate the administrative FBs *)

    ReadStatusAxRefIdx[IdxSingleAxFbs] := IdxSingleAxFbs;

      …

  END_IF;

END_FOR;

The first SAI axis available in the system is defined as the master axis for all function blocks that refer to a master and a slave axis. However, the individual function block instances then receive different references for the slave axis.

FOR IdxMultAxFbs := 0 TO PLC_MULTIAX_IDX DO

  …

  GearInMstIdx[IdxMultAxFbs]  := IdxMasterAx;

  GearInSlvIdx[IdxMultAxFbs]  := IdxSlaveAx;

  GearOutSlvIdx[IdxMultAxFbs] := IdxSlaveAx;

  …

  IF IdxSlaveAx < GC_MCP_AXREF_MAXIDX THEN

    IdxSlaveAx := IdxSlaveAx + 1;

  ELSE

    IdxMasterAx := IdxMasterAx + 1;

     IdxSlaveAx := 0;

  END_IF;

END_FOR;

After the initialisation phase, only the function block instances are calculated cyclically.

All the program code after the comment

(*===========================================================*)

(* The following commands are only for visualisation.       *)

(*===========================================================*)

is only used to supply the assigned visualisation with the data of the selected function block instance.