GRBL Plasma w THC, Torch Touchoff, and Rotary

update: jump to last post in last page of this thread for the latest scpost file download.

I’ve posted this custom .scpost code in various forum replies and questions, various versions of the .scpost while I’ve been developing it. I think it’s pretty stable now, it has features that I like and functions well for my plasma table. Perhaps others can use it with minor changes or as a model in making their custom .scpost, I tried to comment the code well for readability. As it changes going forward, I’ll update the version here.

10/30/23, version 15
updated post, -

  • added another external variable LdcThcZAntiDive, 0 Off, 1 ON, default is ON. The THC Z Anti-Dive enable/disable gcode used is specific to a custom circuit that I built, link to schematic here: bC THC Z Anti-Dive circuit.jpeg - Google Drive
    To use this post without that circuit either change the enable gcode to suit your Anti-Dive circuit or disable the gcode production of it by setting the variable to zero 0.
  • changed some var names to more meaningful names
  • added many new comments to describe external variables, post logic, and gcode.

11/2/23, version 16
update .scpost -

  • as I was replying to another forum question I realized I forgot to cover the case of grbl1.1e+ running on an Arduino Uno board, where D11 is the trigger pin/signal (SPWM signal). So this .scpost version changes the torchfire command to “M3 S1000” to cover this case, when LdcThcZAntiDive = 0.
    GRBL plasma LDC.scpost (15 KB)
    GRBL plasma LDC.scpost (14.2 KB)

updated scpost to version 17

I assume this post won’t work without a THC?
Also I don’t have the Z axis set up yet, so I assume it will hang on the probing step?


It does work without a THC, set external post variable LdcThcZAntiDive = 0 .
It does NOT work without motorized Z axis for reason you noted.

Hello ! It Is amazing to see what is done and shared in some forums, thank you very much bLouChip !

I fear my designed is not adapted to your postprocessor, but may be someone may tell me I am wrong or explain how to tweak the postprocesser to fit this different design.

I based myself on JD Garage too. So I have built the Z axis in the last days. But one first doubt is, this one makes the probe touch and trigger the switch once it is squeezed between the material and the switch. It is based on the z motor lowering the switch against the strength of compression spring. But you say your design works with gravity dropping, right? How to deal with this difference? Any simple solution?

Other difference, not implemented yet, is the rotary axis I plan to install with a chuck, parallel to Y axis. I therefore replaced my Arduino Uno by a Mega, and gave it a fork of grbl, Grbl Mega 5X, to handle the extra axis. That makes a big difference and requires changes in the postprocesser, right?
I was thinking I could just use two different postprocessors according to my task, and use the Z probe only with sheet metal. Bent tubes are not recoverable, and useless in CNC stuffs but it may a pain to always need to switch
Any tip or suggestion will be warmly welcomed.

A last question is about your use of a THC, which I plan to implement as well. I was considering to install a standalone THC, may be make it of my own with an extra Arduino. I believe I understood that in your postprocessor design, the THC is activated only after the plasma arc is rather stabilized, does its job while cutting, and is put off once the cut is done, letting then the z probe take back the control of the same motor, right ? (Since you use Arduino I guess some other THC system communicating Z DRO changes with the the CNC would be impossible. But I prefer to ask now to be sure the design I plan to do will fit an available postprocessor, not as I did before, referring to the previous questions)
Thank you very much for your precisions.

Thank you for the compliment, I’m happy to help.
I’d like to suggest that you move this discussion to a new thread in this forum as it appears it will be rather busy and specific to your build. We can cross link the threads for reference, and I’ll move this reply to into your new thread also.

My scpost may be closer as is to meeting your needs than you believe, but if not, I can help you customize it.
I use the Atmega2560 MCU also, and run the 5axis grbl fork, although I’m using only 4 axes and my rotary is parallel to X, so its axis letter is A. Yours will be B, which is parallel to Y. I too will be using rotary with plasma process soon, so I will add rotary support to my scpost sometime in the next 3 months, I don’t anticipate it being a major change.

re. the Z axis and torch probe touchoff mechanics- I believe some folks refer to this mechanism as “floating torch mount”. That is what I use, its the same concept as JD Garage design as far as I know. The floating or sliding torch mount normally hangs against its down stop position due to gravity, and thus stays off the actuator for the probe switch, until Z motion moves down to compress the “float” distance and actuate the probe switch. The float distance is what I refer to as LdcTorchProbeTravel.

