FP_GET_UNIT_OFFSETS1

计算扩展单元的I/O偏移量

此指令计算iSlot所指定插槽编号中的扩展单元的相关偏置值,用于通过索引寄存器访问输入/输出或单元内存。

参数

输入

iSlot (WORD, INT, UINT)

插槽编号

输出

diOffset_WX0_WY0(DWORD, DINT, UDINT, DATE, TOD, DT)

起始I/O字编号

diOffset_X0_Y0(DWORD, DINT, UDINT, DATE, TOD, DT)

起始I/O字编号乘以16

diOffset_S1(DWORD, DINT, UDINT, DATE, TOD, DT)

插槽编号-1

标注

iSlot = 5和起始字编号= 16

起始字编号

相应地址

应用示例

说明

diOffset_WX0_WY0 = 16

DIX

DIXWX1DIXWY1

访问插槽5中单元的I/O字1

diOffset_X0_Y0 = 16*16=256

DIY

DIYX12DIYY12

访问插槽5中单元的I/O位十六进制12

diOffset_S1 = 4

DI2

DI2S1:UM1A

访问插槽5中单元的单元内存字十六进制1A

示例

POU头

所有用于编程此函数的输入和输出变量已在POU头中声明。 所有编程语言使用相同的POU头。

	VAR
		iSlot: INT:=1;
		bEnable: BOOL:=FALSE;
		wSlotFirstInputWord: WORD:=0;
		bSlotFirstInputFlag: BOOL:=FALSE;
		wSlotFirstUnitMemoryWord: WORD:=0;
		bGetSlotFirstInputWord: BOOL:=FALSE;
		bGetSlotFirstInputFlag: BOOL:=FALSE;
		bGetSlotFirstMemoryWord: BOOL:=FALSE;
	END_VAR

POU本体

当变量bEnable设置为TRUE时,执行此函数。

LD本体

BODY
    WORKSPACE
        NETWORK_LIST_TYPE := NWTYPELD ;
        ACTIVE_NETWORK := 0 ;
    END_WORKSPACE
    NET_WORK
        NETWORK_TYPE := NWTYPELD ;
        NETWORK_LABEL :=  ;
        NETWORK_TITLE :=  ;
        NETWORK_HEIGHT := 6 ;
        NETWORK_BODY
B(B_F,FP_GET_UNIT_OFFSETS1!,,17,0,30,6,,?DEN?DiSlot?AENO?AdiOffset_WX0_WY0?AdiOffset_X0_Y0?AdiOffset_S1);
B(B_VARIN,,iSlot,15,2,17,4,);
B(B_VAROUT,,DIX,30,2,32,4,);
B(B_VAROUT,,DIY,30,3,32,5,);
B(B_VAROUT,,DI2,30,4,32,6,);
B(B_CONTACT,,bEnable,6,1,8,3,);
L(1,2,6,2);
L(8,2,17,2);
L(1,0,1,6);
        END_NETWORK_BODY
    END_NET_WORK
    NET_WORK
        NETWORK_TYPE := NWTYPELD ;
        NETWORK_LABEL :=  ;
        NETWORK_TITLE :=  ;
        NETWORK_HEIGHT := 4 ;
        NETWORK_BODY
B(B_F,E_MOVE!,,17,0,23,4,,?DEN?D?AENO?C);
B(B_VARIN,,DIXWX0,15,2,17,4,);
B(B_VAROUT,,wSlotFirstInputWord,23,2,25,4,);
B(B_CONTACT,,bGetSlotFirstInputWord,6,1,8,3,);
L(8,2,17,2);
L(1,2,6,2);
L(1,0,1,4);
        END_NETWORK_BODY
    END_NET_WORK
    NET_WORK
        NETWORK_TYPE := NWTYPELD ;
        NETWORK_LABEL :=  ;
        NETWORK_TITLE :=  ;
        NETWORK_HEIGHT := 4 ;
        NETWORK_BODY
B(B_F,E_MOVE!,,17,0,23,4,,?DEN?D?AENO?C);
B(B_VARIN,,DIYX0,15,2,17,4,);
B(B_VAROUT,,bSlotFirstInputFlag,23,2,25,4,);
B(B_CONTACT,,bGetSlotFirstInputFlag,6,1,8,3,);
L(8,2,17,2);
L(1,2,6,2);
L(1,0,1,4);
        END_NETWORK_BODY
    END_NET_WORK
    NET_WORK
        NETWORK_TYPE := NWTYPELD ;
        NETWORK_LABEL :=  ;
        NETWORK_TITLE :=  ;
        NETWORK_HEIGHT := 4 ;
        NETWORK_BODY
B(B_F,E_MOVE!,,17,0,23,4,,?DEN?D?AENO?C);
B(B_VARIN,,DI2S1:UM0,15,2,17,4,);
B(B_VAROUT,,wSlotFirstUnitMemoryWord,23,2,25,4,);
B(B_CONTACT,,bGetSlotFirstMemoryWord,6,1,8,3,);
L(8,2,17,2);
L(1,2,6,2);
L(1,0,1,4);
        END_NETWORK_BODY
    END_NET_WORK
END_BODY

ST本体

if (bEnable) then
    FP_GET_UNIT_OFFSETS1(iSlot := iSlot, 
                                  diOffset_WX0_WY0 => DIX, 
                                  diOffset_X0_Y0 => DIY, 
                                  diOffset_S1 => DI2);
end_if;
if (bGetSlotFirstInputWord) then
    wSlotFirstInputWord := DIXWX0;
end_if;
if (bGetSlotFirstInputFlag) then
    bSlotFirstInputFlag := DIYX0;
end_if;
if (bGetSlotFirstMemoryWord) then
    wSlotFirstUnitMemoryWord := DI2S1:UM0;
end_if;

最后更新日期: 此页面上的反馈松下热线