Machsupport Forum
Mach Discussion => VB and the development of wizards => Topic started by: HimyKabibble on September 10, 2009, 12:17:29 AM
-
How can you tell, in a VB script, if a g-code program is currently running?
Regards,
Ray L.
-
Yes, Look at the "cycle Start" LED, the only time it is on, is when the G code is running.
scott
-
But, if your gcode has a macro, the cycle start light goes out when the macro is running.
Update: I stand corrected. Its when you type a macro in the MDI that the cycle start doesnt light up.
-
Then how do we tell weather a gcode program is loaded? I know it's off topic, but it's best not to open a thread that is partially related, i think. =)
-
Hi
currentfile = FileName() will get the name of the loaded .NC file as a string
Testing the return will determine if there is one loaded.
( If (!currentfile.IsEmpty()) {} or If (strlen(currentfile)) {} type of thing in C++ or C, or something clunkier in VBS)
There are undoubtedly other ways to do the same thing.
regards
Melee
-
Uhm, so how is it possible to write in VB???
-
Hi
I don't use VB, except where I have to for Mach.
Looking at the reference material, ( always a good move ) the below is a starting basis
Dim currentfile As String
currentfile = "" // ensure string is empty before you start
currentfile = FileName()
If Len(currentfile) Then
// Do whatever you want to if you find a .NC file is already loaded here
End If
I have put together all the references I found on VBS when I was writing macros HERE (http://myweb.tiscali.co.uk/drahthaar/CNC/VBS_info.zip) for download.
When you have read them you will know as little as me.
regards
Melee
-
Thank you very much melee! Though I've been VB coding on Mach3 for a few years, i don't have such important infos like you have collected! Thank you melee!
-
One more thing to the OP. The cycle start light goes off during and M1 pause.
-
It is undocumented but:
G-Code is Loaded LED 172
-
Son.
Of.
A.
Mofo.
Got any other classified info up your sleeve? Guess that tidbid outta make it to the wiki. Thanks, Jason.
/nick
-
I have put together all the references I found on VBS when I was writing macros HERE (http://myweb.tiscali.co.uk/drahthaar/CNC/VBS_info.zip) for download.
Anyone happen to have the VBS_info.zip that is no longer available at the above link?
Would love to take a peek at it.
-
There are 3 things to look at to tell IF a Gcode FILE is loaded and running. IT MAY NOT work IF a macro (M6) is running a tool change
GetOemLed(172) -----> IF TRUE then a Gcode is loaded
GetLED(4) -----> IF TRUE then CYCLE START is active
GetLed(5) -----> IF TRUE then in FEEDHOLD (pause)
Note there are instances when Mach3 is running a GCODE that you can be in FEEDHOLD and the Cycle start LED will be ON.
AND in some instances whle in Feedhold the LED will be ON. IT just depends on what Mach3 is doing when you FEEDHOLD.
So you have to account for that as well.
(;-) TP
-
UPDATE (;-)
Further Testing, Looks like
GetLed(172)
GetLed(4)
Will do the JOB. BUT you MAY be able to only use
GetLed(4) ----> Cycle Start