re. THC- I use Proma THC SD brand and model. Per its stock installation and wiring diagram it is always “active” and looking for an arc voltage. Once it detects an arc, it takes over (after its own programmed delay to allow the arc to stabilize) the Z axis motor independent of the grbl controller, by relay switching the Z STEP and DIR control signals. I wanted more control than this, so I built a THC Z Anti-Dive circuit to intercept the Z STEP signal from the THC and block it at times, essentially rendering the THC OFF. Thus I can let the circuit work automatically in the Z Anti-Dive mode when XY cornering and during other XY accel/decel motions that would spike the arc voltage, or I can command the THC OFF state using grbl Spindle power percentage (SPWM) gcode stmt and signal at any time.

You can see photos of my CNC build here:

Thank you for your fast answer !

As you suggested, I created a new and specific thread, here :

Just one last question. Where, with which informations and sources, how did you learn how to adapt and write your postprocessor code ?

Update: Version 18
Added Rotary-plasma plugin support. I’ve only done minor machine testing, but much more bench testing. I’ve only tested rotary modes of Flatsheet and Round Pipe. Rectangle and I-Beam not yet tested and I know more work is needed to support those modes, I don’t advise you try those.
Note that rotary jobs by this scpost assume WCS torch zero is the surface of the cylinder, NOT the center of axis rotation as do most other rotary scpost code. I do this because my machine only has 100mm of Z motion available, so I adjust the height of the rotary chuck on Z so the range of 100mm motion is sufficient.
If you don’t have the Rotary-plasma plugin license, don’t use this version, continue to use version 17.

I changed 2 external post variable names to make more sense to other users;

  • LdcThcZAntiDive has been changed to LdcThcPresent, still 1 for yes, and 0 for no THC.
  • LdcThcOn changed to LdcThcEnable, still 1 for ON and 0 for OFF.
    These and other external post variables are dynamic now, so you can use Set Post Processor Variables Operation to change them during runtime.
  • added machine Pause based on a timer that you set in the scpost file, the job will Pause when the timer tips OR between Parts. The timer pause is for the case of allowing an under capacity air supply to catch up. Pause will occur after moving to next shape and in the safeZ position, before pierce so the air should be flowing over solid metal. Pause requires operator intervention to Resume, either via Cycle Start in the sender program or physical pushbutton on the control panel connected to controller Resume input.

Update: later same day, I found a bug, fixed, and reposted file since no downloads yet. Version 18.1

Please read the scpost header comments for full usage information and how to adjust values to your machine if necessary. The external post variables should cover most cases.

GRBL plasma LDC w Rotary.scpost (23.8 KB)

There is a Boolean variable for posts & tools (and maybe operations), although I still don’t think it works correctly in the post variables. I noticed this a while ago, and posted it as a bug on the forum, but I don’t think it’s ever been fixed. Maybe you’ll have better luck. In the tools it displays a checkbox, so you can use a check to select instead of 1 & 0.

@djreiswig - agreed, I tried it, likely hit the same bug. As I recall the bug has to do with the external boolean var testing false regardless of value set in the Set Post Processor Variable Operation, or maybe it was when setting it from the Options window; perhaps it arrives inside the scpost as a number 0 or 1. It was confusing so I went back to unit0DECPLACE instead for external variable flags. I do use other boolean datatypes inside the scpost with success.

Due to the way SheetCam stores values internally, sc.unitBoolean results in a numeric value that is 1 for true or 0 for false. This works fine in C++ but unfortunately Lua regards anything that is not boolean or nil as true.
To be safe you need to do a comparison:

   if LdcThcEnable == 1 then

The bug I found was not with the value, but with the fact that it doesn’t display the check box in the post options window like it does everywhere else.

Do you mean using post.DefineCustomOption and post.ShowCustomOptions?
I just checked and it appears to work in both dev and stable.

Apologies. It wasn’t working on 7.1.22, but I just updated to 7.1.35 and it’s fixed. Thanks Les.

updated scpost, version 20-beta

SheetCAM’s Rotary-plasma plugin support has been added, but it is NOT required.
If you don’t use the Rotary-plasma plugin, that is it is not an “Enabled” plugin, then you should comment out the Rotary Plasma and Helper library stmts at the end of this scpost, as such:
–package.path = sc.Globals:Get().thisDir … “/plugins/RotaryPlasma/?.lua”
If you do use the Rotary-plasma plugin, then those stmts are required.
Know that you can have the Rotary-plasma plugin “Enabled” all the time and just select “Flat Sheet” in the plugin dialogue to run a 2D job, ie rotary is not used.

