I'm a bit of an impasse with my (custom) plasma setup. The controller uses GRBL and I'm using spindle speeds to control my torch height control (THC) and turn it on/off.
I thought this would be simple to set up cut rules for -- just add S400 or S800 to turn the THC off/on and I'm set, right? But it turns out that GRBL (even in laser mode) has some funny behavior with this. If the spindle speed command is on the same line as the G1, it continues motion normally (which is what I want). If the spindle command is on a new line in the G-Code then it pauses, which is what I don't want.
But I can't get SheetCAM to output this on the same line because the "code snippet" feature adds a new line. Is there any way at all to set a variable in Lua instead? If I could access the cut rules somehow in the post processor, my problem would be solved. But as far as I can tell, SheetCAM can't do this. Is there any way?
(I've tried working around this problem by setting the code snippet to "G1 S400", this doesn't work either.)
Can I set Lua variables using cut rules?
Re: Can I set Lua variables using cut rules?
You should be able to set up the THC totally inside the post. That's how my candcnc setup works. How do you determine where the code snippets go currently? That might help figure out how the post needs modified. Also, which post are you using?
Re: Can I set Lua variables using cut rules?
I'm using a custom post. Is there a way to change where the G-Code snippets inserted by the cut rules go in the post, or have any control at all over the process? This is what I'm asking.
The entire issue I'm having is that SheetCAM inserts a line break before adding the snippet. It needs to be on the same line as the move because otherwise GRBL doesn't behave properly. I can work around this by running a script manually on the G-Code that SheetCAM outputs but I'd reaaaaally prefer not to add an extra step to the process.
Re: Can I set Lua variables using cut rules?
I'm guessing the snippets are always going to be on a new line. Maybe Les will chime in. I don't use snippets.
Re: Can I set Lua variables using cut rules?
@neckro23-
I happen to run across this thread while searching for the same use case, Are Lua variables supported in code snippets ? It doesn't appear that they are, unless Les chimes in.
However, I believe I can help re. the specific code snippet use case you have to change spindle speed while also maintaining continuous XY motion while in grbl laser mode ($32=1) and using M4 to fire the torch. I use code snippets to do exactly this, to enable and disable my THC as well.
Disable THC
I use this in a Path Rule "Before end" 2mm from end of shape cut.
Enable THC
I use this in a Path Rule "On start" after 10mm into a shape cut.
It works like a charm. Enjoy.
I happen to run across this thread while searching for the same use case, Are Lua variables supported in code snippets ? It doesn't appear that they are, unless Les chimes in.
However, I believe I can help re. the specific code snippet use case you have to change spindle speed while also maintaining continuous XY motion while in grbl laser mode ($32=1) and using M4 to fire the torch. I use code snippets to do exactly this, to enable and disable my THC as well.
Disable THC
Code: Select all
G91 G1 X0 S0 (block THC Z ctrl w ADC w continuous motion)
G90
Enable THC
Code: Select all
G91 G1 X0 S1000 (pass THC Z ctrl w ADC if enabled, w cont motion)
G90
It works like a charm. Enjoy.
MillRight CNC MegaV XL XYZA Tri-CAM Mill/Plasma/Laser
grbl 1.1i, UGS, Win 11, LightBurn, SC, Aspire, and sometimes [con]Fusion360
my youtube channel
grbl 1.1i, UGS, Win 11, LightBurn, SC, Aspire, and sometimes [con]Fusion360
my youtube channel