Plasma CNC and THC with PlanetCNC TNG

Plasma CNC cutting machine is one of the most commonly used types of CNC machine.

It’s used mostly for cutting Steel, aluminium and other conductive materials.

Like any other type of CNC machine, plasma machine has it own specifics. Machine should be properly designed for such type of machining, considering slag, steel dust, high temperatures, moisture, grease etc..

For plasma CNC machine we recommend using Mk3 controller for its Ethernet support. Ethernet protocol is more robust than USB and therefore more suitable for industrious environments.

Plasma cutter is a great source of electromagnetic interference. So special care should be taken into account when wiring machine electronics.
Be sure to use shielded cables for motors, limit switches. External power supply for motion controller is very recommended. Plasma cutters itself sometimes do not satisfy standards of electromagnetic compatibility (EMC), so make sure that your plasma cutter is within EMC regulations.

Special approach should be considered when designing toolpath program for plasma CNC machines. The reason for this is when plasma ignites and arc pierces trough material, this leaves a mark on material. So your work-piece could be well off from specified dimensions. For this purpose toolpath should include lead in and lead out moves. User should also pay attention to ignition delays, pierce heights etc..
You can use special CAM software intended exclusively for plasma cutting. SheetCAM software offers wide range of plasma toolpath options and it is very user friendly. PlanetCNC post processor is available.

Heat emitted from plasma could deform workpiece material, usually metal sheet, in such case plasma cutter would not cut at constant height which could result as a faulty workpiece or could damage plasma cutter in the process. This is usually solved with THC device. THC stands for Torch Height Control.

THC device measures arc voltage. Bigger the distance between the plasma torch and material higher the voltage and vice versa. So based on the voltage value we can maintain constant height of plasma torch above the material. THC device sends control signals to motion controller which then dynamically compensates Z axis and thus maintains constant cutting height.

Parameters related to THC are located in: File/Settings/Control/THC

Select Machine axis that would perform THC compensation moves. Usually this is Z axis

Dec Pin:
Select decrease input pin of controller. Pin is located at Input header. This pin will receive compensation signal for axis movement in negative direction.
Inc Pin:
Select increase input pin of controller. Pin is located at Input header. This pin will receive compensation signal for axis movement in positive direction.
OK Pin:
Select OK Arc input pin of controllers. Pin is located at Input header.
Range Min:
Minimal height compensation value oppose to relative Z0.
Range Max:
Maximal height compensation value oppose to relative Z0.
Speed is step/cycle time. This should be set by testing, try finding value that suits your machine. Recommended values are from 1-10.


PlanetCNC TNG software uses dedicated g-code to enable and disable THC device. G-code M54 P1 enables THC, M54 P0 disables it.

M3 (turn plasma on)
G04 P.2 (delay for 0.2 seconds)
M54 P1 (turn THC on)
G01 X10 Y10
M54 P0 (turn THC off)
M5 (turn plasma off)

Spindle synchronisation with PlanetCNC TNG

CNC lathe thread cutting requires spindle RPM’s to be synchronised with machines linear movement, we call this spindle synchronisation.

To achieve this, controller needs to read feedback signal from machines spindle to obtain information at which RPM spindle rotates.

For this purpose we can use incremental (with quadrature A and B signals ) encoder or some sort of sensor that would read spindle RPM’s.

If we would use only sensor, we could use optical or magnetic sensor.

But since encoders already use index signal, choosing encoder would satisfy all our needs.

Encoder should rotate at same rotational speed as spindle. Normally it is mounted directly on spindle shaft or connected to spindle shaft via pullyes and timing belt. In such case make sure that transmission rate is at 1:1.

Encoder uses two quadrature signals, A and B and  Index signal. For our purposes 100PPR(parts per revolution) encoder would do just fine.

Encoder is connected to controller via its CTRL header:


Encoder wiring  for Mk3 controller:

Signal A from encoder is connected to EN4A  pin and signal B from encoder to EN4B pin of CTRL header.

Index signal from encoder is connected to IDX pin of CTRL header.


Encoder wiring for Mk3/4:

Signal A from encoder is connected to ENC A  pin and signal B from encoder to ENC B pin of CTRL screw type terminal.

Index signal from encoder is connected to IDX pin of CTRL screw type terminal.

PlanetCNC TNG encoder settings:

Encoder settings are located in: File/Settings/Input/Output/Spindle -> Encoder

