Adding custom features in PlanetCNC TNG software

User can add custom features to PlanetCNC TNG software. Examples of such are 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.) In PlanetCNC TNG install folder locate folder named PlanetCNC64.Scripts or PlanetCNC32.Scripts.

2.) Create new file and name it: Machine.UserDefined_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 Machine.UserDefined_UD6.gcode with text editor.
Write following text:
(name,Spindle ON, 1)
M3

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

You can download custom features for circle center and outside angle measurement here: Custom feature measurement files

To correctly add them into PlanetCNC TNG software, please follow steps above.

Replacing Chinese JP-382C board with genuine PlanetCNC MK3DRV controller

1. Take your control box and remove all screws of the top cover:

Now remove top cover of control box:

2. Locate JP-382C board and disconnect connectors of cable sets for X, Y and Z axis motor outputs, power supply and E-Stop switch. They should not be hard to find:

3. Remove JP-382C board from enclosure by unscrewing two screws at the bottom side of control box and two screws at the back panel:

4. Throw JP-382C board into the trash bin:

5. Take MK3DRV controller and 3D printed pillars:

3D printed parts are available here: PlanetCNC Mk3DRV pillars and back panel

6. Attach and screw them to Mk3DRV controller:

7. At the back panel place controller into existing cutout hole and screw it:

Screw in also pillars at the bottom side of control box:

8. Take cable sets for x,y,z motors that we previously disconnected from JP-382C board:

And cut off the connectors:

Each motor cable set should have 4 wires, 2 wires of one colour and other 2 in different colour.
Each colour represents separate phase of stepper motor.

9. Connect motor cable wires for X,Y and Z axis to Mk3DRV motor output terminals MOTOR 1(X), MOTOR 2(Y) and MOTOR 3 (Z). Motor phase 1 wires (yellow wires) are connected to terminals 1A and 1B, motor phase 2(red wires) is connected to terminals 2A and 2B.

10. Locate power supply cable and cut off its connector.
Connect power supply cable wires to Mk3DRV power supply terminal 24V. Red wire should be connected to “+” terminal and black should be connected to “–“ terminal:

11. Locate E-Stop switch cable and cut off its connector.
Connect it to Mk3DRVs GND and eSTP terminals:

Now you can use your control box with PlanetCNC TNG software and your CNC machine.

PLEASE NOTE: MK3DRV can be used only with PlanetCNC TNG software version SW2017.10.30(or newer), if you will use older version for update such as SW 2017.10.20 beta you could bridge it.

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:

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.

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

 

 

PLEASE NOTE:

“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 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++):
PipeExample

 

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:
(exec,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 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.

InputWiringMk34

InputWiringMk3

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.

SensorIO

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:

Button

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

GenerateEdit

 

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:

ScriptG-code

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

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

 

 

 

 

 

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

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

2. Mount your fixed tool sensor(further in text referenced as sensor) on machine table.

3. Connect sensor to one of the inputs (Input connector) of controller.
InputWiringMk34

InputWiringMk3

4. In settings select either Sensor 1 or Sensor 2(File/Settings/Input/Sensors). It doesn’t matter which one you choose.

From drop down menu select input to which you connected your sensor.

SensorInput1

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

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

6. Jog your machine to sensor position, so that tool is right above the centre of fixed tool sensor.
For Sensor Position(File/Settings/Program Options/Sensor Position)insert X,Y motor values that can be seen under Motors tab of coordinate display.
Z value of sensor position is usually sensors height. Sensor Position(File/Settings/Program Options/Sensor Position).

7. Start Measure Tool procedure(Machine/Tool Offset/Measure Tool).
You can also use the “Tool Offset Measure Tool” button on the left toolbar:
ToolbarButton

8. When “Measure Tool” procedure is executed, default tool measure sequence will be:

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(File/Settings/Program Options/Probe Speed) and when sensor gets activated, machine will stop and ascend to safe height.
Machine will return back to XY position from which we started the “Measure Tool” procedure.

You have configured your fixed tool sensor and you should be able to use “Measure Tool” procedure.

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

 

 

9. You can create and access “Measure Tool” procedure script file  in two ways:

a.) In settings (File/Settings/Program Options/Scripts/Tool Offset) 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

GenerateEdit

