Installing PlanetCNC TNG software on Raspberry Pi 3

You will need:
– Raspberry Pi 3 Model B (or B+)
– Monitor with HDMI cable
– Mouse and Keyboard
– Power supply
– 8GB SD card (16GB and 32GB should also work, 64GB or more will not work)

We used NOOBS version 2.8.2 in this tutorial but it should also work with newer versions.

1. Download NOOBS from here:


You will get almost 2GB large file named “NOOBS_v2_8_2.zip”

2. You need to format SD card. We suggest that you use “SD Memory Card Formatter 5.0” which you can get here:
https://www.sdcard.org/

– Download “SD Memory Card Formatter 5.0”.
– Follow the instructions to install the software.
– Insert your SD card into the computer or laptop’s SD card reader and make a note of the drive letter allocated to it, e.g.
– In SD Memory Card Formatter, select the drive letter for your SD card and format it.

3. Extract files from NOOBS zip file to SD card.

Your SD card contents should look like this:

4. When this process has finished, safely remove the SD card and insert it into your Raspberry Pi. Connect monitor, mouse and keyborad and power up Raspberry Pi.
After few moments selection dialog will appear.

Select “Raspbian (full desktop version)” and click install. Confirm overwriting SD card and wait for Raspbian to be installed. It might take a while.

Another tutorial for Raspbian installation using NOOBS is here:
https://projects.raspberrypi.org/en/projects/noobs-install

5. When installation is finished you will get nice welcome screen and Raspbian will ask you to set country, time zone and password.
You do not have to set password if you do not want it.

If connected to internet it will download and install updates. If not then skip this step.

When finished it will ask to reboot.

After reboot you are ready to install PlanetCNC TNG.

6. First we will modify “config.txt” file.
– Open terminal.

– Type “sudo nano /boot/config.txt”

– GNU nano will apear. Scroll to bottom of file and type:
gpu_mem=128
dtoverlay=vc4-kms-v3d

– If you have black border on your monitor then locate line “disable_overscan=1” and uncomment it.

– When done exit GNU nano by clicking Ctrl+X and confirm saving modified buffer.

7. Reboot Raspberry Pi

7. After reboot we will install PlanetCNC TNG. Create subdirectory “PlanetCNC” in your HOME directory.

8. Download or copy ‘PlanetCNCPi-TNG_(version).tar.gz’ tarball to subdirectory.

9. Extract ‘PlanetCNCPi-TNG_(version).tar.gz’ tarball with “tar -xvf PlanetCNCPi-TNG_*.tar.gz”

10. Run installation script with “sh install.sh”

If you set password then you will be asked to enter it. After instalation completes PlanetNCC TNG will start automaticaly.

11. You can close all windows. There should be PlanetCNC icon on desktop. Double click will start PlanetCNC TNG.

How to set speed and acceleration values in PlanetCNC TNG software

One of the most important steps when setting up your machine in PlanetCNC TNG software is configuring machines max speed and acceleration values.

With speed and acceleration values that are not suitable for one’s machine, user risks lost steps(stepper motor) or increased torque(servo motor), damaged work-pieces, broken machine and most important, lost time.

To obtain machines max speed and acceleration values, user should put his machine trough various tests. This way user will learn motion capabilities and limitations of his CNC machine.

With machine max values correctly set, user can be rest assured that his machine will perform safely within its limitations, achieving best results.

Speed and acceleration settings

As same as we cannot achieve blistering accelerations and record high speeds with a family car, we also cannot expect miracles with small desktop CNC machine.

While the main limitation of a car is usually its engine and chassis, CNC machine’s rigidness and motion capabilities base on its axis motor drives, mechanics and frame.

Machine motion consists of single motor motion(single axis movements) and combined motor motion (combined axis movements – e.g. circular motion).

User would need to obtain max speed and acceleration values for both types of working conditions, single motor motion as also combined motor motion.

Single motor speed and acceleration settings are set under:

File/Settings/Motors/Speed  & Acceleration:

Combined motor speed and acceleration settings are set under:

File/Settings/Motion → Set Maximum Speed and Max Acceleration and Deceleration:

For standard 3 axis linear CNC machines, speed and acceleration values under Motors/Speed & Acceleration and Motion/ Speed & Acceleration are are usually the same.

Machine tests

Motion tests will help with approximation of suitable max speed and acceleration values of your machine. Like mentioned earlier, you would need to perform tests for both, single as also combined motor motion of X,Y and Z axes.

Z axis motion is little more specific than XY axis motion, since Z axis usually carries spindle motor which represents constant load on the Z axis motor. With motion such as hole array drilling and PCB hole drilling we can test Z axis motion capabilities.

It is recommended that some of these tests are performed also while machine is actually cutting/machining.

When machine cuts trough material, motors need to maintain speeds and accelerations while also dealing with resistance from material. Tests performed under these conditions can affect final max speed and acceleration values.

Single axis speed and acceleration test

For this test you will move each axis independently in both directions. Start with default setting values, which are Speed = 2500 [mm/min] and Acceleration = 25[mm/s2].

You can start with X axis, then Y axis and as last Z axis.

To move each axis you can use jogging keys or you can write short g-code program which would move each axis in desired distances and directions.

