Untitled
unknown
plain_text
a year ago
1.3 kB
10
Indexable
Dim isToggleOn As Boolean
Dim relayOnTime As Double
Dim relayOffTime As Double
Dim relayOffTimer As Double
Dim machineMoving As Boolean
relayOnTime = 10 ' Relay ON time in seconds
relayOffTime = 800 ' Relay OFF time in seconds
relayOffTimer = 0
' Infinite loop to check the toggle button and control relay
Do While True
isToggleOn = GetOEMLED(1234) ' Replace 1234 with the OEM code of your toggle button
If isToggleOn Then
' Turn on relay for the on-time (10 seconds)
ActivateSignal(OUTPUT3)
Sleep relayOnTime * 1000 ' Convert to milliseconds
' Turn off relay and start off-timer
DeactivateSignal(OUTPUT3)
relayOffTimer = 0
' Wait for off-time while checking if machine is moving
Do While relayOffTimer < relayOffTime
machineMoving = GetOEMLED(800) ' OEMLED 800 = "Machine moving" status
If machineMoving Then
relayOffTimer = relayOffTimer + 0.1 ' Increment off-timer in 100 ms steps
End If
Sleep 100 ' Wait 100 ms between checks
Loop
Else
DeactivateSignal(OUTPUT3) ' Ensure relay is off if toggle is off
Exit Do ' Exit if the toggle is turned off
End If
Sleep 100 ' Add a small delay to prevent excessive CPU usage
LoopEditor is loading...
Leave a Comment