PLC variant I (trigger via XtsUtility)

You have the option to trigger the Mover ID detection via PLC variant I. To trigger the search automatically, you can use the following sample codes for the Processing Unit object or the TcIoXtsDrv object:

XTS Processing Unit object


// Declaration Part

PROGRAM MAIN
VAR
     stMoverRef                       : ARRAY [1..cAxcnt] OF AXIS_REF;

     fbXtsUnit                        : FB_XtsUnit;

     eMoverIdDetectionMode            : MoverIdDetectionMode:= MoverIdDetectionMode.Mover1; 
                                        //Should be the same as shown in the TcIoXtsDrv object
     bStartMoverIdDetection           : BOOL := TRUE; //Can also be written to trigger the process
                                        manually after start up

     bMoverIdDetectionError           : BOOL;
     bMoverIdDetected                 : BOOL;
     bMoverIdDetectionActive          : BOOL;
END_VAR

VAR CONSTANT
     cAxcnt                           : INT:=10; // Example
END_VAR

//----------------------------------------------------------------------------------------------------

// Programm Part
// Cyclic call of the main block of the XtsUtility Library.

fbXtsUnit(Axis := stMoverRef);

// Check if the position detection of the Movers has been completed.
IF NOT fbXtsUnit.stXtsUnit.stTcIoXtsDrv.stParameter.bAreAllMoverPositionsValid THEN
     // If not all Mover positions are valid, do not process any further.
     RETURN;
END_IF

// Mover1 Functionality
// Check if "MoverIdDetectionMode" has been activated.
IF eMoverIdDetectionMode = E_MoverIdDetectionMode.Mover1 THEN

     // Check if the "MoverIdDetection" has already been started or the Mover1 was found.
     IF bStartMoverIdDetection AND NOT (bMoverIdDetectionActive OR bMoverIdDetected) THEN
          bStartMoverIdDetection:=FALSE;

          // Trigger the "MoverIdDetection".
          fbXtsUnit.stXtsUnit.stTcIoXtsDrv.ipTcXtsIo.TriggerMoverIdDetection();
          bMoverIdDetectionActive:=TRUE;
     END_IF

     // Check for error or success of "MoverIdDetection".
     bMoverIdDetectionError := fbXtsUnit.stXtsUnit.stTcIoXtsDrv.stParameter.bHasMoverIdDetectionError;
     bMoverIdDetected       := fbXtsUnit.stXtsUnit.stTcIoXtsDrv.stParameter.bIsMoverIdDetectionValid;

     // If the detection has an error, check for errors in output and try again.
     IF bMoverIdDetectionError THEN
          bMoverIdDetectionActive:=FALSE;
          RETURN;
     END_IF

     // Do not process any further until the "MoverId" was deteced.
     IF NOT bMoverIdDetected THEN
          RETURN;
     END_IF
     bMoverIdDetectionActive:=FALSE;

// If the "MoverIdDetection" was not activated,
// then the start of the "MoverIdDetection" and the search of Mover1 is skipped.
ELSE
     ;
END_IF

TcIoXtsDrv object


// Declaration Part

PROGRAM MAIN
VAR
     fbXtsEnvironment                 : FB_TcIoXtsEnvironment;
     bInit                            : BOOL;

     bStartMoverIdDetection           : BOOL:=TRUE; // Can also be written to trigger the process
                                        manually after start up

     bMoverIdDetectionError           : BOOL;
     bMoverIdDetected                 : BOOL;
     bMoverIdDetectionActive          : BOOL;
END_VAR

//----------------------------------------------------------------------------------------------------

// Programm part
//Trigger only once in init.
IF NOT bInit THEN
     IF fbXtsEnvironment.Init(TRUE) THEN
          fbXtsEnvironment.Init(FALSE);
          bInit:=TRUE;
     END_IF
     RETURN;
END_IF

// Check if the position detection of the Movers has been completed.
IF NOT fbXtsEnvironment.XpuTcIo(1).GetAreAllPositionsValid() THEN
     // If not all Mover positions are valid, do not process any further.
     RETURN;
END_IF

// Mover1 Functionality
// Check if "MoverIdDetectionMode" has been activated under the XtsProcessingUnit object.
IF fbXtsEnvironment.XpuTcIo(1).GetMoverIdDetectionMode() = MoverIdDetectionMode.Mover1 THEN

     // Check if the "MoverIdDetection" has already been started or the Mover1 was found.
     IF bStartMoverIdDetection AND NOT (bMoverIdDetectionActive OR bMoverIdDetected) THEN
          bStartMoverIdDetection:=FALSE;

          // Trigger the "MoverIdDetection".
          fbXtsEnvironment.XpuTcIo(1).TriggerMoverIdDetection();
     END_IF

     // Check for error or success of "MoverIdDetection".
     bMoverIdDetectionError := fbXtsEnvironment.XpuTcIo(1).GetHasMoverIdDetectionError();
     bMoverIdDetected := fbXtsEnvironment.XpuTcIo(1).GetIsMoverIdDetectionValid();
     bMoverIdDetectionActive := fbXtsEnvironment.XpuTcIo(1).GetIsMoverIdDetectionActive();

     // If the detection has an error, check for errors in output and try again.
     IF bMoverIdDetectionError THEN
          RETURN;
     END_IF

     // Do not process any further until the "MoverId" was deteced.
     IF NOT bMoverIdDetected THEN
          RETURN;
     END_IF

     // Do not process any further until the "MoverId" was deteced.
     IF NOT bMoverIdDetected THEN
          RETURN;
     END_IF

// If the "MoverIdDetection" was not activated in the XtsProcessingUnit object,
// then the activation of the "MoverIdDetection" and the search of Mover1 is skipped.
ELSE
     ;
END_IF