Machsupport Forum

G-Code, CAD, and CAM => G-Code, CAD, and CAM discussions => Topic started by: TomR on April 26, 2012, 04:26:48 PM

Title: How can I have a G-Code program load and run another G-Code program
Post by: TomR on April 26, 2012, 04:26:48 PM
I have three (3) G-Code programs that I would like to run sequentially.  Due to the length of each program, it would be desirable to have a snippet at the end of each program to call/load and run the next G-Code program upon its completion.  Is this possible and could you provide a snippet that might accomplish this objective.

Thanks for your time, TomR
Title: Re: How can I have a G-Code program load and run another G-Code program
Post by: BR549 on April 26, 2012, 05:44:36 PM
FIrst you need to create a mcode(macro)

'M5001 Macro to run next program
LoadRun(C:\Mach3\Gcode\NameOfNextFile.txt")

The you insert the Mcode just before the M30 and use the block delete slash.

/ M5001

This way you can turn OFF the program transfer if needed using block delete.

Now where the 1st program ends it will LOAD AND RUN the called file automaticaly. IF you want it to load and wait for a start then use

,M5001 Macro to load file
LoadFile(C:\Mach3\Gcode\NextFileName.txt")

It will load the file and WAIT for you to press start.

FOR the 2nd file load use another macro M5002 cna call the next program as you did it the first.



(;-) TP
Title: Re: How can I have a G-Code program load and run another G-Code program
Post by: TomR on April 26, 2012, 06:09:43 PM
BR549:

Thanks for your reply. I am going to give this a shot first thing tomorrow.

I really appreciate your help,

Regards, TomR
Title: Re: How can I have a G-Code program load and run another G-Code program
Post by: BR549 on April 26, 2012, 07:18:45 PM
I have also done it another way. I created a Control macro that you could type in the files names in order of run and IT would process each gcode file in order.

(;-) TP
Title: Re: How can I have a G-Code program load and run another G-Code program
Post by: TomR on April 26, 2012, 08:16:17 PM
My wife had to run to the store so this gave me a chance to try your macro suggestion tonight.  Sometimes she gets impatient when I work on my router in the evenings.  Women just don't understand these things.

Anyhow, when I try to write the macro I get a VB Scipter compile error and highlighting the ":"  Here is the text of the macro:

'M5001 Macro to run Push Stick.Tap
LoadRun(C:\Mach3\Gcode\push stick.tap)
 
Any ideas?

Regards, TomR
Title: Re: How can I have a G-Code program load and run another G-Code program
Post by: BR549 on April 26, 2012, 09:39:08 PM
YOu forgot teh "    " same as I did in the example

'M5001 Macro to run Push Stick.Tap
LoadRun("C:\Mach3\Gcode\push stick.tap")

Also IS "push stick" all one word OR is there really a space in between?

OOPS, (;-) TP
Title: Re: How can I have a G-Code program load and run another G-Code program
Post by: TomR on April 27, 2012, 10:46:48 AM
Thanks BR549. 

Making the above format change has the M5001 macro working perfectly.  I tested a 3-program sequence with complete success.

Thanks for all your help.  Also "push stick"  does include the space as typed, however a good heads-up on your part.

Regards, TomR
Title: Re: How can I have a G-Code program load and run another G-Code program
Post by: BR549 on April 27, 2012, 03:50:50 PM
Just a suggestion but that space has gotten me several times in the past(;-)

I started useing a filename format as ALL one worg but capitialize the first letter in each word.

PushStick.tap

Just a thought, (;-) TP
Title: Re: How can I have a G-Code program load and run another G-Code program
Post by: TomR on April 27, 2012, 06:18:32 PM
Good thought, I see what you mean.

Thanks again.
Title: Re: How can I have a G-Code program load and run another G-Code program
Post by: TomR on May 01, 2012, 05:45:42 PM
The mcode macro is working fine in running gcode programs sequentially.  However, the tool path is not regenerating on the tool-path screen when the macro loads and runs the gcode.  I tried using an OemButton(160) after the load/run command but without success.  Mach3 shows a dialog box indicating the tool path is being regenerated but neither regenerates the tool path nor runs the gcode.  Seems like its in some kind of loop.

'M5001 Macro to run PushStick.Tap
LoadRun("C:\Mach3\Gcode\PushStick.tap")
While IsLoading()
Wend
DoOEMButton(160)

Thanks, TomR
Title: Re: How can I have a G-Code program load and run another G-Code program
Post by: BR549 on May 01, 2012, 06:14:10 PM
YOU may want to try the other method

Loadfile("C:\Mach3\Gcode\PushStick.tap")   'Load new file
While IsMoving()
Sleep(1000)
Wend
DoOemButton(160)  ' Regen toolpath
While Ismoving()
Sleep(5000)
Wend
DoOemButton(0)     'Start program


(;-) TP



Title: Re: How can I have a G-Code program load and run another G-Code program
Post by: TomR on May 04, 2012, 11:44:39 AM
I tried the above macro but found the tool path regeneration oembutton 160 goes into some kind of indefinite loop.  The tool path dialog box opens indicating the tool path is being regenerated but only "hangs" there indefinitely.  Cycle Start never executes.

Also, I assume DoOemButton(0) is a typo and should be DoOemButton(1000).

Thanks, TomR
Title: Re: How can I have a G-Code program load and run another G-Code program
Post by: BR549 on May 04, 2012, 01:11:06 PM
SO far eveything has worked here, BUT that is not unusual.  IT MAY be the files that you are trying to use. CAN you post teh files so I can test them here.

Try this method, It does work here as well.

'M5001 Macro
DoButton(169)  'Close Current G-Code file
LoadRUN("C:\Mach3\Gcode\RR2.txt") 'Load Next G-Code File
While ISmoving()
SLeep(5000)
Wend
Title: Re: How can I have a G-Code program load and run another G-Code program
Post by: BR549 on May 04, 2012, 02:58:49 PM
IF you do not want the 5sec pause remove the

Sleep(5000)
Title: Re: How can I have a G-Code program load and run another G-Code program
Post by: TomR on May 06, 2012, 10:50:47 AM
Attached are the three test files I have been using.  It is actually the Road Runner divided into three separate files. 

Thanks, TomR
Title: Re: How can I have a G-Code program load and run another G-Code program
Post by: BR549 on May 07, 2012, 12:48:39 PM
Tom I have tested here and it works fine stiching all 3 files together.

(;-) TP
Title: Re: How can I have a G-Code program load and run another G-Code program
Post by: Graham Waterworth on May 08, 2012, 06:07:53 PM
Hi TomR,

are you using a licensed or the demo version of Mach3, the Demo version has limitations.

Graham
Title: Re: How can I have a G-Code program load and run another G-Code program
Post by: TomR on May 10, 2012, 11:01:27 AM
Well that appears to be the problem.  I have a licensed version at our shop but a demo version at home where I do most of my code development.  When I used BR549's macro on the licensed version, it worked fine.  I was surprised to find the demo has such limitations.

Sorry guys and I hope I didn't waste your time.  I really appreciate your help.

Regards, TomR
Title: Re: How can I have a G-Code program load and run another G-Code program
Post by: BR549 on May 10, 2012, 03:24:44 PM
Art pretty much knew most of the ways around the 500 line demo restricitons(;-). THere ARE a few that work BUT they shall remain unmentioned

(;-) TP
Title: Re: How can I have a G-Code program load and run another G-Code program
Post by: TomR on May 11, 2012, 11:43:27 AM
Pretty please!  I won't tell anyone.