I have tested this scpost with Rotary-plasma plugin for Flat Sheet, Round Pipe, and Rectangle Tubing thus far, but pretty minimal testing, so be careful with use. I have also tested it without the plugin enabled.
Please report problems here or send me a PM.

*** For Rectangles, zero Z on the apex of a corner rotated to top dead center. In other words,
*** that is the maximum radius for the object.

GRBL plasma LDC w Rotary.scpost (26.6 KB)

updated to version 20.3-beta

I updated internal processing to more clearly handle cases of turning the THC ON and OFF. I’m not using the crazy Spindle Speed method anymore, doing so was taking advantage of a condition as to how the THC Z Anti-Dive circuit operates. Rather, I just use M7 now to manage THC ON/OFF state. I had to modify my THC Z Anti-Dive circuit to do this and it provides for fast dynamic switching of the THC now, as well as giving Z control back to grbl controller in the THC OFF state. I needed that THC / grbl controller well behaved operation with Z in order to cut rotary rectangle tubing, in cases where the shape is spanning a tubing corner, in those cases you will see grbl Z and Y motion gcode during the rollover through the corner, I’m guessing having an active THC may not be a good thing on those special condition shape cuts on a machine like mine. Special purpose rectangle tubing plasma rotary machine may be able to handle it with a THC active, either way you get the choice with the post variable LdcThcEnable.
Change the THC ON and OFF commands for your THC in the scpost prologue; LdcThcONcmd and LdcThcOFFcmd.
Schematic updated here: bC THC Z Anti-Dive circuit.jpeg - Google Drive
GRBL plasma LDC w Rotary.scpost (26.5 KB)

updated to version 21

updates involve clarification of code comments and testing and corrections to OnDrill()
GRBL plasma LDC w Rotary.scpost (27.1 KB)

update version 21.1

sorry for the quick change, but I decided to make the OnDrill() function/operation a pecker instead of a driller, but you have the option to easily adjust the pecking parameters in OnDrill(), so you can make it a driller just as easily. This is done without needing to change the tool.

Please report any bugs here; I’m not getting a lot of “table time” these days with the chilly weather, my shop is “naturally aspirated” with a 2300CFM blower during plasma cutting :frowning:
btw - I’ve tested this scpost with both the latest SC Dev version of 7.1.35 and with the SC ga version of 7.0.21
GRBL plasma LDC w Rotary.scpost (27.9 KB)

udpated to version 22
– 21 added OnDrill() support pecking or pierce hole
See the function OnDrill() for fine tuning the pecking parameters; %(75) of pierceDelay, and %(50) of plunge distance to “cutHeight”, thus no need to change tool for plasma “drilling” or pecking. 0.75 and 0.50 are the defaults respectively.

– 21.3 added YA and YB motion options, in addition to XA
See header comments for one of 3 assignments to rotaryAxis global var, XA is default.

– 22 added Marking Tool support, such as EasyScriber
See header comments and global var for marking tool plunge feedrate assignment, 300mm/m is default. When defining the Marking Tool, for Z zero at top of material, use a negative Cut Height value which is the distance to compress the scribe spring for drag tension. Material Thickness on the Options-Job window must be larger than the absolute value of the Cut Height. Also, Plunge Safety Distance from this window is used on rapid motion to start point and in lieu of “pierceHeight” masquerading as cutHeight (which recall is negative value).
GRBL plasma LDC w Rotary.scpost (32.2 KB)

updated version 22.1

– 22.1 fixed machine pause logic on new part.
During testing this morning I discovered that parts are not processed in the order that they reside in the part tree. That makes sense such that optimization can do its job, cutting parts in the most efficient order and per optimization rules.
22.2 machine pause at start of job only for rotary jobs
22.3 fixed machine pause logic during OnDrill(), entityLength nil

update Jan 26…
22.4 prologue and comment fixups
22.5 split and adjusted THC control and LdcSmallShape logic, and corrected entityLength use
23 removed LdcSmallShape option and logic, SC Path Rules ‘on small shape’ is predictable as ~entityLength/pi depending on toolpath offset
GRBL plasma LDC w Rotary.scpost (31.9 KB)