计算扩展单元的I/O偏移量
此指令计算iSlot所指定插槽编号中的扩展单元的相关偏置值,用于通过索引寄存器访问输入/输出或单元内存。
输入
插槽编号
输出
起始I/O字编号
起始I/O字编号乘以16
插槽编号-1
iSlot = 5和起始字编号= 16
起始字编号 |
相应地址 |
应用示例 |
说明 |
---|---|---|---|
diOffset_WX0_WY0 = 16 |
DIX |
DIXWX1或DIXWY1 |
访问插槽5中单元的I/O字1 |
diOffset_X0_Y0 = 16*16=256 |
DIY |
DIYX12或DIYY12 |
访问插槽5中单元的I/O位十六进制12 |
diOffset_S1 = 4 |
DI2 |
DI2S1:UM1A |
访问插槽5中单元的单元内存字十六进制1A |
所有用于编程此函数的输入和输出变量已在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
当变量bEnable设置为TRUE时,执行此函数。
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
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;