Machsupport Forum
Mach Discussion => General Mach Discussion => Topic started by: tbyrd0918 on June 08, 2012, 11:09:44 PM
-
I have a number of while loops in my code where it checks for position after a pneumatic cyl. move for example. When I run the code, it blows by the code like it isn't there. When I step through the code it seems to loop as I would expect it to. any ideas? Here is some sample code.
while not isactive(input4)
message("still going")
Sleep 50
Wend
Message("you made it")
tbyrd
-
Hi tbyrd,
i found the same problem with my toolchange macro. everything is fine in mdi or autorun, but in single it does not wait for the input to be true.
what i did is at the begin in the macro switch off single block then run the macro to the end then switch single block on again.
for me that works well. Your macro may look like
SetVar 500, getoemled(82)
If (getoemled(82) =-1)Or(getoemled(82) =-1) Then
DoOembutton(1004)
end If
while not isactive(input4)
message("still going")
Sleep 50
Wend
Message("you made it")
If (GetVar(500)=-1)Or(GetVar(500)=-1) Then
DoOembutton(1004)
end If
be sure not to use Var 500 for other operations in this case.
alex
-
Thanks Alex, I'll give it a try first thing Monday Morning. I could just put a huge pause after every cyl. move, and hope all things work properly, but I would like to think that the switches will work. Thanks again.
tbyrd
-
You may want to give this a try.
while not isactive(input4)
message("still going")
Sleep 50
Wend
While Ismoving()
Sleep(20)
Wend
Message("you made it")
-
Good replies. I already tried the while ismoving with no results, although I did add it after my G90 moves.
What seems to work is below:
If not getoemled(82) Then
DoOembutton(1004)
end If
thanks Alex for the code
I also had to add some Sleep 1000's after some of the moves, then all seems good now
tbyrd
-
Looks like I still have the same issue, but it gets there sometimes with the second pause I have inserted into the code.
tbyrd