PPR: PPR value of your encoder.

Index PPR: Number of index signals per one revolution of encoder.
Invert: Inverts Index signal.

Debounce: Debounce time period for index signal.


Video of thread cutting using lathe CNC machine and PlanetCNC TNG software and motion controller:

Guidelines when submitting your problem to PlanetCNC support

Some users face an obstacle during their time learning and using PlanetCNC software.
While we always try to give fast and effective support, sometimes we need more info about the problem user is facing in order to come up with solution as fast as possible.

So when you post e-mail or ticket regarding your problem we ask you to provide the following:

1. Clear and in-depth description of your problem.
Please use English language if possible. Please understand that you know your machine and we don’t.

2. Attach files:
.settings(File/Export Settings)
.gcode (.dxf, .gerber)
.Scripts folder (zipped)
.var(located in your installation folder)
log text (Menu Help/Show Log then copy/paste)
.tbl(located in your installation folder)
.keys(located in your installation folder)
.state(State 1-5)
.btn(.btnbottom, .btnleft, .btnright, .btntop)

3. Past experience has shown that video recordings can be very helpful.
Sometimes things do not go smoothly and error occurs during machine operation. In such case it is best to post two video files:

a.) Video of your machine during operation. Video should show machine operation and the exact moment when it comes to an error.
b.) Video of complete PlanetCNC sw user interface during the machine operation mentioned in point a.

This way we can compare both videos and see if anything unusual is happening in software and how software behaviour reflects on machine performance.
It is necessary that for this you use program and settings files that you sent us.

4. If any error message is displayed in PlanetCNC sw please make screenshot of it and post it.

These of course do not apply to each possible scenario, but you should be able to recognise what is applicable in your case.

Custom button examples for TOP toolbar

PlanetCNC TNG software offers option of creating and adding custom buttons to software toolbars.

Buttons can be added to top, bottom, left sided and right sided toolbars.

Custom buttons can execute any feature from File, View, Program, Machine and Help menu.

For this tutorial we will create and add buttons to top toolbar of PlanetCNC TNG software for features: Settings (File/Settings) and Log dialogue (Help/Log)


Step 1.:

Create new text file and name it: PlanetCNC64.btntop

File should be located in PlanetCNC TNG install root folder.

Modifying this file, you create custom buttons located at top toolbar.

Please note: “PlanetCNC64” is name of settings used, if your settings are named differently then this file should have different name.


Step 2.:

Open file PlanetCNC64.btntop with your text editor.

Step 2.1.:

To create button for “Settings” insert this line:

File.Settings_… SET

Open File menu and locate Settings feature:

If you look closely at the text of inserted line you can see that it is actually path to location of this feature, with difference that level is replaced with “.” and spaces are replaced with “_”.

To name the newly created custom button, you add desired text at the end of the line(SET). Make sure that one space is added  before you type the name of the button.


Step 2.2.:

To create button for “Show Log” insert this line:

Help.Show_Log_… LOG

Open Help menu and locate Show Log feature:

If you look closely at the text of inserted line you can see that it is actually path to location of this feature, with difference that symbol level is replaced with “.” and spaces are replaced with “_”.

To name the newly created custom button, you add desired text at the end of the line(LOG). Make sure that one space is added  before you type the name of the button.

Buttons will appear on top tool bar after you restart PlanetCNC TNG software:


To create a divider line between the buttons you just add three hyphen ( – – – ) between the text lines:

File.Settings_… SET
– – –
Help.Show_Log_… LOG


To add buttons on left, right, top and bottom toolbars create these files and use same procedure as above:

PlanetCNC64.btnbottom: With this file you create custom buttons located at bottom toolbar

PlanetCNC64.btnleft: With this file you create custom buttons located at left sided toolbar

PlanetCNC64.btnright: With this file you create custom buttons located at right sided toolbar

Attached are files for custom buttons for top and left toolbars:
Custom button examples for TOP toolbar
Custom button examples for LEFT toolbar

Using “Warp” with PlanetCNC TNG software

Since PCB milling is a very delicate and precise procedure (distance between two pads can be only few mils), already smallest PCB surface height irregularities can create bad results.

So it is very important that depth of milling is constant over the whole PCB surface throughout the whole milling process. We can achieve this by using “Warp” procedure.

‘Warp’ feature helps apply generated toolpath over bended, curved or uneven surfaces.

