Using ExtOut board with PlanetCNC TNG software

This tutorial will help you configure ExtOut board related settings in PlanetCNC TNG software.


ExtOut board settings are located under File/Settings/Input&Output/I2C,TX,Enc,RC.

Under Ext section insert value 10000 for Frequency and enable Invert option for SEL1 Pin:

Related g-codes:

M64 – Output ExtOut

Usage: M64 H Q <L>

– H = ExtOut SSEL value (1 or 2)
– Q = data send to ExtOut
– L (optional) = number of bytes send to ExtOut

M64 H Q E <L>

– H = ExtOut SSEL value (1 or 2)
– Q = parameter number of first data location
– E = data count
– L (optional) = number of bytes send to ExtOut

M64 H P Q <L>

– H = ExtOut SSEL value (1 or 2)
– P = bit position
– Q = zero for Off, otherwise On
– L (optional) = number of bytes send to ExtOut

M64 H L0

– H = ExtOut SSEL value (1 or 2)
– L = zero bytes send to ExtOut



In PlanetCNC TNG install folder locate and open Samples folder. Open Tutorials folder and locate files: M64ex1.txt, M64ex2.txt, M64ex3.txt, M64ex4.txt, M64ex5.txt, M64ex6.txt

These sample g-code programs describe various uses of M64 g-code and ExtOut board.


Using MPG pendant with PlanetCNC TNG software

This tutorial will help you configure MPG pendant related settings in PlanetCNC TNG software.

MPG settings are located under File/Settings/Control/Jogging -> Handwheel

Parameter description:

Enables use of encoder for purposes of jogging when using MPG pendant(used with Mk3 MPG adapter) or standalone encoder. For more info regarding controllers encoder inputs please read Mk3 and Mk3/4 controller user manual.
Note: These settings apply to encoder connected to controller header CTRL pins: EN1A and EN1B

Enter PPR value (parts per revolution) of your MPG encoder. Usually around 100PPR.

Reverses direction of jogging when MPG encoder is used for jogging.

Step Mode 0-6:

You can configure seven modes of jogging when using MPG pendant with PlanetCNC TNG. To select between modes you use MPG hardware switch(x1, x10, x100).

Each step mode can be configured either as Speed Factor or as Step Distance.
If radio button is left unchecked Speed Factor mode will be used, if you enable radio button , Step Distance mode will be used.

Speed Factor:
Encoder wheel will be translated into motion using Speed Factor value.
Inserted value is speed factor which can behave as prescaler or multiplication of MPG encoder wheel rotation.

For example, Speed Factor of value 0.1 is used when you need fine tuning of axis motion.


Step Distance:
Rotation of encoder will jog machine for distance that is set with Step Distance.

Please note:
With PlanetCNC MPG pendant hardware switch you can select only between Step Mode 1, Step Mode 2 and Step Mode 3.

So when you are using using PlanetCNC MPG pendant, configure only Step Modes 1,2 and 3.

Machine jogging with PlanetCNC TNG software

For purposes of machine jogging, user can use on screen jogging keys, PC keyboard keys or external jogging keyboard.


On-screen jogging keys:

Click the cross button next to jogging speed window:
Cloud with jogging keys will appear:
Jogging keys can appear permanently on main screen if you set:
File/Settings/User Interface/Jog Panel -> enable “Fixed”. You can choose among XY Cross, UV cross or default keys layout.:

Default keys layout:

XY Cross layout:

PC keyboard keys:

PC keyboard keys used for jogging  need to be configured in settings File/Settings/User Interface/Shortcuts -> under Jog chapter. Under Code, set keyboard keys you wish to use:


External jogging keyboard:

First under IO tab observe which jogging keyboard keys activate which JOG input.
Then in File/Settings/User Interface/Shortcuts -> under Jog and Pin set designated jog input pins:

Jog1 (X-),Jog2 (X+),Jog3 (Y-),Jog4 (Y+),Jog5 (Z-),Jog 6(Z-)
Since external jogging keyboard also supports Shift key, which in combination with any other jogging key initiates step Jog motion, you should set these shortcuts also:

How to use “Program Edit” feature in PlanetCNC TNG software

Sometimes our NC program does not perform quite as we plan. Many times just a small correction of g-code does the trick and for this we need to edit our NC program. 
For this purpose you can use built-in “Edit” feature. 

Edit feature is located under Program menu.


When Edit feature is active, window is opened with currently imported g-code:


You can directly edit your g-code within the “Edit” window:


