用SCL FOR循环怎么查询IB0八位的状态,是true的要输出,图片的程序不知道错在哪里,请指教?怎么运行都有错
问题补充:
FUNCTION_BLOCK FB25
VAR_INPUT
s1:BYTE;
s2 AT s1:ARRAY [0..7] OF BOOL;
END_VAR
VAR_OUTPUT
x1:BOOL;
x2:BOOL;
END_VAR
VAR
ID1:INT;
END_VAR
BEGIN
x1:=s2[0];
FOR ID1:= 1TO 7 BY 1 DO
X2:S2[ID1];
END_FOR;
END_FUNCTION_BLOCK
图片说明:
最佳答案
For "数据块_1"."BOOL" := 0 To 7 Do
If %IX("数据块_1"."BYTE", "数据块_1"."BOOL") Then
WORD_TO_BLOCK_DB("数据块_1".blockDB).DX("数据块_1"."BYTE", "数据块_1"."BOOL") := %IX("数据块_1"."BYTE", "数据块_1"."BOOL");
Else
WORD_TO_BLOCK_DB("数据块_1".blockDB).DX("数据块_1"."BYTE", "数据块_1"."BOOL") :=0;
End_If;
;
End_For;
提问者对于答案的评价:
是的呀
原创文章,作者:more0621,如若转载,请注明出处:https://www.zhaoplc.com/plc199458.html