I've been testing this script using MDI, for stopping X axis with an external input from a switch, and then allowing it to be moved afterwards:-
If IsActive(INPUT 1) Then 'If switch is tripped
DoOEMButton(250) 'stop X axis
DoOEMButton(1021) 'reset twice (once doesn't work)
DoOEMButton(1021)
End If
If IsActive(INPUT 1) Then
DoOEMButton(250) 'Do again to enable X axis to run again. Simply putting this command after 1st loop doesn't work
DoOEMButton(1021)
DoOEMButton(1021)
End If
If I trigger Input1 and hold it down, then run this, it works as I wanted it to, although it looks awful as a piece of code!
I want this script to run for 10 seconds, during which time it will 'look out' for input 1 triggering; so I put it inside a For Next loop, with a sleep command to ensure that this runs 50 times every second for 10 seconds; sufficient for my needs.
For i = 1 To 500
If IsActive(INPUT 1) Then 'If switch is tripped
DoOEMButton(250) 'stop X axis
DoOEMButton(1021) 'reset twice (once doesn't work)
DoOEMButton(1021)
End If
If IsActive(INPUT 1) Then
DoOEMButton(250) 'Do again to enable X axis to run again. Simply putting this command after 1st loop doesn't work
DoOEMButton(1021)
DoOEMButton(1021)
Sleep 20
End If
Next i
Unfortunately it works exactly the same as the first one; It doesn't seem to loop and wait for input 1 to activate; like the first one, it will only stop the axis and let it restart if I trigger Input1 and hold it down, then press run.
I can't see why it won't loop, sleep, and activate on input 1. Whatever it is, I just can't see it. I can't work out how to debug this at runtime, like in visual studio, as I don't know how to simulate the input 1's active signal.
Does anyone know why it isn't working as expected?
Thanks