Trough out the test, configure Speed and Acceleration setting values depending on the given results of each test. If results indicate that axis could handle higher values, increase them, and if motor looses steps, lower these values. Please note that any unusual noises, vibrations, machine frame movements also indicate unsuited speed and acceleration values.

Hint: While acceleration values can be configured only via settings, you can set different speeds for testing by using JOG speed window. Double click on the value and insert new one.

Note that max jog speed is limited with max motor and motion speed values from settings.

Speed and Acceleration values that will be obtained with this test should be used for all further tests.

Combined axis speed and acceleration tests

Machine will use combined axis motion to perform these tests.

Rounded Square test

For this test you will use “Round Square” user defined feature. This UD feature generates toolpath program for square with round corners. Machine will perform round corners using combined axis motion, which is perfect for our test.

This test can be compared to a car cornering on a race track. If car gets thrown out of the track when passing trough corner, then it is safe to say that car speed was too high. If your machine will loose steps or motors will stall when traveling trough round corners, then set speed was too high.

Under Machine/User Defined, locate Rounded Square option and start it:

Displayed dialog offers you to insert values for Size, Radius, Speed and Loop:

Size: Size of square sides. This value should be high enough so that machine can achieve max speed over each square side.

Radius: Equation offers you to calculate minimum radius that your machine will still be able to travel without lowering its speed, thus obtaining constant speed trough out the whole toolpath. Values for speed and acceleration (v and a) are those that we obtained with single axis test.

Speed: Max speed, speed value obtained with single axis speed and acceleration test.

Loop: Number of times machine will execute this square toolpath. Multiple executions of this toolpath program back to back can help with better observation of machine motion.

Click OK to start execution of square program and under speed dial observe if machine speed will change at any point:

If your machine performs this square toolpath with constant speed and without any problems, this indicates that your single axis max speed and acceleration values are suitable for your machine.

Mickey test

In PlanetCNC install folder locate Samples folder and open Mickey.nc file.

This g-code program uses motion which makes for a great test of combined axis motion.

Since this program does not use F-word command it would be best to set it under File/Settings/Program Options → Feed Speed (Use max speed value obtained with single axis speed and acceleration test.)

NC drill test

Hole array drilling and PCB drilling are great examples of Z axis motion where you can test your Z axis capabilities. Like mentioned earlier, Z axis motor needs to maintain position while also carrying spindle motors weight. With rapid and continuous Z axis motion, inertia can cause for Z axis motor to loose steps.

For this test, your machine should perform NC drill program file where machine drills lots of holes. Perform this test at max speed and acceleration values obtained with single axis speed and acceleration test.

In PlanetCNC install folder locate Samples folder and open Mk1.ncd file.

For Feed Speed and Plunge Speed set max speed value obtained with single axis speed and acceleration test.

If lost steps or any other motion error occurs during these tests, you would need to lower max axis motor speed and acceleration values and repeat single axis speed and acceleration tests again. Then use new max values with combined axis speed and acceleration tests.

How to setup CNC machine in PlanetCNC TNG software

Follow these tutorials to setup your CNC machine:

1.) How to set step per unit values in PlanetCNC TNG software

2.)How to configure limit switch inputs of controller in PlanetCNC TNG software

3.)How to set motor limits in PlanetCNC TNG software

4.)How to set motion limits in PlanetCNC TNG software

5.)How to set homing procedure in PlanetCNC TNG software

6.)How to measure tool offset with fixed tool sensor in PlanetCNC TNG software

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

8.) How to set speed and acceleration values in PlanetCNC TNG software

Certificate Import

License activation depends heavily on digital signatures.

Validity of digital signatures depends on trust. On some computers trusted root certificates are missing, specially on older PC’s or when auto-updates are turned off.

If you are facing problems because of this, it is essential that you install trusted root certificates.

Please download this .zip file and extract it: Certificate files
Archive includes 4 files which are certificates that you would need to install on your computer.

Please perform steps below for each of 4 certificates:

1. Double click on the certificate and click “Install Certificate”:

2. Select “Current User” and click “Next” button:

3. Select “Place all certificates in the following store” option and click “Browse”:

Make sure that “Trusted root certification Authorities” folder is selected and click “OK”:

4. Click “Finish” to import certificate:

System should confirm that importation was successful:

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

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.

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

This tutorial will explain how to correctly use Work Position / Measure  feature with movable sensor using PlanetCNC TNG software and PlanetCNC motion controllers.

 

Movable Sensor

Movable sensor is basically a switch that sends signal to motion controller corresponding input pin.

The most basic type of movable sensor is usually copper-clad laminate. Clad has soldered wire that is connected to controller sensor input, while GND signal is attached to tool via e.g. crocodile clip.

When tool touches sensors surface, controllers corresponding input is activated and software sets Work Position value to zero.

Example of movable sensor used with Mk3 controller:

Mk3resize

 

 

Connecting movable sensor with PlanetCNC motion controller

MK3 controller:

 

 

Mk3/4 controller:

 

MK3DRV controller:

 

MK3ECO controller:

 

 

Configuring movable sensor in  PlanetCNC TNG software

In PlanetCNC TNG under File/Settings/Program Options/Measure configure input pin that you intend to use for movable sensor.