The most important step of ‘Warp’ procedure obtaining surface points. We can  either capture each point single-handedly  or we can use “Measure Surface” procedure. We recommend the latter.

Step 1:
Place your workpiece material (in future text ‘copper board’) to machines table. Mount it properly, so that you avoid any inconveniences later such as vibration, dislocation etc…also make sure that copper board is not in contact with the machine table.

Step 2:

Since copper board itself is conductive material,  it can already be used as sensor. You can solder wire to it or you could just use mounting screw to attach connection wire to copper board.

Now connect wire from your copper board to controllers ‘sensor’ input.

Other wire should be connected to controllers GND terminal. Other end of this wire can be clamped to engraving tool:

While Mk3/4 controller has a designated sensor input, Mk3 controller uses assignable inputs, so you can connect copper board wire at any input of Input header and configure it in settings later.


Step 3:

Now open IO tab and check if correct input is activated under “Input” panel. This is just to be sure that everything is working correctly. Image below shows that Input 1 is activated.

Step 4:

Jog your machine to desired initial origin point of your copper board, usually its corner, and click: “Machine/Work Position/Axis to Zero/XY” or click “Work Position Axis to Zero XY” button from toolbar.

With work position XY set to zero, you have initial point of your workpiece material from which you will start your ‘Warp’ measuring as also your g-code program.

Step 5:

To measure Z axis zero work position, click: “Machine/Work Position/Measure”  or click “Work Position Measure” button from toolbar.


Step 6:

Now that we set zero XY and Z axis work positions, we can start with surface point measuring.

Click “Machine/Measure/Measure Surface”:

“Measure surface” user dialogue will appear:

Position X: X axis initial point of surface measuring.

Position Y: Y axis initial point of  surface measuring.

Size X: X axis dimension of measuring area surface.

Size Y: Y axis dimension of measuring area surface.

Step: Distance between to neighbourly measuring points 



Step 7:

After you click OK, machine will begin measuring surface points of copper board.


Step 8:

When surface measuring procedure is finished,  measured points are saved in PlanetCNC TNG main installation folder as “MeasureSurface.txt” file.

Step 9:

Now open your Gerber file using “File/Import Gerber”:


Step 10:

Set Z axis work position to zero, click: “Machine/Work Position/Measure”  or click “Work Position Measure” button from toolbar.

Step 11:

To apply “Warp” click: “Program/Warp” and click “Load…” button. Locate file “MeasureSurface.txt” and click Open.

Table will be populated with coordinates of measured points:

Click OK.


Step 12:

You will notice that the displayed toolpath has changed in order to compensate for boards curved surface. This is much more evident if you set parameter “Alpha” in settings(File/Settings/User Interface/Colors/Alpha).

These are all steps required to apply Warp with your program. Machine will mill at constant depth no matter of the surface curvature.




“Measure surface” script file is available for edit.

You can open and edit script file if you click: “File/Settings/Program Options/Scripts/Measure” and select “Measure/Measure Surface” from drop down menu. Click: “Edit Script” and script file will open in your default text editor.

Alternatively you can open surface measure script file “Machine.Measure.Measure_Surface.gcode” located in “PlanetCNC64.Scripts” folder with your text editor.


How to create “Spindle Delay” script file in PlanetCNC TNG software

With PlanetCNC TNG software user can create or customise g-code procedures (e.g. for M3/M5 g-codes, M6 g-code) using script files.

Script files are located in PlanetCNC TNG installation folder in scripts folder.

If your settings file is named e.g.”MyCNCRouter.settings”, then your corresponding scripts folder should be named MyCNCRouter.scripts. This way you can link multiple script files to corresponding setting files.

This tutorial will describe how create script file for short delay after spindle is turned ON.


To create and modify M3 g-code script please follow steps below:

1. Open PlanetCNC TNG software installation folder. Locate scripts folder and open it.

2. Create new text file and name it: Machine.UserDefined_M3.gcode

3. Open script file with text editor.

4. Add M3 and G04 g-codes.

Scipt file includes g-code lines:

G04 P5


Now after each time we turn spindle ON, software waits 5 seconds before it continues with program execution.


You can read more on M3 and G04 g-codes here:

How to control PlanetCNC TNG from your own software

Command line arguments

PlanetCNC TNG accepts commands from command line. Only one software instance can run at same time. When you run second instance it will simply pass its arguments to running instance. Running instance will process these arguments and execute command.

