Torch Height Controller with Marlin

After a day of googling, I havent been able to find an instance where someone has implimented automatic torch height control with the Marlin firmware.

Basics of Torch Height Control. THC is used with cnc plamsa cutters to read the voltage of the arc being used by the plasma cutter to fluctuate the Z height continuously throughout the cut to deal with the warping of the material caused by the heat. This is done on the fly every couple of milimeters at a minimum. Maintaining consistent voltage throughout the cut will create a cleaner and more professional cut.

There are a couple of THC units available. For the most part, they have an start cut relay, ARC OK, Z up and Z down outputs. For inputs they have start cut and voltage input from plasma cutter. These units can be purchased or built using an arduino.

The easiest way to have THC is using Mach3 and standalone THC, but I havent found a way to use a Rambo with it.

As far as using repetier with THC, the only way Ive found to make that work is the Babystepping function.

If anyone has some insight into this or advise, Im all ears. Unfortunately Im not skilled enough with arduinos to even know where to begin to make this work. In my searches Ive found that there are hundreds if not thousands of people who would love to be able to make this work using ramps, rambo, etc. Figuring out a way to merge either repetier with THC or an arduino with Mach3 cuts the cost of a solid cnc plasma cutter down to prices that any hobbyist could get down on.

Can you link one. I don’t think the control software actually does anything. I am pretty sure marlin and Mach 3 just say “down” “up” and the motion controller sits in between and fine tunes it, similar to how we use the PID we are working on.




After a second round of googling, I found that there is a conpletely standalone option that does exactly that. Takes in the Z direction and step comands and fine tunes it from there before telling the z stepper to move. This would keep the software sending a consistent z height. The more expensive options are a bit more controlable by Mach by being able to have gcode set the desired voltage but thats easy enough to adjust on the unit beforehand and outside of the software.

This unit seems like all the work is done and is probably going to be the easiest.

The unit would still have to send the rambo an arc ok signal to let it know if it should pause or start x and y movements. As well as have a start/stop arc signal from rambo to THC.

Now the only issue that my build would have, is that I would have to get rid of my dual Z endstops that Ive really come to love and go back to z steppers wired in series. I might be able to wire in a pigtail with some switches to go between series and separate drivers.

Am I understanding all this correctly?

That seems pretty close to the right solution. The stepper drivers we use also have an enable signal, so you wouldn’t be able to turn off the z axis. How important is the arc ok message? Can you do something tricky to get it started (or just pause for a few seconds) or just deal with a crappier start?

Another option is the mechanical one, where you peave your Z axis alone, and hook the output of that box to a separate stepper that only lifts/lowers the tool. Since you’re not lifting the router, having the stepper on the gantry shouldn’t be a huge problem.

The Arc Ok signal is important although it doesnt come on the proma sd as far as I can tell. If arc doesnt start and rambo doesnt know it, the x and y will continue to move without cutting at all. I Do not know if the proma sd will work without having some stepper signal coming in. If it can, then making a mount with a second z axis simplifies things and allows me to keep my dual z endstops. Then having the rambo board being able to detect even a small amout of voltage between the work piece and torch should be easy. It shouldnt matter how dirty the signal is. Im glad you guys are helping me out with this. What first seemed like an impossible task is now becoming simpler and simpler. Being over caffeinated today is probably making me over complicate things.

What’s that for? I think the hard part is keeping the rambo safe from that voltage.

The trouble with the arc ok part is I don’t know how to make Marlin pause for an external signal. Is there some kind of spindle ready signal?

I think there is an M command that has the system wait for a signal before continuing. Simular to tool change? That should be able to be done in post processor. Then a separate voltage divider could help from frying the board from arc okay signal?

How big is that voltage and does it spike? My guess is you’ll want some kind of isolating circuit, like an opto isolator. Something like this:

Im unsure of how high my plasma will be runnung, but I believe 0 to 400vdc is about right? I keep seeing things about 50:1 voltage dividers, but I havent had the time today to learn about them. That opto isolator looks like the right idea, but I think it needs to work the other way around. Is there an easy way to get a varying voltage to a simple open/closed circuit? I also have no clue about spikes and inconsistency in the arc voltage. Whatever needs to happen to create a go/nogo signal should be sufficient.

I’ve been down this road a few months ago so I have some suggestions you may consider. THC can be made with Arduinos and be made to interface with Marlin. However, I did not find much of anything regarding this such as guides or hardware that is current.

Marlin is first and foremost a 3D printer firmware. It can be extended to CNC routers, but there are other firmwares more suited for that (GRBL) that can run on the same hardware (RAMPS 1.4). When I created my LR plasma I started with GRBL and even then I found plasma support lacking. Anything that I did find seemed hacked together and THC support was also very limited. You can go with a Proma and it will be completely independent of your firmware because it handles all of the stepping for the Z-axis. The downside is when you come upon “corner-lock”. When you slow down to cut a corner, heat builds up and voltage increases. This causes the torch to dive because it thinks that it is too far away from the surface. This is a problem that a THC can’t solve alone, it needs help with an intelligent hardware/firmware setup.

