Skip to main content

Upgrading a CNC plasma cutting machine part 4


Implementing torch height control

When using a plasma torch, good cut quality requires a consistent gap between torch tip and material, which is commonly known as torch height. Since most sheet metal stock is not perfectly flat and can warp due to heat introduced during profiling, torch height control (THC) is often employed for CNC plasma cutting.

THC systems monitor torch height, dynamically correcting it throughout the cut, according to a preset target height. As our machine currently only has very basic torch height positioning, in this post we will build our own THC solution before tuning and testing performance.

For details of the build so far, see the first, second and third posts in the series.

Accurate torch positioning


To improve control of torch height, it was decided that the simplest solution would be to replace the existing DC motor with a stepper motor, which can provided sufficiently accurate and repeatable positioning. Alternatively, an encoder could have been fitted to the DC motor and servo control implemented.

A NEMA-23 stepper motor and linear stage will provide the Z-axis motion, whilst a breakaway torch holder adds a degree of forgiveness in case the torch crashes into the work piece or machine bed. A microswitch is fitted that will trigger emergency stop in case of the torch being detached in this way.


The gantry has a thick aluminium plate upon which the new parts could be mounted. This was removed from the machine, drilled and tapped as required.


A new hall effect sensor was added to act as a Z home switch. For consistency, this is the same as the X and Y home sensors and will connect to an input on the PBX-BB (Probotix breakout board for the BeagleBone Black) via a relay in the control cabinet. A bracket was profiled from sheet steel, folded, painted and added to the slide carriage to act as the trigger for the new hall effect sensor.

A length of multi-core cable was added to the machine loom to connect the new configuration to the control cabinet. Both the stepper motor and hall effect sensor were wired with crimp connectors, allowing for easy removal and replacement in the future if necessary.


Inside the cabinet, the H-bridge board previously installed to control the DC motor was now redundant and so removed. In it's place, a Geckodrive 201x stepper driver module (793-4127) will provide high quality control of the new stepper motor. This was mounted to the cabinet and wired in the same way as the driver modules for the X and Y axes.

Sensing arc voltage


Our THC will monitor the voltage of the cutting arc, which changes according to torch height, before adjusting the torch height accordingly. The Hypertherm Powermax 45 power supply has a built-in voltage divider that provides a 50:1 arc voltage output via the machine interface.

A note in the Hypertherm manual states that whilst this provides impedance-protected ELV (extra low voltage) output, it is not fault tolerant and does not comply with SELV (safety extra low voltage) requirements for direct connection to computer products.

This was taken into consideration when building the rest of our system. The simplified diagram above shows the separate components of the THC. A circuit was built using an ADC IC (379-2465) with appropriate protection against possible faults with the output from the Hypertherm power supply. A low-pass filter with a threshold of 45Hz was also included, to eliminate various high frequency components present on the signal.


The output of the ADC circuit was connected to the SPI bus of the BeagleBone Black, requiring a set of jumper wires to be soldered on to the PBX-BB. This will allow for the digital output from the ADC to be read directly into Machinekit, with the use of custom HAL component.

Machinekit configuration


If you have been following this series of posts you will now be familiar with the Machinekit HAL – Hardware Abstraction Layer – that provides a high degree of flexibility with the use of text based configuration files. These files determine how the hardware and software inputs and outputs are connected, as well as managing other machine parameters.

Changes were made to accommodate the new Z axis configuration, including stepper motor control and the new home switch. Motion was calibrated using a dial gauge as we had done before for the X and Y axes.

To get the readings from the ADC into Machinekit, a custom HAL component was written. This was executed on a new realtime thread with a period of 1ms. Another existing HAL component, THC.icomp, was also used. Initially written for use with a MESA THC, this is a flexible components that we were able to use with our own setup, by following the documentation.

Testing operation


With modifications made to the HAL and the Z axis configured, we could move on to testing the THC. This turned out to be reasonably involved, given that we had a particularly noisy arc signal from the plasma cutter and tuning that could be performed in hardware and software.

THC presents challenges that are different to other CNC machining operations, with one LinuxCNC wiki page declaring that “THC does not adhere to the rules for normal CNC and has to be treated with caution”. Full discussion of concepts behind and complexities of THC are beyond the scope of this post and further reading is encouraged.


Before connection to the output from the plasma cutter, a bench power supply was used to provide different voltages to the input of the ADC board, so that we could determine that the system was functioning as expected. A range of 0 - 8V, with 0.5V increments was used.

HALMeter is a useful utility built into Machinekit that allows for monitoring of pins, signals and parameters from within the GUI. It can be thought of as serving the same purpose a multimeter does when working with hardware.

HALMeter was used to display the values read from the ADC board into Machinekit, and verify that they changed as the input voltage varied. The values were noted down and used to calculate the conversion factor between input volts and the number read in Machinekit.

Content that the ADC was functioning, the plasma cutter was connected and first cuts made with the THC system in operation. Increased caution was exercised as the system was still being tuned, with increased likelihood of crashing the torch into the workpiece, or some other malfunction occurring.


Multiple parameters to adjust meant that many cuts were needed, each time with performance assessed and a single parameter changed. With time and over the course of many adjustments, the behaviour of the system improved and eventually the torch height was being adjusted so as to follow the variation in height of the sheet material. The THC was working.

Further improvements and next steps


Despite now having a functional THC, there is still room for improvement. Though the stepper motor is able to jog the torch up and down quickly, the THC system cannot achieve the same velocity when operational. Further tuning is required.

Though care was taken when interfacing the output from the plasma cutter to the ADC, it may also be that additional isolation and/or filtering is required to obtain reliable voltage readings.

More testing is required by running a series of jobs with different parameters and compiling more data. This should allow us to further tune the hardware and software configuration.


Finally, it was also decided that an extra emergency stop switch located on the machine itself would be sensible, since the control cabinet is located some distance from the moving gantry. This will be wired in series with the aforementioned breakaway torch holder microswitch.

In the final post of this series we hope to share the completed machine configuration.

maker, hacker, doer
DesignSpark Electrical Logolinkedin