圖片:
macro_command main()
bool a[2],QB_lamp,MB_Rising_edge
bool on=1,off=0
GetData(a[0], "Local HMI", LB, 0, 1)
//產(chǎn)生上升沿
if a[0] and not a[1] then
MB_Rising_edge=1
end if
//啟動(dòng)自鎖
GetData(QB_lamp, "Local HMI", LB, 10, 1)
if ( MB_Rising_edge and not QB_lamp ) or (not MB_Rising_edge and QB_lamp) then
SetData(on, "Local HMI", LB, 10, 1)
else
SetData(off, "Local HMI", LB, 10, 1)
end if
//復(fù)位上升沿和保持
MB_Rising_edge=0
a[1]=a[0]
end macro_command
程序已經(jīng)測試過,歡迎來討論改進(jìn)