Mach4 autoload Gcode on startup
Hi all,
New to Mach4. Bought and AVIDCNC router complete package. I've got most thing working fine, but I need to Automatically load my Gcode file on startup of Mach 4. This machine will only ever use one gcode file, so would like to take the operator "out of the loop" on loading the gcode file.
Any help greatly appreciated.
-Matt
Re: Mach4 autoload Gcode on startup
Hi,
you could put some code in the PLC script.
The Screen Load script loads first when Mach4 fires up. At the conclusion of that script loading then the PLC runs. There is a counter so that you can detect the first run of
the PLC script, and in that section you would put such things a module loads, and in your case open a Gcode file. The code in this section is executed just the once,
imediately after the Screen Load script.
Would that be adequate?
Craig
Re: Mach4 autoload Gcode on startup
Hi Craig,
Yes, that would work. I tried editing the LUA load screen file (see below) from a thread I found on the Artsoft support forum. I tried both formats discussed in the string using "//" vs "/" in the file name but cant get the file loaded. Unfortunately the Admin has not approved my account for the forum yet, so I'm reaching out here.
Thanks for the response.
-------------------------------------------------------
-- Screen Load Script
-------------------------------------------------------
pageId = 0
screenId = 0
testcount = 0
machState = 0
machStateOld = -1
machEnabled = 0
machWasEnabled = 0
inst = mc.mcGetInstance()
mc.mcCntlLoadGcodeFile(inst, "C:/Mach4Hobby/GcodeFiles/O0001.ngc")
mc.mcToolPathGenerate(inst)
Re: Mach4 autoload Gcode on startup
Hi,
no you don't want to put it in the screen load script. The script loads little chunks at a time. What happens if the bit they you want to load requires some other bit that has
not yet loaded....it'll fail. No....what you do is wait until the screen load script has fully loaded and started running so all of Machs framework is in place and then call your Gcode file.
Open the screen editor and peruse the PLC script. You'll see a section that runs when the variable testcount is 1 and not otherwise. That is where you would put your script or better still a a pointer or call to it.
I would construct your script 'in a sand box' and NOT put it in the PLC UNTIL is be written and debugged. Its a f*****kup to put faulty code into the PLC because it run every few milliseconds
and any cockup gets repeated and repeated again.
Craig
Re: Mach4 autoload Gcode on startup
Thanks Craig,
I'll look at in the AM and post results.
2 Attachment(s)
Re: Mach4 autoload Gcode on startup
Hi Craig,
I assume you mean PMC vs PLC ?. I have a PMC editor for ladder logic which I have done. When I look at the PMC file, I don't see any reference to timers. In the Ladder logic utility, i don't see a method to load gcode files.
Sorry if I'm missing something obvious as I'm new to Mach4.
Attachment 503594
Attachment 503596
Re: Mach4 autoload Gcode on startup
Hey Craig,
I think I found what you were referring to after I made the post, so disregard. Thanks
Quote:
Originally Posted by
AUSTINMACHINING
Hi Craig,
I assume you mean PMC vs PLC ?. I have a PMC editor for ladder logic which I have done. When I look at the PMC file, I don't see any reference to timers. In the Ladder logic utility, i don't see a method to load gcode files.
Sorry if I'm missing something obvious as I'm new to Mach4.
Attachment 503594
Attachment 503596