You can select between either Sensor 1 or Sensor 2 option. It doesn’t matter which one you choose.

 

Input pin is selected from drop down menu:

 

Size Z: If you use copper board as a movable sensor, then value of this parameter is the thickness of the copper board( usually 1.6mm).

 

Now that your sensor is connected and configured, it is best to activate sensor by hand to check if everything is functioning OK. Jog your machine (it can be in any direction) and see if machine stops when you activate sensor.

Under IO tab of main display check if input is activated correctly:

 

The last parameter that needs to be  configured is Probe Speed. This is the speed at which Z axis will descend to measure Z axis work position.

Please note: Make sure that Probe speed is not set too high. You see, during measuring procedure, when tool touches the surface (sensor gets activated) machine stops immediately. If your probe speed is too high, inertia on Z axis will cause loss of steps of Z axis stepper motor.

 

 

 

Measuring work position with  PlanetCNC TNG software

Work position measure procedure can be executed via menu item Machine/Work Position/Measure or  using left toolbar button:

Button

 

Default sequence of Work Position Measure procedure:

-Machine will start descending at current position in -Z direction using 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(zero).

 

 

Measure work position script file

Work Position Measure procedure uses script file. If you would like to edit script code or to have more in-depth look at the procedure itself, you can do that by opening script file.

You can generate, access and edit script file  in two ways:

a.) In settings under File/Settings/Program Options/Scripts/Work position -> Work Position Measure click button Edit Script.  Script file will open in your default text editor.

 

b.) When you execute Work Position Measure procedure for the first time, either via toolbar button or via Machine menu,  _Work_Position.Measure.gcode default file will be created. Locate your PlanetCNC TNG software installation folder and locate script file under Profiles/Default/Scripts -> _Work_Position.Measure.gcode

 

Default script code:

O<PlanetCNC> if[[#<_sensor1_pin> GT 0] OR [#<_sensor2_pin> GT 0]]
M70 (store state)
G90 (absolute mode)
G15 (cancel polar mode)
#<z> = #<_machine_z> (store current z position)
F#<_speed_probe> (set probe speed)
G38.2 Z-100000 (touch down)
G92 Z#<_sensor_sizeZ> (set Z)
G53 G0 Z#<z> (move back to stored position)
M72 (restore state)
O<PlanetCNC> else
(msgdlg,Sensor is not configured)
O<PlanetCNC> endif

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

M73:
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 = #<_machine_z>: Stores value of current Z axis position as parameter #3.

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

F#<_speed_probe>:
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:
G38.2 g-code uses parameters X(-/+)value, Y(-/+)value or Z(-/+)value which define which axis should move to which position and in what direction. When probe is activated over the time of machine travel, machine will stop.

G92 Z#<_sensor_sizeZ>: Sets current work position (where probe was activated) to thickness of sensor value.

<_sensor_sizeZ> parameter is set with Site Z  in settings (File/Settings/Program Options/Measure/Movable Sensor -> size Z).

G53 G0 Z#3:

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

 

 

 

 

 

How to measure tool offset with fixed tool sensor in PlanetCNC TNG software

This tutorial will explain how to correctly use Tool Offset / Measure  feature with fixed tool sensor using PlanetCNC TNG software and PlanetCNC motion controllers.

 

Fixed tool sensor

For fixed tool sensor we can use a dedicated tool measuring switch or, most basic solution, a standard micro switch fixed to machine table.

When tool activates tool sensor, controllers corresponding input is activated and software sets new tool offset value.

Example of fixed tool sensor used with Mk3 controller:

 

Connecting movable sensor with PlanetCNC motion controller

MK3 controller:

InputWiringMk3

 

Mk3/4 controller:
InputWiringMk34

 

MK3DRV controller:

 

MK3ECO controller:

 

Configuring fixed tool sensor in  PlanetCNC TNG software

In PlanetCNC TNG under File/Settings/Program Options/Measure configure input pin that you intend to use for fixed tool sensor.

You can select between either Sensor 1 or Sensor 2 option. It doesn’t matter which one you choose.

 

Sensor input pin is selected from drop down menu:

Now that your sensor is connected and configured, it is best to activate sensor by hand to check if everything is functioning OK. Jog your machine (it can be in any direction) and see if machine stops when you activate sensor.

Under IO tab of main display check if input is activated correctly:

 

Now move  machine to position where fixed sensor is mounted. Make sure that tool is right above the center of fixed tool sensor or in case that you use micro switch, above the lever.

 

Write down Machine coordinates of  X and Y axis. These values will be used for configuration of sensors X and Y axis position:

 

Jog Z axis towards the sensor. When sensor is activated, write down Machine coordinate of  Z axis.

We would like to emphasise that it is very important what kind of tool is used when obtaining Z axis position value, because all future tool measurements will be dependent on this value. That is why we call this tool also a default tool.
Default tool should not be too long or too short. It should be some normal length.

Signs that your default tool was not suitable are usually Z axis plunging into machine table or Z axis activating limit switch after tool offset measurement.

This value will be used for configuration of sensor Z axis position:

 

Under File/Settings/Program Options/Measure/Fixed Sensor/Sensor Position, insert values that you previously wrote down.

 

 

Measuring tool offset with  PlanetCNC TNG software

Tool offset measure procedure can be executed via menu item Machine/Tool Offset/Measure or  with left toolbar button:

ToolbarButton

Default sequence of Tool Offset Measure procedure:

-Machine will ascend to safe height and move from current position to sensors XY position(the one we set in settings).

-Machine will descend towards sensor with probe speed and when sensor gets activated, machine will stop and ascend to safe height.

-Software will set new tool offset value

-Machine will return back to XYZ position

 

Measure tool offset script file

Work Position Measure procedure uses script file. If you would like to edit script code or have more in-depth look at the procedure itself, you can do that by opening script file.

You can generate, access and edit script file  in two ways:

a.) In settings under File/Settings/Program Options/Scripts/Tool Offset -> Tool Offset Measure click button Edit Script.  Script file will open in your default text editor.

 

b.) When you execute tool Offset Measure procedure for the first time, either via toolbar button or via Machine menu, _Tool_Offset.Measure.gcode default file will be created. Locate your PlanetCNC TNG software installation folder and locate script file under Profiles/Default/Scripts ->_Tool_Offset.Measure.gcode

 