With “Verify” button you verify edited g-code in case of any errors. If error is located, message is displayed with error description and number of program line that causes error:


With “Update” button edited g-code is loaded into g-code window.

How to create new profile in PlanetCNC TNG software

This tutorial will help you create new profile in PlanetCNC TNG software.

If you have multiple CNC machines (machines of different dimensions or different types) with its corresponding controllers, and you want to use them with only one computer, it is very useful to create separate profiles, each using pre-configured settings and scripts, each for specific machine.

Using profiles makes up for much more organised and transparent file management of PlanetCNC TNG files.

Each profile will have its designated files for:

  • Settings
  • Keys
  • Parameters
  • Toolbar buttons
  • Scripts
  • Tool table


Create new profile

Right-click with your mouse somewhere on desktop and select New -> Shortcut

Browse location of PlanetCNC TNG.exe file and click Next:

Name your shortcut, (for purposes of this tutorial we will name it MyCNC) and click Finish:

New shortcut for PlanetCNC TNG software will appear on desktop:


Right click on newly created shortcut and click Properties. Insert name of settings  into Target window after Target path.

Please note: Name of inserted settings should be the same as name of shortcut:

Click Apply and OK.

Start PlanetCNC TNG sw via newly created shortcut.

Access your PlanetCNC install folder and locate Profiles folder. Locate  your new profile folder(in this case it is MyCNC profile folder) and open it. You will notice that software generated new native files of new profile:


Now you can add different toolbar button, custom tab  and custom feature files to each separate profile:

Adding user toolbar buttons in PlanetCNC TNG software

How to create custom tabs in PlanetCNC TNG software

Adding custom features in PlanetCNC TNG software



Using LOG command with PlanetCNC TNG software

If you want to save your variable and parameter values or any other log data in a form of a file, you can use LOG command.

LOG: Writes to LOG file
LOGOPEN: Creates new LOG file.
LOGAPPEND: Adds content to previously created LOG file
LOGCLOSE: Closes LOG file


Example 1: G-code program will create LOG file where desired data will be saved.

(LOG,This text is saved in "DataLOG.txt" file)


Example 2: G-code program will create two separate LOG files where data will be saved.

(LOGOPEN,DataLOG 1.txt)
(LOG,This text is saved in "DataLOG 1.txt" file)

(LOGOPEN,DataLOG 2.txt)
(LOG,This text is saved in "DataLOG 2.txt" file)

(LOG,This text is also saved in "DataLOG 1.txt" file)

(LOG,This text is also saved in "DataLOG 2.txt" file)



Created LOG files are located in current folder. User can also explicitly tell where created LOG file will be located.





Adding custom features in PlanetCNC TNG software

User can add custom features to PlanetCNC TNG software. Examples of such are various frequently used machining programs, various measuring procedures or any other machine motion sequences that help user with workpiece or machine setup before starting machining process.

Custom feature programs are accessible trough Machine/User Defined menu:

In order that program appears as User Defined menu item, further steps need to be performed:

1.) Access your PlanetCNC  install folder and locate Profiles folder. Open desired profile folder and locate folder Scripts.

2.) In Scripts folder create new file and name it: UD6.gcode

Make sure that name of the file includes UDn text. n stands for order number of user defined file. Since there are already 5 pre-existing user defined files (UD1-UD5), our newly created file will have order number 6. File should be saved as .gcode file.

3.) We will write most basic custom feature g-code.
Open newly created file UD6.gcode with text editor.
Write following text:
(name,Spindle ON, 1)

This custom feature will load as g-code program in g-code window and it will turn spindle ON when you start it. It will be available under Machine/User Defined menu as Spindle ON.

If you change first line (name,Spindle ON, 1) to (name,Spindle ON, 0), notice the zero, then program will start instantly without prior loading g-code into g-code window.

4.) PlanetCNC TNG software click: Machine/User Defined -> Reload

Our Spindle ON program should be available after reloading:

User can also execute these custom features via custom buttons: Custom buttons in PlanetCNC TNG


To add any future user defined feature into PlanetCNC TNG software, please follow steps above.

Adding user toolbar buttons in PlanetCNC TNG software

User can add user buttons to software toolbars. These custom buttons can execute any feature from File, View, Program, Machine and Help menu. Buttons can execute also custom procedures. This will make any software feature even more accessible and easier to use. Buttons can be added to top, bottom, left and right sided toolbars.

Button files are located in Profiles folder. Button files are named: BtnTop.txt, BtnBottom.txt, BtnLeft.txt, BtnRight.txt

