Machsupport Forum
Mach Discussion => VB and the development of wizards => Topic started by: SailFl on January 19, 2009, 08:43:38 AM
-
I am not sure I am using the right code to check that the spindle is on or that cycle start (gcode running) is correct. When I test on my computer it works but when I test on my CNC machiine the spindle works but the cycle start allows the macro to run. Am I using the wrong code or what might be happening or is there a better way to do this. What I am trying to accomplish is that if the spindle is running or gcode is running, I do not want to allow a macro to run.
Code:
' Check to see if Cycle Start or Spindle is active
' If active then exit macro.
If GetOEMLED(11) Or GetOEMLED(804) Then
If GetOEMLED(11) Then
Code "(Spindle Active - Zero Touch Plate Macro Aborted)"
End If
If GetOEMLED(804) Then
Code "(Cycle Start Active - Zero Touch Plate Macro Aborted)"
End If
Else
Thanks for input
-
Well for one thing, your not putting out any info so that the other Macro can NOT run under those conditions.
here is your code with one possible solution, there are other ways as well.
'I recommend you can put this VB in your macro pump, since you need messaging.
'I added other conditionals to your messaging to handle the other possibles.
' Check to see if Cycle Start or Spindle is active
' If active then exit macro.
If GetOEMLED(11) Or GetOEMLED(804) Then
If GetOEMLED(11) and Not GetOEMLED(804) Then
Code "(Spindle Active - Zero Touch Plate Macro Aborted)"
End If
If GetOEMLED(804) and Not GetOEMLED(11) Then
Code "(Cycle Start Active - Zero Touch Plate Macro Aborted)"
End If
If GetOEMLED(804) and GetOEMLED(11) Then
Code "(G-Code and Spindle Running - Zero Touch Plate Macro Aborted)"
End If
SetUserLED(2000,1) ' This will set a User LED to ON, and it will be your
'control LED for your Probing Macro when ON, your Probe macro
'will not run.
Else
SetUserLED(2000,0) ' This will set a User LED to Off, when off your Probe will run.
'your other code here
End If
'/////////////////////////////////////////////////////////////////////////////////////////
'Now in your Probing Macro put this:
Sub Main()
If GetUserLED(2000) Then
Exit Sub
Else
'Your Probing Code here
End If
End Sub
Main
'enjoy scott
-
poppabear,
Thanks for responding. Since I have not learned all the codes, I am not sure I understand one part of your solution.
Let me also give you some more details. For my Zero Touch Plate, I am not using a mach screen for input or results. I have added an LED to the touch plate. Before running the ZTP macro from my Shuttle Pro, I touch the plate to the bit. If the LED turns blue (the color of the LED), I know I will not drive the bit throught the touch plate. I then can run the macro.
What I realized is that with out some code to check if the spindle or a cut file is running, if I accidently pushed the ZTP button on the shuttle pro, I could have the macro run at a bad time while I am trying to cut a file.
So I do not have a user LED but I will try you have suggested.
I know that my code for the spindle is correct because the macro aborts when only the spindle is active. But if the spindle is off and I engage Cycle Start and then run the macro, the macro will not abort and it starts to do a ZTP run. I realize that the chances that I have code running and the spindle is off is rare but my past programming experience I program this way.
Since I have not worked with Mach that much, I am not sure why this is happening.
Does that help?
I also do not understand this comment. "Well for one thing, your not putting out any info so that the other Macro can NOT run under those conditions." Could you explain?
Thanks for your help.
-
???
Just pick a User LED, for your control LED, it doesnt even have to exist on your screen.
scott
-
Scott,
Thanks for your help but you are not answering my questions so I still don't understand. If you don't have the time to answer my questions that is okay but I am not just looking for a solution but understanding.
Regards
-
I dont understand your questions, that is why I put the Questioning smiley
-
Your first response, you tell me to SetUserLED. That is where it comes from.
"Well for one thing, your not putting out any info so that the other Macro can NOT run under those conditions." You aslo made this comment and I don't understand what you mean.
-
ah, that is much clearer.
In your first code you posted (I am assuming it is running in Macropump?), when your conditions are met to NOT run your probing macro, you do not have a method to pass the "dont run" information so another macro, or brain could use that.
So, in mach you have 2,256 User LEDs that you can use for your purposes, you could also use UserDROs, or "Vars" any of them would do. LEDs are simple cause they are on or off. Further, even if you control an LED, you dont have to physically SHOW the LED on any of your screens, you can use it "invisibly" so to speak.
So what I was telling you was in your main code to set a User LED to ON, when you dont want the Probing cycle to run, and that same code would set it to OFF when you do want the probing to be able to run.
Your Probing Macro, written as a SUB (so you can exit), is watching that same LED, if it is on and you try to run the Probing script, then it will EXIT and not run. If the LED is OFF, it WILL run.
scott
-
Scott,
Why would you assume that it is running in macropump? It is my understanding that in macropump, macros run all the time or that is the what I learned watching the video.
Where is the a list of the user LED, DRO and Vars? I did not know that.
From your third line, it appears that the macro does not run all the time in the macropump and you can turn it on and off.
So let me see if I understand this correctly. This is what I understand.
The code that checks to see if the spindle and cycle start are active along with setting the User LED on or off based on the if else statement is located in my macro that I call with I push the button on my shuttle pro. The actual ZTP probe code that will do the work resides in a macro in the macropump and runs only when the user defined LED is turned off.
If this is correct, point me to the information that tells me how to place the macro in the macropump. Also the list of user LED, DRO and Vars.
I have another question...... I think some one said that the macropump will not allow another macro to run if the gcode is running so do I need to check if the spindle or cycle start is active. Don't I just have to turn the User LED off?
Thank you. This is what I needed to know.
-
no
the first code I gave you should run in the macropump,
it is assumed that your probing code is inside a button, and when you push it, it will Run or Not depending on the state of the LED.
I dont fool with the shuttle pro, so you will need to get someone else to help you there.........
-
Scott
I know how to do the shuttle pro so that is not a problem.
Please tell me where to find the documents that refer to the user LED, DRO, etc.
Thanks for your help.
-
wiki
and under the VB thread