Here are some examples (Windows, 64bit):

1. Open command prompt.
2. Go to PlanetCNC TNG installation folder. Usually “C:Program Files (x86)PlanetCNC”.
3. Type PlanetCNC64.exe. Software will start.
4. Type PlanetCNC64.exe gcode “G01 X10G01 Y10”. You will notice that two g-code lines are now loaded.
5. Type PlanetCNC64.exe start. Machine will start and g-code will be executed.

Named pipes

More advanced option is to use named pipes. Named pipes is simple cross-platform interprocess communication mechanism. It is possible to use named pipes in almost all programming languages.

PlanetCNC TNG must be running otherwise it will not receive command. If you do not want to show main window you can start software with “hide” command.

Here is source code of an example (Windows, C++):


List of supported commands

Both options described above use same commands. Here is a list and brief explanation.

show Shows main window
hide Hides main window
exit Exits program
estop Toggles EStop
start Performs Start
stop Performs Stop
pause Performs Pause
isestop Returns 1 if EStop is active, 0 otherwise
ispause Returns 1 if Pause is active, 0 otherwise
open "filename" Opens GCode from file
gcode "program" Opens GCode from string
close Closes opened GCode
mdi "command" Executes MDI command
param name=value Sets parameter value
param name Returns parameter value
posabs Returns absolute position for all axes
posabsx Returns absolute position for X axis
posabsy Returns absolute position for Y axis
posabsz Returns absolute position for Z axis
posabsa Returns absolute position for A axis
posabsb Returns absolute position for B axis
posabsc Returns absolute position for C axis
posabsu Returns absolute position for U axis
posabsv Returns absolute position for V axis
posabsw Returns absolute position for W axis
pos Returns position for all axes
posx Returns position for X axis
posy Returns position for Y axis
posz Returns position for Z axis
posa Returns position for A axis
posb Returns position for B axis
posc Returns position for C axis
posu Returns position for U axis
posv Returns position for V axis
posw Returns position for W axis
speed Returns current speed
accel Returns current acceleration
spindle Returns current spindle RPM
input Returns value of INPUT 
input1 Returns value of INPUT 1 pin
input2 Returns value of INPUT 2 pin
input3 Returns value of INPUT 3 pin
input4 Returns value of INPUT 4 pin
input5 Returns value of INPUT 5 pin
input6 Returns value of INPUT 6 pin
input7 Returns value of INPUT 7 pin
input8 Returns value of INPUT 8 pin
jog Returns value of JOG
jog1 Returns value of JOG 1 pin
jog2 Returns value of JOG 2 pin
jog3 Returns value of JOG 3 pin
jog4 Returns value of JOG 4 pin
jog5 Returns value of JOG 5 pin
jog6 Returns value of JOG 6 pin
jog7 Returns value of JOG 7 pin
jog8 Returns value of JOG 8 pin
joga1 Returns value of JOG A1 pin
joga2 Returns value of JOG A2 pin
jogs Returns value of JOG S pin
jogpot Returns value of JOG POT
limit Returns value of LIMIT
limit1 Returns value of LIMIT 1 pin
limit2 Returns value of LIMIT 2 pin
limit3 Returns value of LIMIT 3 pin
limit4 Returns value of LIMIT 4 pin
limit5 Returns value of LIMIT 5 pin
limit6 Returns value of LIMIT 6 pin
limit7 Returns value of LIMIT 7 pin
limit8 Returns value of LIMIT 8 pin
limit9 Returns value of LIMIT 9 pin
output Returns value of OUTPUT
output1 Returns value of OUTPUT 1 pin
output2 Returns value of OUTPUT 2 pin
output3 Returns value of OUTPUT 3 pin
output4 Returns value of OUTPUT 4 pin
output5 Returns value of OUTPUT 5 pin
output6 Returns value of OUTPUT 6 pin
output7 Returns value of OUTPUT 7 pin
output8 Returns value of OUTPUT 8 pin
aux1 Returns value of AUX 1 pin
aux2 Returns value of AUX 2 pin
aux3 Returns value of AUX 3 pin
aux4 Returns value of AUX 4 pin
buffer Returns amount of free buffer 
bufferpercent Returns percent of buffer utilization
linecount Returns number of lines in GCode program
line Returns line number currently executing


Starting program from g-code

You can also start your own program from gcode. Optionally you can wait for program to finish before g-code continues or you can pass parameters.

Start myprogram.exe:

