Machsupport Forum
Mach Discussion => VB and the development of wizards => Topic started by: babinda01 on August 18, 2009, 07:08:02 PM
-
Hi
I am having a few issues with my macropump, and am hoping someone can help.
This macro works in a fasion, it does what I want but I get random errors occuring, like Cypress enable error, and sometimes I get a divide by zero error and sometime my system freezes (not sure if this one is related). Sometimes the system will run for hours with no problems and other times I will only get a few minutes out of the beast
Basically what I am wanting to do is if my safety door is open I need to stop and close the current program and send a message back to a C# application - AKSYSTECH.ABORT, and then when the door is closed again re-enable the system and prompt to reload the last program.
I hope you can get the idea of what I am trying to do.
Regards
Andrew
-
'/////////////////// unless your going to use an Exit dont use a sub in macropump
'Sub Main()
Dim DoorOpen
Dim DoorSafetyCycle
Dim t
If IsActive(Input1) Then
setuserled(1113,1)
DoorOpen = 1
setuserled(1114,0)
'///////////////////////////////////////////////////////////////////////////
If isloading() = 0 Then
'change to: If isloading() Then
'////////////////////////////////////////////////////////////////////
If getled(4) = 1 Then
' This has to be: GetOEMLED(4)
DoOEMButton(1003)'Stops Program May need to change this to 1001 - Pause
End If
DoOEMButton(169)'Closes Current Program
End If
deactivatesignal(output1)
deactivatesignal(output2)
deactivatesignal(output3)
deactivatesignal(output4)
Message ("Door Open - PROGRAM ABORTED!!!")
End If
If Not IsActive(input1) Then
If getuserled(1113) = 1 Then
setuserled(1114,0)
DoorSafetyCycle = 1
setuserled(1114,1)
Message ("Re-Select Required Job")
Message ("AKSYSTech.Abort")
For t = 1 To 3
SetTimer( 1 )
'///////////////////////////////////////
While GetTimer(1) < .05 ' You CANNOT use While loops in the macro pump it will crash mach
Wend
'Change this to an if statement or somthing..
Next t
Message ("")
setuserled(1113,0)
End If
End If
'//////////////////////////////////////////////////////////////
If IsLoading()= 1 Then
' Change to: If IsLoading() Then
If getuserled(1114) = 0 Then
'/////////////////////////////////////////////////////////////////
While IsLoading()= 1 ' You CANNOT use While loops in the macro pump it will crash mach
Wend
'Change this to an if statement or somthing..
Message ("AKSYSTech.Abort")
Message ("Door Safety Cycle Not Completed!!!")
DoOEMButton(1003)'Stops Program
DoOEMButton (169)'Closes Current Program
End If
End If
If getoemled(164) Then
setuserled(1114,0)
End If
If getoemled(165) Then
setuserled(1114,0)
End If
If GetOEMLed(800) Then
setuserled(1111,0)
setuserled(1112,0)
setuserled(1113,0)
setuserled(1114,0)
End If
'/////////////////// unless your going to use an Exit dont use a sub in macropump
'
End Sub
Main
'scott
-
Would it be easier to use the door safety input for mach? Prevents the program from running with it ajar.
Just a thought, (;-) TP
-
Hi Scott,
Thanks for your reply. The while loops I have in there may be my problem. I will change it and see how I go then.
Regards
Andrew
-
Hi Scott,
Just nother question ....... Can I use a sleep(500) in the macropump? Or doesn't it like sleep commands either.
Regards
Andrew
-
Dont run a sleep, since the macro pump is a Scanning program runs in a continous loop at machs update loop.......
instead if you need to do a pause, or set a timed event, dont run a: code"G4 P#" since you would have to run a "While IsMoving()" Wend after that.
a better approach in the macro pump would be to set a VB Timer then be watching for that value to be exceeded in an if statement to execute the code you where waiting on the time out for.
scott
-
Hi
I'm with VMax549, ordinarily a safety door would be wired with all the other interlocks to EStop. Simple and effective.
I suspect there is something else going on with your set up outside of Mach and you are trying to automate the whole thing.
If one had to design something that would degrade system performance and potentially cause unlimited problems, it would be the macro pump, continually polling something or other.
Insert a while() loop with a conditional exit which might not even be reached, into something that is called several times a second and crash, bang, wallop.
If you can change your programming methodology to avoid the use of the macro pump, you will have a much faster and more stable system.
If you don't want to just link the door to Estop, one possibility is to have a user defined macro which is called at the start of every program, which in turn checks the state of whatever pin you have linked your door to.
If active it halts and sends the relevant message.
I assume your safety door is not going to open on its own accord during the cycle, you just want to check that it is shut before starting, so you don't need to check thousands upon thousands of times, just once at the beginning.
Just some thoughts
regards
Melee
-
Hi Melee,
Thanks for your input. The machine I am having trouble with is a special purpose machine, and my customer had problems with the operators bypassing the safety input (originally I just had it wired to the safety input as suggested). So the decission was made to make the system look for both a door open and a door close before it would allow a program to be run. In doing this I decided it would be best to remove the program from Mach3 once a door opened and again if the operator tried to run the program without completeing the complete door cycle.
Your suggestion of putting the brainwork into a macro that I call at the start of my program is excellent, and I thank you for the suggestion. I will try this thismorning and see how I go.
Thanks again
Andrew