FC_PhyEncGetPosition - General Information

Overview

Type:

Function

Available as of:

SystemInterface_1.32.6.0

Versions:

Current version

Task

Read-in the encoder position of the physical encoder (SinCos encoder).

Description

With this function the actual, absolute position (InitPosition) of the physical encoder (P_ENC) is read and the EncoderPosition is updated. The function only sends one job. This job is processed by a system task. This task communicates with the physical encoder via a serial interface.

 WARNING
INVALID READING OF THE POSITION
Ensure that the encoder does not move during the read process.
Failure to follow these instructions can result in death, serious injury, or equipment damage.

Use the function FC_PhyEncGetCmdState() to determine if the job was completed.

Interface

Input

Data type

Description

i_stEncId

ST_LogicalAddress

Logical address of the encoder

Return Value

Data type

Description

BOOL

TRUE: job started

FALSE: job interface is busy (try again) or error

Example

 PROGRAM PLC_PRG 
VAR CONSTANT 
   c_diErrorState: DINT := 50000; 
END_VAR 
VAR 
   diState : DINT := 10; 
   xPhyEncGetPositionResult: BOOL; 
   xGetCmd2Result : BOOL; 
   TONInst:TON;
   q_sErrorText:STRING; 
END_VAR 
CASE diState OF 
10:  
   xPhyEncGetPositionResult := FC_PhyEncGetPosition(PMEnc.stLogicalAddress); 
   TONInst(IN := FALSE, PT := t#5s); 
   TONInst(IN := TRUE, PT := t#5s); 
   IF xPhyEncGetPositionResult = FALSE THEN 
      q_sErrorText:=' FC_PhyEncGetPosition failed'; 
      diState := c_diErrorState; 
   ELSE 
      diState := 20; 
   END_IF 
20:  
   TONInst(IN := TRUE, PT := t#5s); 
   xGetCmd2Result := PhyEncGetCmdState2( PMEnc.stLogicalAddress ); 
   IF xGetCmd2Result = TRUE THEN 
      diState := 30; 
   END_IF 
   IF TONInst.Q THEN 
      q_sErrorText:=' FC_PhyEncGetPosition timeout'; 
      diState := c_diErrorState; 
   END_IF 
   c_diErrorState:;  
 END_CASE