ExpansionUnitNumberToIOWordOffset_FPX_FP0

Function to calculate the I/O offset of an analog expansion unit connected to the CPU via an adapter.

I/O starting addresses vary, depending on the installation positions of the adapter and of the expansion unit. The function calculates the I/O word offset based on the adapter position and the unit position relative to the adapter.

Parameters

Input

iFPX_ExpansionUnitNumber (INT)

Set the position of the adapter relative to the CPU.

Values: 1 to 8

iFP0_ExpansionUnitNumber (INT)

Set the position of the FP0/FP0R expansion unit relative to the adapter.

Values: 1 to 3

Output

iIOWordOffset (INT)

Returns the offset of the I/O word (WX/WY)

Example

POU headerCopy code to clipboard

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
		Inst_FP0R_A21: Unit_AnalogInOut_FP0R_A21;
		iAnalogOut0: INT:=0;
		bIO_Config_done: BOOL:=FALSE;
		iAnalogIn0: INT:=0;
		iAnalogIn1: INT:=0;
	END_VAR

POU body

The function calculates the I/O word offset for an FP0/FP0R analog unit connected to an FP-X CPU. iFPX_ExpansionUnitNumber is the installation position (1 to 8) of the FP0/FP0R expansion adapter. iFP0_ExpansionUnitNumber is the installation position of the analog unit relative to the adapter (1 to 3).

LD bodyCopy code to clipboard

BODY
    WORKSPACE
        NETWORK_LIST_TYPE := NWTYPELD ;
    END_WORKSPACE
    NET_WORK
        NETWORK_TYPE := NWTYPELD ;
        NETWORK_LABEL :=  ;
        NETWORK_TITLE :=  ;
        NETWORK_HEIGHT := 8 ;
        NETWORK_BODY
B(B_VARIN,,3,2,2,4,4,);
B(B_F,ExpansionUnitNumberToIOWordOffset_FPX_FP0!,,4,1,26,5,,?DiFPX_ExpansionUnitNumber?DiFP0_ExpansionUnitNumber?C);
B(B_FB,Unit_AnalogInOut_FP0R_A21!,Inst_FP0R_A21,36,1,51,8,,?BiIOWordOffset?BiOutChannel0?BiOutChannel0_Config?BiInChannel0_Config?BiInChannel1_Config?CbConfigIsDone?CiInChannel0?CiInChannel1);
B(B_VAROUT,,bIO_Config_done,51,2,53,4,);
B(B_VARIN,,2,2,3,4,5,);
B(B_VARIN,,iAnalogOut0,34,3,36,5,);
B(B_VAROUT,,iAnalogIn0,51,3,53,5,);
B(B_VARIN,,3,34,4,36,6,);
B(B_VAROUT,,iAnalogIn1,51,4,53,6,);
B(B_VARIN,,0,34,5,36,7,);
B(B_VARIN,,0,34,6,36,8,);
L(1,0,1,8);
L(26,3,36,3);
        END_NETWORK_BODY
    END_NET_WORK
END_BODY

ST bodyCopy code to clipboard

Inst_FP0R_A21(iIOWordOffset := ExpansionUnitNumberToIOWordOffset_FPX_FP0(3, 2),
	iOutChannel0 := iAnalogOut0,
	iOutChannel0_Config := 3,
	iInChannel0_Config := 0,
	iInChannel1_Config := 0,
	bConfigIsDone => bIO_Config_done,
	iInChannel0 => iAnalogIn0,
	iInChannel1 => iAnalogIn1);

Modified on: 2023-10-18Feedback on this pagePanasonic hotline