User buttons located at the top toolbar will use file: BtnTop.txt

User buttons located at the bottom toolbar will use file: BtnBottom.txt

User buttons located at the left toolbar will use file: BtnLeft.txt

User buttons located at the right toolbar will use file: BtnRight.txt



Add new user button to top toolbar:

This example will demonstrate how to add button to top toolbar which would execute feature from Program menu, in this case, Edit feature:

Open BtnTop.txt file with your text editor.

Code which creates button is actually path to menu location of this feature, with difference that level is replaced with “.” and spaces are replaced with “_”. To name a button, use one space before name text and put name text into quotes (“name”).

So, to add button to top toolbar which will execute Edit feature and will be named EDIT, write this code:

Program.Edit_... "EDIT"


Add new custom feature button to left toolbar:

This example will demonstrate how to add button to left toolbar which would execute custom feature from Machine/User Defined menu, in this case, Square feature:

Open BtnLeft.txt file with your text editor.

Code which creates button is actually path to menu location of this feature, with difference that level is replaced with “.” and spaces are replaced with “_”. Since we are creating button for custom feature we also need to write name of user defined file, in our case this is UD1.gcode(Square).  To name a button, use one space before name text and put name text into quotes (“name”).

So, to add button to left toolbar which will execute UD1.gcode(Square)  feature and will be named SQR, write this code:

Machine.UserDefined_UD1 "SQR"


Buttons will appear at the top and left toolbars after you restart PlanetCNC TNG software:



Adding button icon

This example will demonstrate how to add custom button icon for  newly created user button, in this case, for our Edit button.

Button icons use .PNG files that are located in Icons folder of specified profile folder. Icons folder already includes default .PNG files but you can add your own .PNG files.

For this example we will use PNG file “Icons/IMG_BTN_FileOpen.png” that is already included in Icons folder.


So for our Edit button, to use FileOpen.png icon with no button name, write this code:

Program.Edit_... "" "Icons/IMG_BTN_FileOpen.png"

After software restart, EDIT button now uses File Open icon:



To use FileOpen.png icon with button name, write this code:

Program.Edit_... "EDIT" "Icons/IMG_BTN_FileOpen.png"

After software restart, EDIT button now uses File Open icon and EDIT name:



Hiding default toolbar buttons

User can also hide default toolbar buttons from being displayed.

To hide default toolbar buttons click: File/Settings/User Interface/Toolbar Buttons -> Hide


Now only user toolbar buttons are displayed:


User can completely remove all toolbar buttons and use only those which are needed, either default buttons or user buttons.

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

This tutorial will describe how to create script file for short delay after Mist(M8)is turned ON.

With PlanetCNC TNG, user can create or customize g-code procedures (e.g. for M7,M8 g-codes, M6 g-code) using script files.

Script files are located in Scripts folder of corresponding profile in PlanetCNC TNG installation folder.


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

1. Start PlanetCNC TNG software and click File/Settings/Program Options/Scripts and find M-code option. From drop down menu select M8 and click Edit Script.

2. Blank M8 script file is created and opened in default text editor
3. Add M8 and G04 g-codes into blank file. Script file should include g-code lines:

G04 P5


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


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 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.

To create new custom tab, access your PlanetCNC  install folder and locate Profiles folder. Open your profile folder and create new .txt file and name it State3.txt.

Now locate State5.txt  file in your PlanetCNC install folder under Samples/Templates.

Open file and copy whole text.

Paste this text to your State3.txt file.  Save changes and close State3.txt. Also close PlanetCNC TNG software.

State3 tab file named “All” should be visible upon new launch of PlanetCNC TNG software. This tab will display all parameters and is meant as demonstration tab. We recommend that you use selected parameter names from State5.txt file and create tab that will display only parameters that you wish to display.





Using “Optional Pause” feature with PlanetCNC TNG software

PlanetCNC TNG software supports, next to the conventional M00 pause, also optional M01 pause.

While M00 command pauses program every time when it appears in program, M01 pauses program only when “Optional pause” option is enabled in machine menu: Machine/Options/Optional pause

You can enable/disable optional pause while program is running, so you would not need to restart the program in order to use optional pause feature.

You can insert M01 optional pause at different locations in your program.
So when you run your program for the first time, you can have these pause checkpoints in-between, where you can check up on machine or machining parameters, measure your work piece or tool wear, check fixture position etc..

Optional pause disabled:

Optional pause enabled:

You can download “Optional pause” example program here: Optional pause example