FP_GET_UNIT_ID

returns the expansion unit ID of a specified slot

This FP instruction returns the unit ID of the expansion unit of the slot number specified by iSlot. The unit ID found in I/O map and unit configuration is written to the output variable wUnitId and can be used for comparison with a system variable of the group PLC unit constants.

Input

iSlot (WORD, INT, UINT)

Slot number of expansion unit

Output

wUnitId (WORD, INT, UINT)

Unit ID of expansion unit, e.g. SYS_UNIT_AFP7X16DW

Remarks

Before using this instruction, please re-compile your PLC program and download it with Online > Download program code and PLC configuration to PLC to the PLC. This prevents a wrong unit ID to be returned in case the unit configuration has been changed.

Example

POU header

All input and output variables used for programming this function have been declared in the POU header. The same POU header is used for all programming languages.

	VAR
		bStart: BOOL:=FALSE;
		iSlot: INT:=1;
		wModelCode: WORD:=0;
		bIsInputUnit_16Points_AttachedToSlot: BOOL:=FALSE;
		@'': @'';
	END_VAR

POU bodyCopy code to clipboard

When the variable bStart is set to TRUE, the function is carried out.

LD bodyCopy code to clipboard

BODY
    WORKSPACE
        NETWORK_LIST_TYPE := NWTYPELD ;
        ACTIVE_NETWORK := 0 ;
    END_WORKSPACE
    NET_WORK
        NETWORK_TYPE := NWTYPELD ;
        NETWORK_LABEL :=  ;
        NETWORK_TITLE :=  ;
        NETWORK_HEIGHT := 4 ;
        NETWORK_BODY
B(B_VARIN,,iSlot,10,2,12,4,);
B(B_VAROUT,,wModelCode,21,2,23,4,);
B(B_CONTACT,,bStart,5,1,7,3,);
B(B_F,FP_GET_UNIT_ID!,,12,0,21,4,,?DEN?DiSlot?AENO?CwUnitId);
L(1,2,5,2);
L(7,2,12,2);
L(1,0,1,4);
        END_NETWORK_BODY
    END_NET_WORK
    NET_WORK
        NETWORK_TYPE := NWTYPELD ;
        NETWORK_LABEL :=  ;
        NETWORK_TITLE :=  ;
        NETWORK_HEIGHT := 3 ;
        NETWORK_BODY
B(B_F,@EQ-2!,,12,0,17,3,,?D?D?C);
B(B_VARIN,,wModelCode,10,0,12,2,);
B(B_VARIN,,SYS_UNIT_AFP7X16DW,10,1,12,3,);
B(B_VAROUT,,bIsInputUnit_16Points_AttachedToSlot,17,0,19,2,);
L(1,0,1,3);
        END_NETWORK_BODY
    END_NET_WORK
END_BODY

ST bodyCopy code to clipboard

IF (bStart) THEN
    FP_GET_UNIT_ID(iSlot := iSlot, wUnitId => wModelCode);
END_IF;
IF wModelCode = SYS_UNIT_AFP7X16DW  THEN
    bIsInputUnit_16Points_AttachedToSlot:= TRUE;
END_IF;

Modified on: 2019-12-14Feedback on this pagePanasonic hotline