Default script code:

O<PlanetCNC> if[[#<_sensor1_pin> GT 0] OR [#<_sensor2_pin> GT 0]]
M70 (store state)
#<xpos> = #<_x> (store current x position)
#<ypos> = #<_y> (store current y position)
#<zpos> = #<_z> (store current z position)
G90 (absolute mode)
G53 G0 Z#<_motorlimit_zp> (move to safe height)
G53 G0 X#<_sensor_x> Y#<_sensor_y> (move to tool sensor position)
F#<_speed_probe> (set probe speed)
G38.2 Z-100000 (touch down)
G43.1 Z[#<_probe_z> - #<_sensor_z>] (set tool offset)
G53 G0 Z#<_motorlimit_zp> (move to safe height)
G0 X#<xpos> Y#<ypos> (move to last xy position)
#<zposm> = [ToMachine[#<zpos>, 2]] (calculate new machine position of last z)
o<100> if[[#<zposm> LT #<_motorlimit_zp>] AND [#<zposm> GT #<_motorlimit_zm>]]
G0 Z#<zpos> (move to last z position)
o<100> endif
M72 (restore state)
O<PlanetCNC> else
(msgdlg,Sensor is not configured)
O<PlanetCNC> endif

 

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

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

#<xpos> = #<_x> (store current x position): Stores value of current X axis position as parameter #1.
#<ypos> = #<_y> (store current y position):
Stores value of current Y axis position as parameter #2.
#<zpos> = #<_z> (store current z position):
Stores value of current Z axis position as parameter #3.

G90:
With G90 g-code we set absolute mode of motion. Prior to “Measure Tool” procedure , motion mode could be different so we used M73 to save current modal states.

G53 G0 Z#<_motorlimit_zp>: Machine ascends to safe height.

G53 G0 X#<_sensor_x> Y#<_sensor_y>: Machine moves to sensor XY position.

F#<_speed_probe>: 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.

G43.1 Z[#<_probe_z> – #<_sensor_z>]: When G38.2 g-code senses that sensor is activated and stops the machine, this g-code sets tool offset.

G53 G0 Z#<_motorlimit_zp>: Machine moves in absolute coordinates to safe height.

G0 X#<xpos> Y#<ypos> (move to last xy position): Rapid move to position from which we started the “Measure Tool” procedure .

#<zposm> = [ToAbs[#<zpos>, 2]]: calculate new absolute position of last z

o<100> if[[#<zposm> LT #<_motorlimit_zp>] AND [#<zposm> GT #<_motorlimit_zm>]]
G0 Z#<zpos> (move to last z position)
o<100> endif

With this subroutine program we make sure that even with new tool offset value, we are safely within Z axis machine limits when machine moves back to position from which we started the “Measure Tool” procedure .

How to configure limit switch inputs of controller in PlanetCNC TNG software

Limit switches are used for reference (homing procedure) and as a safety feature.

In order that software recognizes limit switch activation and makes appropriate action, we need to configure limit switch inputs in settings: File/Settings/Motors/Limit Switches

Examples below will demonstrate various scenarios of limit switch input configuration depending on how limits switches are used with CNC machine. Examples will demonstrate use of limits for X axis, all shown principles can be used for all other axes.

 

Limit switch input configuration

 

CNC machine uses only one limit switch for X axis (for positive direction), switch is connected to limit input 1:

 

CNC machine uses two limit switches for X axis ( for  positive and  negative direction), both switches are connected to limit input 1:

 

CNC machine uses two limit switches for X axis ( for  positive and  negative direction), each switch is connected to separate limit input, 1 and 2:

 

Limit switch test:

Test if PlanetCNC TNG software recognizes limit switch activation. On main screen click “IO” tab and observe controllers Limit behavior:

 

Invert option:
If you use normally closed type of limit switches then you can invert controller limit input in settings: File/Settings/Input/Output -> Limit

Click radio button next to limit pin that you wish to invert.

 

How to set homing procedure in PlanetCNC TNG software

This tutorial will explain how to correctly use Machine/Home  feature.

Homing procedure will reference machine axes and set machine work area.

First you need to configure step per unit values, motor & motion limits and limit switch inputs of controller:

How to set step per unit values in PlanetCNC TNG software

How to configure limit switch inputs of controller in PlanetCNC TNG software

How to set motor limits in PlanetCNC TNG software

How to set motion limits in PlanetCNC TNG software

 

Homing procedure configuration

Homing procedure is configured in settings: File/Settings/Program Options/Home

Order:

To set homing order of specified axis, select order number from drop down menu:

Direction:

To set homing direction of specified axis, click radio button of axis direction option, – or +:

Position:

Position value is axis position to which axis returns after homing.

To set home position for each axis insert desired value for specified axis:

Switch hysteresis:

Perhaps you noticed that when switch is triggered you need to move back short distance to release it. Some switches need longer distance, some very small, but all switches need this.

Values are usually around 2-5mm.

 Home Speed:

Make sure that homing speed it not too high to the point where limit switch or machine gets damaged. Homing speed is set in File/Settings/Program Options -> Home Speed

 

 

Homing sequence:

You can execute homing procedure via Machine menu Machine/Home or left toolbar button: 

When Homing is executed, homing sequence(as set above – see screenshots) will be:

Z axis will be referenced first. Axis will move in positive direction until Z axis limit switch is activated. When switch is activated machine stops and moves to position set with Z “Position”(Z=20mm) .

X axis will be referenced second. Axis will move in positive direction until X axis limit switch is activated. When switch is activated machine stops and moves to position set with X “Position”(X=0mm).

Y axis will be referenced third. Axis will move in positive direction until Y axis limit switch is activated. When switch is activated machine stops and moves to position set with Y “Position”(Y=0mm).

 

Home script file

Homing procedure uses script file. If you would like to edit script code or to have more in-depth look at the procedure itself, you can do that by opening script file.

You can generate, access and edit script file  in two ways:

a.) In settings under File/Settings/Program Options/Scripts/Home & Measure -> Home, click button Edit Script.  Script file will open in your default text editor.

b.) When you execute Homing procedure for the first time, either via toolbar button or via Machine menu,  _Home.gcode default file will be created. Locate your PlanetCNC TNG software installation folder and locate script file under Profiles/Default/Scripts -> _Home.gcode

 

Default script code:

M70 (store state)
G90 (absolute mode)
G94 (units per minute mode)
F#<_speed_home> (set home speed)

#<axis>=1
o<loop> while [#<axis> LE 9]

 o<ordx> if [#<_home_order_x> EQ #<axis>]
 o<dirx> if [#<_home_dir_x> GT +0.5]
 o<checkpin> if [#<_limit_xp_pin> EQ 0]
 (msgdlg,Limit switch X+ is not configured)
 M2
 o<checkpin> endif
 G38.1 X+10 (home X axis)
 G10 L9 X[#<_motorlimit_xp> + #<_homeswitch_hysteresis>] (set absolute X)
 G53 G0 X[#<_home_pos_x>] (move to home)
 o<dirx> elseif [#<_home_dir_x> LT -0.5]
 o<checkpin> if [#<_limit_xm_pin> EQ 0]
 (msgdlg,Limit switch X- is not configured)
 M2
 o<checkpin> endif
 G38.1 X-10 (home X axis)
 G10 L9 X[#<_motorlimit_xm> - #<_homeswitch_hysteresis>] (set absolute X)
 G53 G0 X[#<_home_pos_x>] (move to home)
 o<dirx> endif
 o<ordx> endif

 o<ordy> if [#<_home_order_y> EQ #<axis>]
 o<diry> if [#<_home_dir_y> GT +0.5]
 o<checkpin> if [#<_limit_yp_pin> EQ 0]
 (msgdlg,Limit switch Y+ is not configured)
 M2
 o<checkpin> endif
 G38.1 Y+10 (home Y axis)
 G10 L9 Y[#<_motorlimit_yp> + #<_homeswitch_hysteresis>] (set absolute Y)
 G53 G0 Y[#<_home_pos_y>] (move to home)
 o<diry> elseif [#<_home_dir_y> LT -0.5]
 o<checkpin> if [#<_limit_ym_pin> EQ 0]
 (msgdlg,Limit switch Y- is not configured)
 M2
 o<checkpin> endif
 G38.1 Y-10 (home Y axis)
 G10 L9 Y[#<_motorlimit_ym> - #<_homeswitch_hysteresis>] (set absolute Y)
 G53 G0 Y[#<_home_pos_y>] (move to home)
 o<diry> endif
 o<ordy> endif

 o<ordz> if [#<_home_order_z> EQ #<axis>]
 o<dirz> if [#<_home_dir_z> GT +0.5]
 o<checkpin> if [#<_limit_zp_pin> EQ 0]
 (msgdlg,Limit switch Z+ is not configured)
 M2
 o<checkpin> endif
 G38.1 Z+10 (home Z axis)
 G10 L9 Z[#<_motorlimit_zp> + #<_homeswitch_hysteresis>] (set absolute Z)
 G53 G0 Z[#<_home_pos_z>] (move to home)
 o<dirz> elseif [#<_home_dir_z> LT -0.5]
 o<checkpin> if [#<_limit_zm_pin> EQ 0]
 (msgdlg,Limit switch Z- is not configured)
 M2
 o<checkpin> endif
 G38.1 Z-10 (home Z axis)
 G10 L9 Z[#<_motorlimit_zm> - #<_homeswitch_hysteresis>] (set absolute Z)
 G53 G0 Z[#<_home_pos_z>] (move to home)
 o<dirz> endif
 o<ordz> endif

 o<orda> if [#<_home_order_a> EQ #<axis>]
 o<dira> if [#<_home_dir_a> GT +0.5]
 o<checkpin> if [#<_limit_ap_pin> EQ 0]
 (msgdlg,Limit switch A+ is not configured)
 M2
 o<checkpin> endif
 G38.1 A+10 (home A axis)
 G10 L9 A[#<_motorlimit_ap> + #<_homeswitch_hysteresis>] (set absolute A)
 G53 G0 A[#<_home_pos_a>] (move to home)
 o<dira> elseif [#<_home_dir_a> LT -0.5]
 o<checkpin> if [#<_limit_am_pin> EQ 0]
 (msgdlg,Limit switch A- is not configured)
 M2
 o<checkpin> endif
 G38.1 A-10 (home A axis)
 G10 L9 A[#<_motorlimit_am> - #<_homeswitch_hysteresis>] (set absolute A)
 G53 G0 A[#<_home_pos_a>] (move to home)
 o<dira> endif
 o<orda> endif

 o<ordb> if [#<_home_order_b> EQ #<axis>]
 o<dirb> if [#<_home_dir_b> GT +0.5]
 o<checkpin> if [#<_limit_bp_pin> EQ 0]
 (msgdlg,Limit switch B+ is not configured)
 M2
 o<checkpin> endif
 G38.1 B+10 (home B axis)
 G10 L9 B[#<_motorlimit_bp> + #<_homeswitch_hysteresis>] (set absolute B)
 G53 G0 B[#<_home_pos_b>] (move to home)
 o<dirb> elseif [#<_home_dir_b> LT -0.5]
 o<checkpin> if [#<_limit_bm_pin> EQ 0]
 (msgdlg,Limit switch B- is not configured)
 M2
 o<checkpin> endif
 G38.1 B-10 (home B axis)
 G10 L9 B[#<_motorlimit_bm> - #<_homeswitch_hysteresis>] (set absolute B)
 G53 G0 B[#<_home_pos_b>] (move to home)
 o<dirb> endif
 o<ordb> endif

 o<ordc> if [#<_home_order_c> EQ #<axis>]
 o<dirc> if [#<_home_dir_c> GT +0.5]
 o<checkpin> if [#<_limit_cp_pin> EQ 0]
 (msgdlg,Limit switch C+ is not configured)
 M2
 o<checkpin> endif
 G38.1 C+10 (home C axis)
 G10 L9 C[#<_motorlimit_cp> + #<_homeswitch_hysteresis>] (set absolute C)
 G53 G0 C[#<_home_pos_c>] (move to home)
 o<dirc> elseif [#<_home_dir_c> LT -0.5]
 o<checkpin> if [#<_limit_cm_pin> EQ 0]
 (msgdlg,Limit switch C- is not configured)
 M2
 o<checkpin> endif
 G38.1 C-10 (home C axis)
 G10 L9 C[#<_motorlimit_cm> - #<_homeswitch_hysteresis>] (set absolute C)
 G53 G0 C[#<_home_pos_c>] (move to home)
 o<dirc> endif
 o<ordc> endif

 o<ordu> if [#<_home_order_u> EQ #<axis>]
 o<diru> if [#<_home_dir_u> GT +0.5]
 o<checkpin> if [#<_limit_up_pin> EQ 0]
 (msgdlg,Limit switch U+ is not configured)
 M2
 o<checkpin> endif
 G38.1 U+10 (home U axis)
 G10 L9 U[#<_motorlimit_up> + #<_homeswitch_hysteresis>] (set absolute U)
 G53 G0 U[#<_home_pos_u>] (move to home)
 o<diru> elseif [#<_home_dir_u> LT -0.5]
 o<checkpin> if [#<_limit_um_pin> EQ 0]
 (msgdlg,Limit switch U- is not configured)
 M2
 o<checkpin> endif
 G38.1 U-10 (home U axis)
 G10 L9 U[#<_motorlimit_um> - #<_homeswitch_hysteresis>] (set absolute U)
 G53 G0 U[#<_home_pos_u>] (move to home)
 o<diru> endif
 o<ordu> endif

 o<ordv> if [#<_home_order_v> EQ #<axis>]
 o<dirv> if [#<_home_dir_v> GT +0.5]
 o<checkpin> if [#<_limit_vp_pin> EQ 0]
 (msgdlg,Limit switch V+ is not configured)
 M2
 o<checkpin> endif
 G38.1 V+10 (home V axis)
 G10 L9 V[#<_motorlimit_vp> + #<_homeswitch_hysteresis>] (set absolute V)
 G53 G0 V[#<_home_pos_v>] (move to home)
 o<dirv> elseif [#<_home_dir_v> LT -0.5]
 o<checkpin> if [#<_limit_vm_pin> EQ 0]
 (msgdlg,Limit switch V- is not configured)
 M2
 o<checkpin> endif
 G38.1 V-10 (home V axis)
 G10 L9 V[#<_motorlimit_vm> - #<_homeswitch_hysteresis>] (set absolute V)
 G53 G0 V[#<_home_pos_v>] (move to home)
 o<dirv> endif
 o<ordv> endif

 o<ordw> if [#<_home_order_w> EQ #<axis>]
 o<dirw> if [#<_home_dir_w> GT +0.5]
 o<checkpin> if [#<_limit_wp_pin> EQ 0]
 (msgdlg,Limit switch W+ is not configured)
 M2
 o<checkpin> endif
 G38.1 W+10 (home W axis)
 G10 L9 W[#<_motorlimit_wp> + #<_homeswitch_hysteresis>] (set absolute W)
 G53 G0 W[#<_home_pos_w>] (move to home)
 o<dirw> elseif [#<_home_dir_w> LT -0.5]
 o<checkpin> if [#<_limit_wm_pin> EQ 0]
 (msgdlg,Limit switch W- is not configured)
 M2
 o<checkpin> endif
 G38.1 W-10 (home W axis)
 G10 L9 W[#<_motorlimit_wm> - #<_homeswitch_hysteresis>] (set absolute W)
 G53 G0 W[#<_home_pos_w>] (move to home)
 o<dirw> endif
 o<ordw> endif

 #<axis> = [#<axis> + 1]
o<loop> endwhile
M72 (restore state)
M2

Description of important script parameters and g-codes:

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

G90:
With G90 g-code we set absolute mode of motion. Prior to measure tool procedure, motion mode could be different so we used M73 to save current modal states.

F#<_speed_home>:

Speed at which machine will home each axis. Set with Home Speed in settings(File/Settings/Program Options/Home Speed). This value can be set directly with new F value. In such case you should delete the “#<_speed_home>” line of code.

 

G38.1 X+10:
This g-code moves selected axis in selected direction and senses the limit switch activation.
G38.1 g-code uses parameter X(-/+)Value,Y(-/+)Value or Z(-/+)Value which define which axis will move in which direction when measuring limit switches.
When limit swith activation occures over the time of machine travel, machine will stop.

G10 L9 X[#<_motorlimit_xm> + #<_homeswitch_hysteresis>]:
When G38.1 g-code senses and stops the machine, this g-code sets current absolute position for selected axis .
Example:
G10 L9 X[#<_motorlimit_xp> + #<_homeswitch_hysteresis>]: Absolute position value of X axis will now be added value of X+ motor limit value  and  X+ switch hysteresis value.

G53 G0 X[#<_home_x>]: Machine moves in absolute coordinates to x axis home postion.
Example: If new machine absolute position is the one saved with G10 L9 g-code(X+ motor limit  and  X+ switch hysteresis value), we move machine back to X axis home position.

 

How to set motion limits in PlanetCNC TNG software

This tutorial will explain how to set motion limits of your machine under File/Settings/Motion-> “Range”.

First you need to configure step per unit values, limit switch inputs of controller and motor limits:

How to set Steps Per Unit values in PlanetCNC TNG software

How to configure limit switch inputs of controller in PlanetCNC TNG software

How to set motor limits in PlanetCNC TNG software

 

If you use normal XYZ axis machine, then we recommend that you set your motion limits to same values as motor limits.

You are probably wondering what is the difference between motor limits and motion limits?
We try to think that motor limits are limiting actual motor movement while motion limits are limiting  effector (tool) movement.

Eleboration:
With use of combined motors and special mechanics you can achieve movement which doesn’t follow the same kinematic rules as linear motion CNC’s. Examples of such machines are H-bot, Delta or multi-axis machines. In such cases values for motor limits and motion limits would not be the same.

 

To set motion limits of your machine click: File/Settings/Motion-> “Range”

 

Limit- value sets limitation of effector (tool) movement in negative direction, Limit+ value sets limitation of effector (tool) movement in positive direction for specific axis:

 

 

If we want machine to stop when limits are reached we must enable them. To enable motion limits for specified axis enable round button for specified axis:

 

 

 

 

How to set motor limits in PlanetCNC TNG software

This tutorial will explain how to set motor limits of your machine under File/Settings/Motors-> “Limits”.

With motor limits we set limitation of motor movement and therefore machine travel.

First you need to configure step per unit values and limit switch inputs of controller:

How to set Steps Per Unit values in PlanetCNC TNG software

How to configure limit switch inputs of controller in PlanetCNC TNG software

 

 

Configuring motor limits

You can configure limit values for each axis motor.

Limit- value sets limitation of axis motor movement in negative direction

Limit+ value sets limitation of axis motor movement in positive direction

Step 1:

First we need to set all machine and tool offsets values to zero.

Work offset should be set to zero with command “Machine/Work Offset->To Zero”.

Tool offset should be set to zero with with command “Machine/Tool Offset -> To Zero”.

 

Step 2:

Now we need to choose where machine absolute zero position is. Usually machine works in relative coordinates and it is not really important where absolute zero is. What is important is that it is always at same position. I will put some tape to mark it so that you will see it better on image:

 

Tool is put in spindle and machine is jogged to this position. Use tool with normal length, not too short, not too long. Be careful not to crush tool into machine table when you descent Z axis. You can just loosely tighten tool in spindle and if accident happens nothing will be damaged.

This position should be machine absolute zero. Command for zeroing machine absolute position is in menu: “Machine/Absolute Position ->To Zero”.

After using “To Zero” feature you will notice that values under Machine and Motors tab in coordinate display will be zero for all axes:

 

Step 3:

Slowly jog Z axis up until Z+ limit switch is hit and machine stops. Step jog in opposite direction so that limit switch is released and write down Z+ axis machine position.

Slowly jog X axis in positive direction until X+ limit switch is hit and machine stops.  Step jog in opposite direction so that limit switch is released and write down X+ axis machine position.

Slowly jog X axis in negative direction until X- limit switch is hit and machine stops. Step jog in opposite direction so that limit switch is released and write down X- axis machine position.

Slowly jog Y axis in positive direction until Y+ limit switch is hit and machine stops.  Step jog in opposite direction so that limit switch is released and write down Y+ axis machine position.

Slowly jog Y axis in negative direction until Y- limit switch is hit and machine stops.  Step jog in opposite direction so that limit switch is released and write down Y- axis machine position.

Please note: When machine triggers limit switch during homing it stops in a moment. That is why we need to approach limit switch with slow speed.

The distance from where limit switch is activated and to the point where it gets released is called switch hysteresis. This parameter will be used when configuring homing procedure.

 

Step 4:

Now insert values that you previously written down(X+, X- ; Y+,Y-; Z+)  into Motor limit windows. If we want motors to stop when motor limits are reached, we must enable the radio button for desired axis:

 

 

 

 

How to set step per unit values in PlanetCNC TNG software

This tutorial will explain how to correctly configure step per unit values of your machine.

 

Step per unit value (in further text SPU) defines how many step pulses controller needs to generate in order that machine axis moves for distance of one unit. Units can be in millimeters or in inches.

SPU value depends on few factors: stepper motor, stepper drivers micro-step configuration, lead screw pitch:

Motor
Stepper motors usually have 200 or 400 full steps per one rotation of its shaft.
One rotation of shaft in degrees is 360°. For motors with 200 steps per revolution this means
one step is equal to 1.8°. For motors with 400 steps per revolution this means one step is equal to 0.9°.

In equation below, we will name this parameter M

Micro-Stepping
With micro-stepping we improve motors resolution, accuracy, smoother movements, we reduce
resonance problems etc. The real compromise is that as you increase the number of micro-steps per
full step the incremental torque per micro-step drops off drastically. Resolution increases but
accuracy will actually suffer.

With micro-step number we define, how many smaller steps is one full step divided into.
Most common values are ½ , ¼ , ⅛… but it is really up to you which micro-step value you will use.

In equation below, we will name this parameter S

Pitch
Usually CNC machines operate with the help of lead screws and nuts. They can be trapezoidal or
ball screw leads. The pitch of a screw thread is the distance between adjacent threads. When lead
screw is rotated for one revolution, this reflects as linear motion of axis. Distance traveled is equal
to lead screw’s pitch.

In equation below, we will name this parameter P

(Some CNC machines use rack and pinion instead. Distance traveled when pinion makes one
revolution can also be considered as pinion pitch. Similar is also true for toothed belt drive.)

 

 Configuring SPU values of your machine in PlanetCNC TNG software

StepsPerUnit tab can be found in settings under Motors section: File/Settings/Motors

 

We can calculate SPU values for our machine by starting from two different initial conditions:

If we know all variable values:
Calculating correct SPU value is easy: SPU value = (M*S)/P

If we don’t know all variable values:
We will have to do some measuring and provide ourselves with some numbers. Then we will be able to calculate correct SPU value.

We use metric units so our unit is millimeter. If you use imperial units (inches) then values are different.

1) In Settings/Axes/Setup we set our SPU value to some “normal” number, say 200 steps per unit.

 

2) Jog machine to a suitable location, and set: Machine/Work Position/Axis to Zero/XY offsetXY.

3) Now let’s say that we want to move X axis from our offset zero position to X=10 position and measure the actual distance for which machine will move. To measure the distance of machines travel, we can use ruler, caliper or measuring tape which we place under machines tool.

Tool should start at 0 of the ruler:
X0TNG

In MDI window write X10:
MDIx10

Machine should move from X=0 to X=10, therefore travel for 10mm, but when we execute MDI command we can see that machine travelled for 2.5mm instead of 10mm:
X3.5TNG

Meaning, our current SPU value moves machine axis for wrong distance.

4) We can ask ourselves a question:

If ‘Current SPU’ value moves X axis for ‘Measured distance’ value, what is the ‘Correct SPU’ value that will move X axis for ‘Entered distance’ value?

Equation looks like this:
Correct SPU value = ( Current SPU value * Entered distance value ) / Measured distance value

Current SPU = 200
Entered Distance = 10
Measured distance = 2.5

Correct SPU value= (200*10)/2,5 = 800 SPU

 

Insert correct value for SPU in Settings/Motors/StepsPerUnit:

 

Now enter X10 in MDI window and measure the new distance value:
X0TNG

Measured distance value is now correct. Our steps per unit are correctly set.
X10TNG

It is recommended to repeat this procedure several times and use largest possible travel. Using 10mm travel is good for first pass but if you use maximum possible distance machine can travel, you will obtain much better results.