在博途中用FOR指令實現(xiàn)數(shù)據(jù)的自動排序
下面在博途中用FOR指令實現(xiàn)數(shù)據(jù)的自動排序
程序是用SCL寫的
首先,建立一個數(shù)據(jù)塊。這個數(shù)據(jù)塊就是要排序的數(shù)據(jù)塊。

建立一個FC塊
塊接口定義一個

FC中的程序
……………………………………………………………………………………………………………
(*用FOR指令實現(xiàn)自動排序*)
(*實現(xiàn)5個數(shù)的自動排序*)
IF #Compare THEN
? ? FOR #t_Counter1:= 0 TO 3 DO
? ? ? ? FOR #t_Counter2 := #t_Counter1+1 TO 4 DO
? ? ? ? ? ??
? ? ? ? ? ? IF "5個整數(shù)".Static_1[#t_Counter1]>"5個整數(shù)".Static_1[#t_Counter2] THEN
? ? ? ? ? ? ? ? #t_BB := "5個整數(shù)".Static_1[#t_Counter2];
? ? ? ? ? ? ? ? "5個整數(shù)".Static_1[#t_Counter2] := "5個整數(shù)".Static_1[#t_Counter1];
? ? ? ? ? ? ? ? "5個整數(shù)".Static_1[#t_Counter1] := #t_BB;
? ? ? ? ? ? END_IF;
? ? ? ? END_FOR;
? ? END_FOR;
END_IF;
…………………………………………………………………………………………………………
在OB1中調(diào)用一下FC

在HMI中建一個畫面,有5個整數(shù)I/0域

PLC和HMI聯(lián)合仿真,
下面是仿真效果。


好了,就到這里了。
有什么疑問歡迎留言,私信也可。