Start myprogram.exe and send current X and Y coordinates:
(exec,myprogram.exe #<_x> #<_y>) 

Start myprogram.exe, send current X and Y coordinates and wait for program to finish:
(execwait,myprogram.exe #<_x> #<_y>) 

Make sure that myprogram.exe is added to whitelist in settings otherwise TNG will refuse to execute it.

Hint: This external program can use named pipes to set some g-code parameters. TNG will use these parameters when g-code execution will continue.

How to create custom tabs in PlanetCNC TNG software

With PlanetCNC TNG user can create his own custom tabs.

Tabs are displayed on main user interface and can include any parameter used by software whether its tool offset value, number of g-code line or absolute position of machine. By default, software will display tabs “Speed” and “IO”.

User can create maximum of  5 state files, meaning, you can display up to 5 custom tabs. File with extension .state1 creates first tab file, .state2 creates second tab file all the way up to .state5 file.

To create new custom tab go to your PlanetCNC TNG installation folder and create new text file and change its name to PlanetCNC64 or PlanetCNC32 and its extension to “state1“: PlanetCNC64.state1 or PlanetCNC32.state1

It is worth mentioning that the text before .state must be the same as name of your settings file. So, if your settings file is named: MyCNCRouter.settings, then your corresponding .state file should be named MyCNCRouter.state1. This way you can link multiple state files to corresponding setting files.

Now open this file and copy/paste bottom example text for an easy start:

If we look parameter “_abs_x 3” you can see that at the end we add number 3. Since this parameter is X axis absolute position value, this number means number of decimal places.

If parameter uses Boolean logic you add instead of number a letter B.

Now that we created  state file and we configured it, “My new tab” tab should appear after we restart PlanetCNC TNG software:

If we click “My new tab” tab we can see the parameters displayed:

Parameter 1 displays X axis absolute position
Parameter 2 displays Total run time of g-code file
Parameter 3 displays SPU value of X axis

We can change names of parameters to make them more understandable:

Now parameter names are much easier to understand:

You can download state file with all parameters here: All parameter .state file

Using the G04 g-code with PlanetCNC TNG software

In machining it is sometimes necessary to stop the motion of all axes for a given amount of time (for example to let the spindle come up to speed or wait for the coolant to start flowing). This is called dwell. It’s activated with the G04 command. The time is specified using a P-word and a number seconds (the number is a float so fractions of a second can be used).
For example: G04 P3.7

A common place to use the G04 dwell command is when starting a spindle of a machine. Because it can’t accelerate instantly to the desired speed we need to allow it some time to speed up before starting to cut the material. An example of code that waits 5 seconds after starting the spindle at 10000 RPM is here:
M03 S10000
G04 P5

Using G02 and G03 g-codes with PlanetCNC TNG software

Another two g-codes used to specify machine movements are G02 and G03. They move the machine in an arc, in contrast to G00 and G01 which move the machine in a straight line.

G02 moves the machine in a clockwise arc and G03 moves the machine in a counterclockwise arc.
To use these codes we need to specify the coordinates to which the machine will travel, the offsets to the center of the arc or the arc radius and optionally the number of additional turns the machine will make while performing the move. The speed of these movements is also defined by the F-word (feed rate).

For example: Starting from X0 Y0 Z0, we would like to round a 90 degree corner using a counterclockwise arc to X50 Y50 Z0. To do this we will use the command G03 X50 Y50. But this command isn’t complete yet and the program would signal an error if we tried to use it like that. We still need to specify the center of the arc. This is done by specifying offsets from the starting position or with the deprecated method of specifying the radius.

The offsets are simply the distance from the starting position to the center of the arc. The offsets are separated into components for each axis. The center also needs to be equidistant from both the starting and the destination point. Otherwise the arc won’t be part of a circle and the controller will signal an error accordingly.

As we said, the offsets are the distance the machine would need to move along each axis separately to get to the center. In our case (starting from the origin) this would be 50 units along the Y axis. This also means that the radius of the circle will be 50 units (the radius equals the distance from the center to the origin or destination). Now we need to specify the offsets to the machine. To do this we use I, J and K-words for the X, Y and Z axes accordingly. When we put all this together we get the final code that looks like this: G03 X50 Y50 J50.


Controlling the Spindle and Coolant with PlanetCNC TNG Software

A fundamental operation in CNC machining is controlling the spindle. It is controlled in g-code using M3, M4 and M5 commands.
M03 will start the spindle turning clockwise.
M04 will start the spindle turning counterclockwise.
Both commands turn on the spindle at the speed determined separately by the S-word. It is used to set the RPM at which the spindle will turn when turned on.
M05 will stop the spindle regardless of direction.

Other than controlling the spindle, the M03 command can also turn on a plasma cutter, laser, water jet or even a hot wire for cutting polystyrene foam. Their power is likewise set using the S-word.

When machining some materials, most often metals, it is sometimes required to use coolant. It can be supplied to the tool and on the work in different ways. There are three commands for coolant control.
M07 will turn on the mist coolant supply.
M08 will turn on the flood coolant supply.
M09 will turn both coolant supplies off.

As with M03, these commands can be used to control something else, as they just turn an output on the CNC USB controller on or off. For example one of the codes could be used to control the dust collection vacuum for a woodworking machine.

The M07, M08 and M03 commands can also be activated manually using the buttons from top toolbar:
CoolantFlood CoolantMist SpindleM3


Currently active M-codes will also show up in the machine state display.


How to measure work position with movable sensor in PlanetCNC TNG software

1. Reference your machine using Homing procedure(Machine/Home):
How to set Homing procedure in PlanetCNC TNG software

2. Connect movable sensor (further in text referenced as sensor) to one of the inputs (Input connector) of controller.



3. In settings select either Sensor 1 or Sensor 2 (File/Settings/Program Options/Measure/Sensor). It doesn’t matter which one you choose. From drop down menu select input to which you connected your sensor.


4. Activate sensor by hand and under IO tab of main display check if designated input gets properly triggered.


For safety reasons jog your machine (it can be in any direction) and see if machine stops when you activate sensor.

5. In settings set:

Probe speed(File/Settings/Program Options/Probe speed): This is the speed at which Z axis will descend to measure Z axis work position.

Sensor Thickness(File/Settings/Program Options/Measure/Movable Sensor/Thickness): If you use copper board as a movable sensor, then value of this parameter is the thickness of the copper board( usually 1.6mm).


 6. Start “Work Position Measure” procedure(Machine/Work Position/Measure). You can also use the “Work Position Measure” button on the left toolbar:


7. When “Work Position Measure” procedure is executed, default sequence will be:

Machine will at current machine position descend towards sensor at probe speed(File/Settings/Program Options/Probe Speed). When sensor is activated, machine will stop and ascend to Z height from which we started “Work Position Measure” procedure.

Z axis work position value on surface of material should now be 0.

You have configured “Work Position Measure” procedure and you should be able to use it with your movable sensor.

If you would like to edit “Work Position Measure” procedure to fit your needs or to have more in depth look at the procedure itself, you can do that by opening the “Work Position Measure” procedure script file.



8. You can create and access “Work Position Measure” script file  in two ways:

a.) In settings (File/Settings/Program Options/Scripts/Work position) you can click buttons Generate and Edit. With Generate button you create default file and with Edit button you can open it and make any modifications of the script g-code



b.) When you start “Work Position Measure” procedure for the first time(for example via button), Machine.Work_Position.Measure.gcode default file will be created. Open your PlanetCNC TNG software installation folder and locate folder: “.Scripts”

Find “Machine.Work_Position.Measure.gcode” file and open it with text editor:


9. Description of parameters and g-codes(in order of appearance in script g-code):

This g-code saves states of of all modal g-codes currently used by software. When Machine.Work_Position.Measure.gcode procedure is executed in its entirety, all states will be restored to their previous values.

#3 = #<_abs_z>: Stores value of current Z axis position as parameter #3.

With G90 g-code we set absolute mode of motion.


Speed at which machine descends to measure tool. Set with Probe Speed in settings(File/Settings/Program Options/Probe Speed). This value can be set directly with new F value. In such case you should delete the “#<_speed_probe>” line of code.

G38.2 Z-100000:
This g-code moves selected axis in selected direction. G38.2 g-code uses parameter X(-/+)Value,Y(-/+)Value or Z(-/+)Value which define to which coordinate value machine should move and in what direction. When probe activation occurs over the time of machine travel, machine will stop.

G92 Z#<_sensor_thick>:

When movable sensor is activated, we set current work position as thickness of sensor. Here comes in great help g-code G92.

G53 G0 Z#3:

Machine moves in absolute coordinates to previously saved Z axis position.