I switched over to LinuxCNC with Mesa cards (5i25&7i76) with the Mesa THCAD-300. The THCAD-300 takes raw arc voltage from inside the plasma cutter, and converts it to a frequency. With the frequency, torch height can be optimized. It’s a bit different than the Proma standalone THCs, but you have higher controllability.

I stalled on my plasma for a while because LinuxCNC has a fairly steep learning curve (there’s so much to tweak!) and it was so hot in the garage I didn’t feel like troubleshooting wires and firmware code. Within the last week I’ve gotten a lot accomplished to get back to setting it up.

If you wanna keep going the RAMPS/Marlin/Arduino route then go for it. It would be great to have a low cost option. The easiest but most expensive way would be Mach3/Proma THC (Mesa hardware is LinuxCNC only). Seems to be a little more plug and play as far as setting things up goes. LinuxCNC is great and has potential, but it is pretty complicated at first introduction.


**Which plasma cutter do you have? If it doesn’t have a CNC port on it then it likely won’t have 50:1 divided voltage available, you’ll have to deal with raw arc voltage. Also, Arc-OK signal is not critical, you can fake a high signal for the THC. You would just lose a fail-safe if it doesn’t start.


I’m a badge carrying windows hater (Linux, not Mac), so take this next comment with a grain of salt, but…

More expensive doesn’t equal better. Sometimes people who drop a bunch of money on stuff convince themselves they don’t regret it, so find facts and examples. I love that there’s a Linux solution. Mach3 could be simpler and better, but don’t think that just because if the extra price.

Isn’t LinuxCNC called MachineKit now?

I’ve asked some developpers people about implementing torch height control in Marlin a few months ago. They were ok with it and actually willing to implement this function.

I just had to build the voltage sensor and install it on my plasma cutter for them to try to develop the code according to the voltage readings, but I got caught in some other projects and didn’t manage to get back at it, my bad :frowning:

I guess if you purchase a commercial torch height control unit and explain your need well enough to the Marlin team they surely will be able to help you, I was very surprized to see that they were actually willing to give it a shot, they have a wonderful community.

I’ve found the thread, you can see the discussion here (at the bottom of the discussion):


That’s interesting, I haven’t thought of this issue before.

Can’t you just raise the acceleration and jerk settings so that the plasma cutter won’t slow down as much when arriving into a corner? I guess if you go fast enough then the problem won’t be very significant.

Since there are almost no effort at all on the Z axis you can go very high on acceleration. For instance, on my MPCNC 3D printer, I’ve already set the acceleration settings to 6000 and it was working fine, despite a 400mm long Z axis and very heavy tubes.

Might worth a shot, who knows.

I Definetly like the options available with Mach and a high quality thc with trusted algorithms, kerf detection, and having software know when its going over a hole. But I also dont want to creep so close to the cost of turn key cnc plasma table that I had wished I went down that route. For me specifically, it sounds like and arduino THC or something similar will be good enough for what Ill be needing. I also like the idea of trying to push the low cost option forward so that maybe one day this tech can be had by anybody.

It wasnt long ago when 3d print quality was so bad it was funny and still more epensive than my car.

Also, an arduino option would allow for custom algorithms that could detect quick voltage spikes and recognize them. I couldnt do it cuz Im not savy that way. But the beauty of “open source stuff” is someone could make something halfway decent and others could make something great out of it.

My plasma cutter is an everlast powerpro 164Si. Multi process tig/stick/plasma. No cnc port.

I believe MachineKit is more of a fork from LinuxCNC. It has been demonstrated to work on BeagleBone Black and RPi 2/3’s, which is quite awesome.

I’m quite surprised that they are willing to add these features. It will be a lot of work for a small user base, but I guess that is how you grow and attract more.

You can, but you always have to deal with inertia. Depending upon gain values for the THC PID control, it doesn’t take much to cause the Z-axis to react quickly to a change in voltage. On the other hand, there are no cutting forces involved so feed speeds will be much higher than typical routing.

I seem to struggle with this every time I run into a problem with software or some new hardware, “If only I spent the money I’ve invested now on a commercial solution.” The big thing is knowing what your limits are and how much your time is worth. I wanted to pursue the Arduino THC route but I didn’t have the patience to problem solve everything.

As an aside, plasma cutters produce tons of electrical noise. Besides running all shielded cables, utilizing a higher voltage on your signal lines helps with the SNR. Another plus of LinuxCNC is I’m able to run 24v inductive sensors for my endstops. Using 5V logic level can be tricky when noise can be a couple of volts alone if not dealt with properly.

If this is a hobby, then you have to look at the time spent as the benefit and not the cost :).

I’ve also spent a bunch of time with commercial offerings (not CNC stuff, I work in software) that cost more than $30k and it took more time, and I had to call (really, in 2018) support guys to get them to help me workaround “known issues”.

The make or buy is always a question, but if you’re adding in time, don’t forget that making things is fun, and the commercial stuff takes time too.

Hi all.I see the posts and wanted to ask if the THC is needed for curved metal sheets or generally is needed.I have a plasma and want to put it in my LR.I want to cut only 2D sheets that are flat.I was thinking to put a relay and control my plasma throught Estlcam ,but maybe is not needed because if there is no touch,no heat is produced,so i may add a little lift after every cut.How do you turn on and off the machine?