b.) When you start “Measure Tool” procedure for the first time, Machine.Tool_Offset.Measure_Tool.gcode default file will be created. Open your PlanetCNC TNG software installation folder and locate folder: “.Scripts”

Find “Machine.Tool_Offset.Measure_Tool.gcode” file and open it with text editor:

MeasureScript

 

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

#1 = # (store current x position): Stores value of current X axis position as parameter #1.
#2 = # (store current y position): Stores value of current Y axis position as parameter #2.
#3 = # (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#1 Y#2:
Rapid move to position from which we started the “Measure Tool” procedure .

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

With this sub program we make sure that we are safely within Z axis motors 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 to reference your machine(homing procedure) as also for safety reasons.

If you use only one limit switch for axis X motor (positive direction), connected to controllers limit input 1:

XAxis+

If you have two limit switches for axis X motor (negative and positive direction), connected to same limit input of controller:

XAxis+-

If you have two limit switches on X axis(negative and positive direction), connected to separate limit inputs of controller:

XAxisSeparatePin

Same principles that were shown above for X axis can be used for all other axes.

Limit switch test:

When your limit switches are connected to limit inputs of controller, you can test if PlanetCNC TNG software senses the limit switch activation. On main screen click the “IO” tab and observe controllers Limit status bar behaviour:

Limit1_IO

Limit1_IO_Active

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

LimitInvert

Click round button next to limit pin that you wish to invert:

LimitInvertEnabled

How to set Homing procedure in PlanetCNC TNG software

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

1. First you need to configure these settings:
Motor limits(File/Settings/Motors/Limits):
Set limitation of movement for each motor.
Motor limits tutorial can be found on this link: Motor Limits tutorial

Limit switch input configuration(File/Settings/Limit/Limit Switches):
Configure limit switch inputs of controller. Limit switch input configuration tutorial can be found on this link: Limit switch input configuration tutorial

Home speed(File/Settings/Program Options/Home Speed):
Set homing speed.

2. To execute homing procedure click: Machine/Home or click the “Home” button located on vertical toolbar: HomingButton

Homing procedure(File/Settings/Program Options/Homing) can be configured to fit your needs.

To set homing Order of axes you select order number from drop down menu for each axis:

HomingSettings

To set homing Direction of axes you click the round button of axis direction option:

HomingDirection

You can set home Position for each axis:

HomePosition

Switch hysteresis:
This is the distance from the moment when limit switch is activated to when limit switch is released. Usually around 2-5mm. Test this on your machine.

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

Z axis will homed 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”.

X axis will homed 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”.

Y axis will homed 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”.

These are all necessary steps to configure Homing procedure of your machine. 

To take more in-depth look at the code behind Homing procedure see next chapter.

 

3. When you click home button for the first time, Machine.Home.gcode file will be created. Open your PlanetCNC TNG software installation folder and locate folder: “.Scripts”

Find “Machine.Home.gcode” file and open it with text editor(bottom image describes homing g-code only for three axes):

Script_g-code

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+100000:
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 to which coordinate value machine should move and in what direction.
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 Z will now be added value of X+ motor limit  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.

Homing procedure can be configured to fit your needs. You can set homing speed, axes homing order, home position etc…

How to set Motion Limits in PlanetCNC TNG software

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

Motion Limits tab

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

MotionLimitsValues

With Motion limits values inserted, we set motion limits of machine. If we want machine to stop when limits are reached we must enable them.
To enable Motion limits for specified axis click the round button:

MotionLimitsValuesEnabled

When you set your machines motion limits you will notice that 3D representation of machine limits will be displayed accordingly on the main screen:

3DDisplayValues

If you use normal XYZ axis machine then we recommend that you set your motion limits at 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 and Motion limits are limiting machine or 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 printer or multiple axis machines. In such cases values for Motor limits and Motion limits would not be the same.

How to set Motor limits in PlanetCNC TNG software

To set your axis motor limits click: File/Settings/Motors -> “Motor Limits”.
MotorLimitsTab

Limit- value sets limitation of motor movement in negative direction, Limit+ value sets limitation of motor movement in positive direction:

MotorLimitsTabValues

With Motor limits values inserted, we set limits of motors. If we want motors to stop when limits are reached, we must enable them.
To enable Motor limits for specified axis click the round button:

MotorLimitsEnabled