[[cha:plasmac-user-guide]]

= PlasmaC User Guide
:toc:
:toclevels: 5
:figure-caption!:

== License

PlasmaC and all its related software is released under GPLv2.

== Introduction

PlasmaC is a plasma cutting configuration for LinuxCNC v2.8 or later. It includes a HAL component plus GUI configurations for both <<cha:axis-gui, Axis>> and <<cha:gmoccapy,Gmoccapy>>. There is also an option to have the Axis GUI display in portrait mode, see <<axis-ini, Axis .ini file>>.

It should run on any hardware that is supported on LinuxCNC provided there are enough I/O pins for the configuration.

If you are new to plasma user, it may be worthwhile having a read through the link:plasma-cnc-primer.html[Plasma CNC Primer] document which is a generic introduction to CNC plasma cutting.

[[plasmac-mode]]

PlasmaC uses one of three different operating modes.

[width="100%",cols="4,16"]
|===
|*Mode*|*Description*
|0|Use external arc voltage in to calculate Arc Voltage and Arc OK
|1|Use external arc voltage in to calculate Arc Voltage +
   Use external arc ok in for Arc OK
|2|Use external arc ok in for Arc OK +
   Use external up/down for THC
|===

NOTE: If your plasma cutter has an Arc OK (Transfer) output then it is recommended to use that for Arc OK rather than the soft Arc OK of mode 0.

No Z axis motion is required in G-Code, in fact the standard PlasmaC configurations will comment out any Z commands during program load.

For reliable use of PlasmaC you should *NOT* use any Z axis offsets other than coordinate system offsets (G54 ~ G59.3).

Normally it is best to touch off your Z axis to the Z axis minimum limit during the initial configuration then leave it at that.

== I/O Requirements

This section only touches on the I/O required for PlasmaC itself, base machine requirements such as limit switches, home switches etc. are in addition to these.

[width="100%",cols="4,2,14"]
|===
|*Name*|*Modes*|*Description*
|Arc Voltage|0,1|Analog input to read the arc voltage +
                 Typically connected to a velocity output from an encoder
|Float Switch|0,1,2|Digital input. Optional, see below +
                    Connected to the switch on the floating head +
                    If not using an ohmic probe this is the primary probe sensor +
                    If using an ohmic probe this is the fallback probe sensor
|Ohmic Probe|0,1,2|Digital input. Optional, see below +
                   Connected to the probe output +
                   If used, this is the primary probe sensor
|Ohmic Probe Enable|0,1,2|Digital output. Optional, only required if using ohmic probing +
                          Connected to the probe enabling input +
                          This pin is used to arm the ohmic probe
|Breakaway Switch|0,1,2|Digital input. Optional, see below +
                        Connected to the torch breakaway switch +
                  Senses if the torch has broken away from its cradle
|Torch On|0,1,2|Digital output +
                Connected to the torch on input of the plasma power supply
|Move Up|2|Digital input +
           Connected to the up output of the external THC control
|Move Down|2|Digital input +
             Connected to the down output of the external THC control
|Scribe Arming|0,1,2|Digital output +
                     Connected to scribe arming circuit
|Scribe On|0,1,2|Digital output +
                     Connected to scribe on circuit
|===

Only one of either *Float Switch* or *Ohmic Probe* is required. If both are used then *Float Switch* will be a fallback if *Ohmic Probe* is not sensed.

If *Ohmic Probe* is used then *Ohmic Probe Enable* is required.

*Breakaway Switch* is not mandatory because *Float Switch* is treated the same as a breakaway when not probing. If they were two separate switches, they could be combined and connected as a *Float Switch*

NOTE: The minimum I/O requirement for a PlasmaC configuration is *Arc Voltage* input, *Float Switch* input and *Torch On* output. In this case, PlasmaC treats the float switch as a breakaway switch when it is not probing.

IMPORTANT: THESE PINS WILL BE ENTERED LATER INTO THE CONFIGURATOR, THEY SHOULD *NOT* BE USED IN YOUR BASE MACHINE .HAL FILE.

== Installing LinuxCNC

The preferred method of installing LinuxCNC with PlasmaC is by using an ISO image as described below.

The minimum requirement for PlasmaC is LinuxCNC v2.8.

NOTE: It is possible to install and run LinuxCNC on a variety of Linux distributions but this is beyond the scope of the Plasmac User Guide. If you wish to follow this path then you will need to install your preferred Linux distribution and then install LinuxCNC v2.8 or later along with any required dependencies, then you can open LinuxCNC and continue with <<sec:testing-linuxcnc, Testing LinuxCNC Installation>>

All PlasmaC development has been done on a Stretch ISO installation.

=== If You Do Not Have Linux Installed

LinuxCNC requires a realtime Linux kernel and there are currently two ISO images available from LinuxCNC downloads with different realtime options.

. PREEMPT_RT - The preferred option if using an external motion card. Good for parallel port if your machine has acceptable latency. Required if you intend to use a Mesa Electronics ethernet card.
. RTAI - Good for parallel port, normally provides better latency than PREEMPT_RT.

The downloadable ISO images are:

* PREEMPT_RT - http://www.linuxcnc.org/testing-stretch-rtpreempt/
* RTAI - http://www.linuxcnc.org/iso/linuxcnc-2.7.14-wheezy.iso

Download your chosen image and write it to a bootable device, then boot from that device and run it in Live mode to check the latency of the machine. The latency test is in the Main Menu under CNC. You really should have Max Jitter less than 50000, the lower the better. When you are happy with the performance, reboot and select install from the boot menu and continue to install the system.

This will give you a machine with the current stable branch (v2.7) of LinuxCNC which will be upgraded to 2.8 in the next section.


=== If You Have LinuxCNC v2.7

The method described here is called a Buildbot Installation as it uses prebuilt packages from the LinuxCNC Buildbot to install and update LinuxCNC.

NOTE: There is another method called Run In Place which requires the user to compile LinuxCNC locally. This method is normally used for development work and is beyond the scope of this manual.
For more information on a Run In Place installation, see link:../code/building-linuxcnc.html[Building LinuxCNC]

To use the buildbot packages on your computer, first add the buildbot archive signing key to your apt keychain by running this command from a terminal:

----
sudo apt-key adv --keyserver hkp://keys.gnupg.net --recv-key E0EE663E
----

If you get an error like GPG: keyserver receive failed: No dirmngr

Then enter the following in the terminal:

----
sudo apt-get install dirmngr
----

The missing dirmngr package will then be installed.

If you still get an error downloading the key it may be caused by being behind a firewall or a proxy server. In this case it may be worthwhile specifying port 80 rather than using the default of 11371:

----
sudo apt-key adv --keyserver hkp://keys.gnupg.net:80 --recv-key E0EE663E
----

Close the terminal, then from the Main Menu, open Synaptic Package Manager.

Select Search in the menu bar and do a search using *linuxcnc* as the search term. Right click on any linuxcnc results and then click Mark for Removal. When all installed results are selected click Apply on the menu bar and these will be removed.

Click Settings from the menu and select Repositories.

You can then either edit or delete existing LinuxCNC entries from the repositories list. You need to end up with the following set of stanzas as the only enabled references to LinuxCNC:

----
deb     http://buildbot.linuxcnc.org/ <distro> <branch>-<rt_type>
deb-src http://buildbot.linuxcnc.org/ <distro> <branch>-<rt_type>
----

Where:

* <distro> is stretch or wheezy
* <branch> is 2.8 or master
* <rt_type> is rtpreempt or rt

So if you installed the *stretch* version and wanted *2.8* branch on a *PREEMPT_RT* machine then you would have:

----
deb     http://buildbot.linuxcnc.org/ stretch 2.8-rtpreempt
deb-src http://buildbot.linuxcnc.org/ stretch 2.8-rtpreempt
----

When this is completed Synaptic should do a package reload, if not do a manual Reload from the menu bar.

Now do a Search with *linuxcnc* as the search term and the result should be a list of newly available LinuxCNC packages

Right click on the package you want to install and then select Mark for Installation.

For PREEMPT_RT you would select linuxcnc-uspace and for RTAI it would be linuxcnc.

You may also select the documentation if you want it installed locally and/or the -dev package if you intend to build new realtime components and/or alternate front-ends for linuxcnc.

When you have made all your selections, click Apply on the menu bar and the selected packages will be installed.

Go to <<sec:testing-linuxcnc, testing the linuxCNC installation>>

NOTE: For more information on the LinuxCN Buildbot, see the http://buildbot.linuxcnc.org/[LinuxCNC Buildbot home page]

[[sec:testing-linuxcnc]]

=== Testing LinuxCNC Installation

The LinuxCNC Configuration Selector should open.

Navigate to Sample Configurations > by_machine > plasmac.

Select either Axis or Gmoccapy.

Select either metric or imperial.

The selected PlasmaC simulation configuration will now open and may be tested at will.

You now have all the requirements to run PlasmaC, the next step is to create a working configuration for your machine.

=== Make A Working Base Machine Configuration

NOTE: Base machine configuration means a complete working system without any plasma connections. All axes should be working and tuned for best performance and all home and limit switches if installed should be operating correctly.

IMPORTANT: DO *NOT* ADD ANY PLASMA CONNECTIONS SUCH AS TORCH_ON OR ARC_OK ETC. HERE, THESE WILL BE ADDED LATER DURING THE PlasmaC CONFIGURATION.

* Floating Head - it is recommended that a floating head is used and it has enough movement to allow for overrun during probing. Overrun can be calculated using the following formula:

----
o = 0.5 × a × (v ÷ a)^2
----

where: o = overrun, a = acceleration in units/sec2 and v = velocity in units/sec

For a metric machine with a Z axis MAX_ACCELERATION of 600 mm/s^2^ and MAX_VELOCITY of 60 mm/s the overrun would be 3mm

For a imperial machine with a Z axis MAX_ACCELERATION of 24 in/s^2^ and MAX_VELOCITY of 2.4 in/s the overrun would be 0.12 in

It is also recommended that even if you intend to use ohmic probing as your primary probing system that you also have a switch on the floating head as a backup in case of ohmic probe failure due to dirty surfaces.
 
[[z_settings]]

Recommended settings for the Z axis are:

* Z MINIMUM_LIMIT should be just below top of the slats with allowances for float_switch_travel and tolerance. So if your float switch took 4mm (0.157") to activate then set your Z minimum 5mm (0.096) below the lowest slat.
* Z MAXIMUM_LIMIT should be the highest you want the Z axis to travel (it must not be lower than Z HOME_OFFSET)
* Z HOME should be just below the maximum limit

IMPORTANT: YOU SHOULD BE ABLE TO HOME YOUR MACHINE, TOUCH OFF, JOG TO SOFT LIMITS WITHOUT CRASHING AND RUN SOME TEST G-CODE WITHOUT ANY ERRORS.

When and ONLY WHEN this stage is successfully completed can you configure PlasmaC on top of your working machine.

You can create a base machine manually or you may use existing configuration helpers:

NOTE: It is best to keep the base machine config simple until you have it fully tested and tuned. If you are using Stepconf or Pncconf then deselect the VCP Panel, spindle, manual tool change and classic ladder options these can be manually added later if you have a need for them.

If using a Mesa Electronics board, use the <<cha:pncconf-wizard, pncconf wizard>>:

----
$ pncconf
----

If using a parallel port, use the <<cha:stepconf-wizard, stepconf wizard>>:

----
$ stepconf
----

If using a Pico Systems board: +
https://forum.linuxcnc.org/27-driver-boards/14977-pico-systems-faq[This LinuxCNC forum thread] may help.

If you have a dual motor gantry configuration you may need to hand edit your configuration to suit: +
https://forum.linuxcnc.org/49-basic-configuration/33079-how-to-2-or-more-motors-on-one-axis-gantry-linuxcnc-2-8-master?start=0[This LinuxCNC forum thread] may help.

CAUTION: DO *NOT* CONTINUE UNTIL THE BASE MACHINE IS CONFIGURED AND WORKING

== Add A PlasmaC Configuration To The Base Machine

You NEED to have a fully tested and working base machine configuration without any connections to plasma specific equipment before proceeding.

CAUTION: DO *NOT* PROCEED UNTIL THIS HAS BEEN DONE

NOTE: IF YOU ARE USING A *Mesa Electronics THCAD* CARD FOR ARC VOLTAGE MEASUREMENT, SEE <<mesa-thcad, Mesa THCAD>> BEFORE PROCEEDING

[[configurator]]

Installing a Plasmac configuration is done from the Configurator.

From a terminal:

----
$ python /usr/share/doc/linuxcnc/examples/sample-configs/by_machine/plasmac/configurator.py
----

=== Configure

The selection window is now visible:

image::images/plasmac_configurator_home_new.png[width=30%]

Select *New* from the selection window, this shows an info dialog, select *Continue* and the New Configuration window will display.

NOTE: There will be different fields visible depending on the mode you select.

image::images/plasmac_configurator_new.png[width=50%]

[[configurator-table]]

HAL connection examples in the following table show an example for both a parallel port config and a Mesa 7i96 config. Change these pin names to suit your configuration.

[width="100%",cols="4,10,6"]
|===
|*Field*|*Description*|*Examples*
|Machine Name|the new name for your machine. This will create a ~/linuxcnc/<name> directory and your .ini file will be <name>.ini|plasma_table
|Ini File|this is the .ini file you created for your base machine config|base.ini
|HAL File|this is the .hal file you created for your base machine config|base.hal
|Mode|select the mode you require +
      0 if using an arc voltage signal for Arc Voltage and Arc OK +
      1 if using external arc ok for Arc OK +
      2 if using up/down from an external THC|1
|Arc Voltage|Modes 0 And 1 only +
             the HAL pin you have connected your arc voltage signal to|encoder.0.velocity +
                                                                       hm2_7i96.0.encoder.00.velocity
|Torch On|the HAL pin you have connected your torch on to|parport.0.pin-16-out +
                                                          hm2_7i96.0.ssr.00.out-00
|Arc OK|Modes 1 and 2 only +
        the HAL pin you have connected your arc ok signal to|parport.0.pin-10-in-not +
                                                             hm2_7i96.0.gpio.008.in
|Ohmic Probe|only required if using ohmic probing +
             the HAL pin you have connected your ohmic probe to|parport.0.pin-11-in +
                                                                hm2_7i96.0.gpio.007.in
|Ohmic Probe Enable|only required if using ohmic probing +
                    the HAL pin you have connected your ohmic probe enable to|parport.1.pin-01-out +
                                                                              hm2_7i96.0.ssr.00.out-01
|Float Switch|only if using a float switch +
              the HAL pin you have connected your float switch to|parport.0.pin-12-in +
                                                                  hm2_7i96.0.gpio.006.in
|Breakaway Switch|only if using a breakaway switch +
                  the HAL pin you have connected your breakaway switch to|parport.0.pin-13-in +
                                                                          hm2_7i96.0.gpio.005.in
|Move Up|Mode 2 only +
         the HAL pin you have connected your move up signal to|parport.1.pin-10-in +
                                                               hm2_7i96.0.gpio.004.in
|Move Down|Mode 2 only +
           the HAL pin you have connected your move down signal to|parport.1.pin-11-in +
                                                                   hm2_7i96.0.gpio.003.in
|Run Panel|Run Tab = the run frame is a tab behind the preview tab +
           Run Panel = the run frame is a panel at the side of the GUI|Run Tab
|Scribe Arming|only required if using a scribe +
               the HAL pin to arm the scribe|parport.1.pin-16-out +
                                             hm2_7i96.0.ssr.00.out-02
|Scribe On|only required if using a scribe +
              the HAL pin to turn the scribe on|parport.1.pin-16-out +
                                                hm2_7i96.0.ssr.00.out-03
|Powermax Comms|only required if using Powermax communications +
                the serial port used for communications|/dev/ttyUSB0
|===

NOTE: If you are not sure of the full name of a HAL pin then start LinuxCNC for your base machine and run *HalShow* for a full listing of all HAL pins.

Fill in the required entries to suit your machine wiring, click *Create* and you should end up with a working PlasmaC configuration in ~/linuxcnc/configs/<machine_name>

This can be run as follows:

----
$ linuxcnc ~/linuxcnc/configs/<machine_name>/<machine_name>.ini
----

After creating a new configuration some initial setup is required.

=== Initial Setup

LinuxCNC should now be running with the PlasmaC panels visible.

Open the Config Panel and ensure every one of these settings suits your machine.

See <<config-panel, Config Panel>>

. axis Z MIMIMUM_LIMIT should be set below the slats by the amount of float switch travel plus a small 'bit' for tolerance. Say your float switch moves 4mm (0.157") before the switch activates then you should set the Z axis minimum limit to 5mm (0.096) below the lowest slat position.

. axis Z MAXIMUM_LIMIT should be the highest you want the Z axis to travel, it must not be lower than Z HOME_OFFSET but does not need to be at the top of travel.

. axis Z HOME should be at or just below axis Z MAXIMUM_LIMIT.

. Home the Z axis.

. Ensure there is nothing below the torch then Jog Z down until it stops at axis Z MIMIMUM_LIMIT then touchoff the Z axis with the Touchoff button at zero offset.

. Home the Z axis again.

If you use a float switch then you will need to set the offset in the Config Panel.

. Check that the Probe Speed and the Probe Height in the Config Panel are correct. PlasmaC can probe at the full Z axis velocity so long as your machine has enough movement in the float switch to absorb any overrun. If your machine is suitable you could set Probe Height to near the Z axis minimum and do all probing at full speed.

. Home the machine if not already homed and in the home position.

. Place some material on the slats under the torch.

. Press the Probe Test button.

. The Z axis will probe down, find the material then move up to Pierce Height. It will wait there for the time set in the ini file, the default is 30 seconds (you can change this if you wish). After this it will rise to the starting height.

. Measure the height above the material while it is waiting at Pierce Height.

. If it measures greater than Pierce Height then reduce the Float Travel by the difference, if less than Pierce Height then increase the Float Travel by the difference.

. After the Z axis rises, repeat from #4 above until the Pierce Height is correct. 

IMPORTANT: IF USING A *Mesa Electronics THCAD* THEN UP UNTIL NOW THE *Voltage Scale* VALUE WAS OBTAINED MATHEMATICALLY. IF YOU INTEND TO USE CUT VOLTAGES FROM MANUFACTURES CUT CHARTS THEN IT WOULD BE ADVISABLE TO DO MEASUREMENTS OF ACTUAL VOLTAGES AND FINE TUNE THE *Voltage Scale* AND *Voltage Offset*.

CAUTION: PLASMA CUTTING VOLTAGES CAN BE LETHAL, IF YOU ARE NOT EXPERIENCED IN DOING THESE MEASUREMENTS GET SOME QUALIFIED HELP.

[[lowpass]]

== Lowpass Filter

The PlasmaC HAL component has an inbuilt lowpass filter which has the same behaviour as the LinuxCNC lowpass HAL component. This filter if used is applied to the *plasmac.arc-voltage* output. The pin name to use for this filter is *plasmac.lowpass-frequency* and as the name suggests you enter the cutoff frequency that is required, if the frequency is zero then there is no filtering applied.

It is suggested that if you wish to use the filter then the entry for it should be in the <machine_name>_connections.hal file in your configuration directory.

----
setp plasmac.lowpass-frequency 100
----

Would give a cutoff frequency of 100Hz.

== Contact Debounce

Contact bounce or external interference may cause some inconsistent behaviour of the following switches:

* Float Switch
* Ohmic Probe
* Breakaway Switch

This may be alleviated by changing the debounce value in the <machine_name>_connections.hal file. In a standard configuration this value applies to all three switches simultaneously but you could separate these by using an exclusive debounce group.

Each increment changes the debounce timing by one servo thread cycle and for the Float and Ohmic switches it equates to a 0.001mm (0.00004") increase in the probed height result.

Debounce is achieved by using the HAL link:http://linuxcnc.org/docs/html/man/man9/debounce.9.html[debounce component].

If you require debounce for other equipment like home or limit switches etc then change the following line in the <machine_name>_connections.hal:

----
loadrt  debounce  cfg=3
----

to:

----
loadrt  debounce  cfg=3,n
----

with n being the number of contacts you need debounced. 

This will create a new debounce group named debounce.1 for your use, then add the following lines:

----
setp  debounce.1.delay  c
addf  debounce.1        servo-thread
----

with c being the number of servo cycles for the debounce time.

Then you can net the debounce to any HAL pin you require in any of the .hal files (except postgui.hal) like the following example:

----
net home-x-in   parport.1.pin-11-in-not  =>  debounce.1.0.in
net home-x-out  debounce.1.0.out         =>  joint.0.home-sw-in
----


== Desktop Launcher

You could create a desktop launcher to your config by right clicking on the desktop and selecting Create Launcher or similar. This will bring up a dialog to create a launcher. Give it a nice short name, enter anything for the command and click OK.

After the launcher appears on the desktop, right click on it and then open with your editor of choice. Edit the file so it looks similar to:

----
[Desktop Entry]
Comment=
Terminal=false
Name=LinuxCNC
Exec=sh -c "linuxcnc $HOME/linuxcnc/configs/<machine_name>/<machine_name>.ini"
Type=Application
Icon=/usr/share/pixmaps/linuxcncicon.png
----

If you would like a terminal window to open behind the GUI window then change the Terminal line to:

----
Terminal=true
----

Displaying a terminal can be handy for error messages and information messages.
 
== Plasmac Files

After an installation, the following files are created in the configuration directory:
[width="100%",cols="1,2"]
|===
|*Filename*|*Function*
|<machine_name>.ini|configuration file
|<machine_name>.hal|HAL connections for the PlasmaC component
|<machine_name>_connections.hal|HAL connections to the I/O HAL pins
|postgui.hal|a HAL file run after the GUI has loaded for user customizing
|===

NOTE: Custom commands are allowed in <machine_name>_connections.hal and the postgui.hal files as they are not overwritten during upgrades

In addition to the above files, the following links are created to the files in the source directory:
[width="100%",cols="1,2"]
|===
|*Filename*|*Function*
|blank.ngc|for Gmoccapy shape library file loading
|configurator.py|configure a new or upgrade/re-configure an existing PlasmaC configuration
|xxx_startup.ngc|initial G-Code startup for imperial or metric machines
|M190|for G-Code changing of materials
|materialverter.py|tool table converter and material file creator
|plasmac_axis.py|python code to customise the Axis GUI
|plasmac_xxx.glade|a gladevcp panel for the PlasmaC configuration
|plasmac_xxx.hal|HAL connections for the panel
|plasmac_xxx.py|python code for the panel
|plasmac_G-Code.py|a preprocessor for the loaded G-Code file
|plasmac.tcl|permanent HAL connections for the plasmac component
|pmx_test.py|test panel for powermax communications
|pmx485.py|python code for powermax communications
|tool.tbl|tool table for the PlasmaC configuration
|versions.html|complete uddate list
|wizards|files relating to the shape library
|test|files for the test panel
|===

After running a new configuration the first time the following files will be created in the configuration directory:
[width="100%",cols="1,2"]
|===
|*Filename*|*Function* (<machine_name> = name of machine in .ini file)
|<machine_name>_config.cfg|configuration settings for the Config Panel
|<machine_name>_run.cfg|configuration settings for the Run Panel
|<machine_name>_material.cfg|material file for cut parameters
|<machine_name>_wizards.cfg|configuration settings for the shape library
|plasmac_stats.var|saved statistics
|===

NOTE: The .ini files are notated for extra the requirements for these configurations.

NOTE: The .cfg files are plain text and may be edited with any text editor.


== PlasmaC GUI Panels

PlasmaC adds several panels to the GUI, some are panels on permanent display and others are tabs behind the preview tab.

Some functions are only used for particular modes and are not displayed if not required.

[[config-panel]]

=== Config Panel
This panel is for configuration parameters that are modified infrequently.

It is possible to disable this panel so machine settings cannot be modified by unauthorised personnel. This is achieved by setting a variable in the .ini file:

----
[PLASMAC] CONFIG_DISABLE = 1
----

A HAL pin named *plasmac_config.config-disable* can then be set to Zero to enable the panel. This pin could be tied to a key-switch or similar so only authorised personnel could enable the Config Panel.

image::images/plasmac_config.png[width=50%]

[underline]*Probing*

[width="100%",cols="4,16"]
|===
|*Name*|*Description*
|Float Travel|This is the amount of travel in the float switch mechanism. This can be tested with a Probe Test button, see <<custom-user-buttons, Custom User Buttons>>.
|Probe Speed|This is the speed the Z axis will probe down at after it moves to Probe Height.
|Probe Height|This is the height above the Z axis bottom limit that Probe Speed begins.
|Ohmic Probe Offset|The Z axis offset of the ohmic probe.
|Ohmic Retries|This is the number of times to retry an ohmic probe if it fails before fallback to the float switch.
|Skip IHS|The distance used to see if Initial Height Sense (probe) can be skipped for the current cut, see <<ihs-skip, IHS Skip>>.
|===

NOTE: Probe Height is the height above the minimum Z axis limit.

[underline]*THC*

[width="100%",cols="4,2,14"]
|===
|*Name*|*Modes*|*Description*
|Delay|0,1,2|Delay from cut start until THC activates.
|Threshold|0,1,2|Variation from target voltage for THC to correct height.
|PID P Gain (Speed)|0,1|PID P gain for THC, THC correction speed.
|VAD Threshold|0,1|Percentage of Cut Feed Rate velocity needs to fall below to lock THC.
|Void Override|0,1|Higher values need greater voltage change to lock THC
|PID I Gain|0,1|PID I gain for THC
|PID P Gain|0,1|PID D gain for THC
|===

[underline]*Safe Height*

[width="100%",cols="4,16"]
|===
|*Name*|*Description*
|Safe Height|This is the height above the work surface that the Z axis will retract to on rapid moves. +
                   If set to Zero then Z axis maximum height will be used for the safe height.
|===

[underline]*Arc*

[width="100%",cols="4,2,14"]
|===
|*Name*|*Modes*|*Description*
|Fail Timeout|0,1,2|The amount of time to wait from torch on until a failure if arc is not detected.
|Max. Starts|0,1,2|The number of attempts at starting an arc.
|Retry Delay|0,1,2|The time between an arc failure and another arc start attempt.
|Voltage Scale|0,1|The value required to scale the arc voltage input to display the correct arc voltage.
|Voltage Offset|0,1|The value required to display zero volts when there is zero arc voltage input. +
                    For initial setup multiply the arc voltage out value by -1 and enter that for Voltage Offset.
|Height Per Volt|0,1,2|The distance the torch would need to move to change the arc voltage by one volt. +
                       Used for manual height change only.
|OK High Volts|0|High voltage threshold for Arc OK.
|OK Low Volts|0|Low voltage threshold for Arc OK.
|===

[underline]*Motion*

[width="100%",cols="4,16"]
|===
|*Name*|*Description*
|Max. Speed|Display only of the maximum speed the Z axis is capable of.
|Setup Speed|The Z axis speed for setup moves. e.g. Pierce Height, Cut Height etc.
|===

NOTE: Setup Speed has no effect on THC speed which is capable of Max. Speed.

[[scribe-config]]

[underline]*Scribing*

[width="100%",cols="4,16"]
|===
|*Name*|*Description*
|Arm Delay|Delay to allow scribe to reach surface of material before start of scribing.
|On Delay|Delay to allow scribe to start before beginning motion.
|===

[underline]*Spotting*

[width="100%",cols="4,16"]
|===
|*Name*|*Description*
|Threshold|The arc voltage at which the delay timer will begin. +
           0V starts the delay when the torch on signal is activated.
|Delay|The length of time the torch is on after threshold reached (mS).
|===

[underline]*Save & Reload Buttons*

The **Save** button will save the currently displayed parameters.

The **Reload** button will reload all the parameters.

[[run-panel]]

=== Run Panel

This panel shows the parameters which are active for the current cut.

There are two formats for this panel, a tab behind the preview tab or a panel at the side of the GUI. The formats are different but the functionality is identical.

image::images/plasmac_run.png[width=70%]

See <<axis-display-section, Axis [DISPLAY] Section>> or <<gmoccapy-display-section, Gmoccapy [DISPLAY] section>>

[underline]*Cut Parameters*

[width="100%",cols="4,16"]
|===
|*Name*|*Description*
|Material|Selects and displays the currently selected material, if there are no materials in the material file then only the default material will be displayed
|Kerf Width|The kerf width for the currently selected material
|THC Enable|THC state for the currently selected material
|Pierce Height|The pierce height for the currently selected material
|Pierce Delay|The pierce delay for the currently selected material
|Cut Height|The cut height for the currently selected material
|Cut Feed Rate|The cut feed rate for the currently selected material
|Cut Amps|The cut amperage for the currently selected material +
          Operator indicator only unless using Powermax communications
|Cut Volts|The cut voltage for the currently selected material
|P-Jump Height|The puddle jump height for the currently selected material
|P-Jump Delay|The puddle jump delay for the currently selected material
|Pause At End|Pause for n seconds at end of cut with torch on before turning torch off and raising torch
|Gas Pressure|The gas pressure for the currently selected material. +
              Only valid if PowerMax communications operational
|Cut Mode|The cut mode for the currently selected material. +
          Only valid if PowerMax communications operational +
          1 = Normal, 2 = CPA, 3 = Gouge/Mark
|===

[underline]*THC*

[width="100%",cols="4,2,14"]
|===
|*Name*|*Modes*|*Description*
|State|0,1,2|Disabled = permanently off +
             Auto = decide by THC Enable and G-Code +
             Enabled = on unless disabled by G-Code
|Use Auto Volts|0,1|On = THC control voltage is sampled from arc voltage +
                    Off = THC control voltage is from Cut Volts +
|VAD Enable|0,1,2|On = Velocity anti-dive is enabled +
                  Off = Velocity anti-dive is disabled +
|Void Sense Enable|0,1|On = Void sensing is enabled +
                      Off = Void sensing is disabled

|===

[underline]*Ohmic Probe*

[width="100%",cols="4,16"]
|===
|*Name*|*Description*
|Ohmic Probe Enable|This is to enable or disable the ohmic probe input.
|===

NOTE: If Ohmic Probe is disabled, the Ohmic Probe LED will still show the status of the probe input.

[underline]*Single Cut*

[width="100%",cols="4,16"]
|===
|*Name*|*Description*
|X Axis Length|The X axis distance to travel for a single cut.
|Y Axis Length|The Y axis distance to travel for a single cut.
|Start Cut|Press to commence a single cut.
|===

[underline]*Cutting Mode*

[width="100%",cols="4,16"]
|===
|*Name*|*Description*
|Mesh Mode|Enable mesh mode for cutting expanded metal.
|Ignore Arc OK|Don't require Arc OK to start a cut and ignore loss of Arc OK during a cut.
|===

[underline]*Powermax Comms*

[width="100%",cols="4,16"]
|===
|*Name*|*Description*
|Enable|This is to enable or disable the communications to a Powermax.
|Status|This will display one of *Connecting*, *Connected*, *Comms Error* or *Fault Code*.
|===

For more information, see the <<pm_comms, Powermax Communications>> section.

NOTE: This frame is only visible if a PM_PORT is configured in the [PLASMAC] section of the .ini file.

[[run-buttons]]

[underline]*Save Button*

image::images/plasmac_save_dialog.png[width=20%]

The **Save** button brings up a dialog with the following options:

[width="100%",cols="4,16"]
|===
|Material|Save the Cut Parameters for the material currently displayed.
|Settings|Save all setting except for the Cut Parameters.
|Both|Save The Cut Parameters and the settings.
|Cancel|Close the dialog withaout saving.
|===

[underline]*Reload Button*

The **Reload** button will reload all the saved settings and the material file then redisplay the current material. If Powermax communications was enabled it will ignore the saved settings and keep it enabled.

[underline]*New Button*

The **New** button allows the addition of a new material in the material file.

It will prompt for a material number and a material name. When these are entered it will create the new material using the Cut Parameters from the currently active material and then reload the material file with the new material displayed.

Make any required changes and then save them using the save button.

[underline]*Delete Button*

The **Delete** button allows the deletion of a material from the material file.

It will prompt for a material number and when this is entered it will prompt again to make sure you want to delete it.

If the deletion is confirmed it will delete the material from the material file and reload the materials with the default material loaded.

=== Monitor Panel

The Monitor Panel is used for display only, both Axis and Gmoccapy have similar Monitor Panels.

image::images/plasmac_monitor.png[width=40%]

[width="100%",cols="6,2,14"]
|===
|*Name*|*Modes*|*Description*
|Arc Voltage|0,1|Displays the actual arc voltage
|Arc OK|1,2|Indicates the status of the arc ok signal
|Torch On|0,1,2|Torch is activated
|THC Enabled|0,1,2|Indicates if THC is enabled
|Ohmic Probe|0,1,2|Indicates the probe has sensed the material
|Float Switch|0,1,2|Indicates the float switch is activated
|Breakaway|0,1,2|Indicates the breakaway sensor is activated
|THC Active|0,1,2|Indicates THC is currently active
|THC Up|0,1,2|Indicates THC is causing the Z axis to raise
|THC Down|0,1,2|Indicates THC is causing the Z axis to lower
|THC Velocity Lock|0,1,2|Indicates THC is locked due to velocity constraints
|THC Void Lock|0,1|Indicates THC is locked due to void being sensed
|===

NOTE: The Ohmic Probe LED will show the status of the probe input regardless of whether Ohmic Probe is enabled or disabled.


=== Button Panel

The Button Panel contains buttons useful for the operation of the machine.

Both GUIs have a *Torch Enable* button which is permanent, all other buttons are <<custom-user-buttons, user programmable>> in the .ini file. Axis has five user buttons and Gmoccapy has four user buttons.

Axis button layout:

image::images/plasmac_buttons_a.png[width=40%]

Gmoccapy button layout:

image::images/plasmac_buttons_g.png[width=10%]

The *Torch Enable* button toggles between Enabled and Disabled.

It needs to be Enable to do any cutting.

If it is Disabled then running a loaded program will cause the program to do its cycle without the torch being activated.

=== Control Panel

The Control Panel allows the control of some functions, both GUIs are similar except that the Gmoccapy Control Panel is integrated into the frame containing feed and rapid overrides.

These functions are enabled and disable automatically depending on the status of the machine.

Axis Control Panel: 

image::images/plasmac_control_a.png[width=40%]

Gmoccapy Control Panel:

image::images/plasmac_control_g.png[width=40%]

[underline]*Torch Pulse*

This pulses the torch on for the amount of time set in the corresponding slider.

[[paused-motion]]

[underline]*Paused Motion*

When a program is paused, this allows x/y motion to follow the programmed path in the reverse or forward direction at the percentage of the current feed rate shown in the adjustment.

When reversing, motion will stop when it reaches a spindle on command.

When forwarding, motion can continue until the end of the path.

For advanced recovery from a failed cut see <<cut-recovery, cut recovery>>.

[underline]*Height Change*

Each press of Raise or Lower will change the height of the torch by the value set in Height Per Volt in the Arc frame of the Config Panel. Reset will cancel any height override.

=== Statistics Panel

This provides statistics to allow tracking of consumable wear and job times.

They are shown for the current job and are also as a running total.

Job statistics are reset when the current program is run.

The total values may be reset either individually or all together.

image::images/plasmac_stats.png[width=60%]

=== Extras Panel

This provides a conversational shapes library with some simple shapes that can be selected and loaded into LinuxCNC.

It also provides ten custom user buttons which operate the same as the other custom user buttons plus they have the ability to use the <<cut-recovery, cut-recovery>> function and load a G-Code program. They can also display a custom image on the button.

See <<shape-library, conversational shape library>> for shape usage.
 
See <<custom-user-buttons, custom user buttons>> for button usage.

image::images/plasmac_extras.png[width=60%]

The Extras panel may be disabled by commenting out the appropriate entries in the [DISPLAY] section of the .ini file. This will have no effect on the operation of the PlasmaC configuration.

== Using PlasmaC

The only mandatory G-Code requirement for a PlasmaC configuration is *M3 $0 S1* to begin a cut and *M5 $0* to end a cut, plus of course standard motion codes to move from start to end.

If you are using PlasmaC without <<multi-tool, multiple tools>> enabled then it is permissible to use *M3 S1* in lieu of *M3 $0 S1* to begin a cutting job and *M5* in lieu of *M5 $0*.

=== Coordinates

See <<z_settings, recommended Z axis>> settings.

Each time LinuxCNC is started it requires homing. This allows LinuxCNC to know where in the world the torch is and sets the soft limits to the values specified in the .ini file thus preventing the machine from crashing into a hard stop during normal use.

If your machine does not have home switches then you need to ensure that all axes are at the home coordinates specified in the .ini file before homing.

If your machine has home switches then it will move to the specified home coordinates when directed.

Depending on your configuration you may have a *Home All* button or you may need to home each axis individually. Use the appropriate button/buttons to home the machine.

After homing the torch needs to know where the material is, this is achieved with *Touch Off*.

It is recommended that the first time you use PlasmaC that you jog the Z axis down to near the slats and *Touch Off* the Z axis with a zero offset. When done, jog the Z axis up to where it was originally. This should not need to be done again. From now on leave the Z axis at this position as PlasmaC will control all Z axis motion.

If you intend to place your material in the same place on the table every time then you could jog the X and Y axes to the X0,Y0 position of the material and then *Touch Off* both axes with a zero offset.

If you intend to place the material randomly on the table then before each job you will need to *Touch Off* as above or place the material at the previous location.

[[path-tolerance]]

=== Path Tolerance

The provided <<rs274, RS274NGC_STARTUP_CODE>> files, metric_startup.ngc and imperial_startup.ngc set the path tolerance to 0.1mm (0.004") with a G64 command. If LinuxCNC sees an Estop at any stage then the path tolerance if set to default which will round corners off so it is recommended that the path tolerance is set in the header of each G-Code file.

=== Pause At End Of Cut

This causes all motion to pause at the end of the cut with the torch still on. After the specified dwell time has passed the torch will turn off and the Z axis will rise.

The time value for this feature is *Pause At End* in the Cut Parameters of the Run Panel. This value is also in the material file and may be set for each material.

This feature is used to allow the arc to catch up to the torch position to fully finish the cut. It is usually required for thicker materials, especially stainless.

[[multi-tool]]

=== Multiple Tools

Multiple tools allows the use of more than one tool, valid tools are:

* Plasma Torch - for normal cutting
* Scribe - for engraving
* Plasma Torch - for spotting

If multiple tools are enabled then a LinuxCNC tool number is required in the *M3 command to selected the required tool.

* *M3 $0 S1* will select the plasma cutting tool.
* *M3 $1 S1* will select the scribe.
* *M3 $2 S1* will select the plasma spotting tool.

To enable the multiple tools feature you need to edit the following line in <machine_name>_connections.hal.

from:

----
setp plasmac.multi-tool 0
----

to:

----
setp plasmac.multi-tool 1
----

PlasmaC will read the cut parameters from the Run Panel and use them where required.

[[material-handling]]

=== Material Handling

Material handling has nothing at all to do with the LinuxCNC tool table, instead it uses a material file that was created at the same time as the configuration.

The LinuxCNC tool table and tool commands only come into play if your are using an <<scribe, scribe>> in addition to the plasma torch.

There is a <<material-file, material file>> with its name derived from *[EMC]MACHINE* in the in file, so a machine named *METRIC_PLASMAC* would have a material file named *metric_plasmac_material.cfg*.

It is not a requirement that you use a material file, if required you can change the cut parameters manually in the Run Panel. It is also not a requirement to use the automatic material changes, just omit them from the G-Code file.

The following codes may be used for a PlasmaC configuration:

* *M190 Pn* - changes the material to number n.
* *M66 P3 L3 Q1* - waits for material change to be confirmed.
* *F#<_hal[plasmac.cut-feed-rate]>* - sets the feed rate to the feed rate shown in the cut parameters of the Run Panel.
* *M3 $0 S1* - starts the PlasmaC component.

For manual material handling you manually select the material from the materials list in the Run Panel before running your G-Code which should have the following minimum code:

----
F#<_hal[plasmac.cut-feed-rate]>
M3 $0 S1
.
.
M5 $0
----

NOTE: Manual material handling does restrict you to only one material for the entire job.

For automatic material handling, the codes MUST be in the order shown.
You could have other codes between them.
In your G-Code you need:

----
M190 Pn
M66 P3 L3 Q1
F#<_hal[plasmac.cut-feed-rate]>
M3 $0 S1
.
.
M5 $0
----

Material numbers in the materials file do not need to be consecutive nor do they need to be in numerical order.

When a material is changed it only changes the cut parameters in the Run Panel, LinuxCNC knows nothing of the material nor does PlasmaC know anything about LinuxCNC tools. (i.e. it does NOT do a tool change)

Materials can be selected manually with the either the Cut Parameters combobox or via MDI with M190 Pn.

If a G-Code program is loaded which contains one or more material change commands then the first material will be displayed in the Run Panel as the program is loading.

=== Materials Adding And Editing From G-Code

It is possible to add new materials or edit existing materials by using "magic comments" in a G-Code file.

The options are:

[width="75%",cols="0,1"]
|===
|*Option*|*Description*
|0|Create a temporary default material +
     This will be discarded by a manual reload or a LinuxCNC restart
|1|Add a new material if it does not exist
|2|Overwrite an existing material if it exists +
     Add a new material if it does not exist
|===

Mandatory parameters are:

[width="75%",cols="0,1"]
|===
|*Name*|*Description*
|o|option
|nu|material number (not required for option 0)
|na|material name (not required for option 0)
|ph|pierce height
|pd|pierce delay
|ch|cut height
|fr|feed rate
|===

Optional parameters are:

[width="75%",cols="0,1"]
|===
|*Name*|*Description*
|kw|kerf width
|th|thc enable (0=disable, 1=enable)
|ca|cut amps
|cv|cut voltage
|pe|pause at end delay
|gp|gas pressure (Powermax)
|cm|cut mode (Powermax)
|jh|puddle jump height
|jd|puddle jump delay
|===

Formatting rules are:

- The entire comment must be in parentheses
- The beginning of the magic comment must be *(o=*
- The equals sign must immediately follow each parameter with no space
- The above mandatory parameters must be in the magic comment (*nu* and *na* are not required for option 0)
- There can be any number and type of magic comments in a G-Code file with the exception of option 0. If more than one option 0 are in the G-Code file then only the last one found will be used.
- If option 0 is required as well as other option 1 and/or option 2 then option 0 must be the last one in the G-Code file.
A complete example is:

----
(o=1, nu=2, na=5mm Mild Steel 40A, ph=3.1, pd=0.1, ch=0.75, fr=3000, kw=0.5, th=1, ca=45, cv=110, pe=0.1, gp=5, cm=1, jh=0, jd=0)
----

[[thc]]

=== THC

THC can be controlled from the THC frame of the Run Panel, off = disabled, on = enabled and auto means abide by the THC Enable checkbox in the cut parameters.

THC can also be enabled or disabled directly from G-Code provided that THC is not disabled in the Run Panel.

PlasmaC uses a control voltage dependent on the state of the Use Auto Volts checkbox in the Run Panel:

. If Use Auto Volts is checked then the actual cut voltage is sampled after the cut begins and this is then used as the control voltage. To allow the arc voltage to stabilise, PlasmaC waits for the amount of time displayed as Delay in the THC frame of the Run Panel before taking the sample.
. If Use Auto Volts is not checked then the voltage displayed as Cut Volts in the Cut Parameters frame of the Run Panel is used as the control voltage.

THC does not become active until the velocity reaches 99.9% of the *CutFeedRate*.

[underline]*G-Code THC*

THC may be disabled and enabled directly from G-Code provided THC is not disabled in the Run Panel, by setting or resetting the *motion.digital-out-02* pin with the M-Codes M62-M65:

* *M62 P2* will disable THC (synchronised with motion)
* *M63 P2* will enable THC (synchronised with motion)
* *M64 P2* will disable THC (immediately)
* *M65 P2* will enable THC (immediately)

[[velocity_thc]]

[underline]*Velocity Based THC*

If the cut velocity falls below a percentage of *CutFeedRate* then THC will be locked until the cut velocity returns to at least 99% of *CutFeedRate*.

This percentage is displayed as VAD Threshold % in the THC frame of the Config Panel.

Velocity based THC prevents the torch height being changed when velocity is reduced for a sharp corner or a small hole.

There is a HAL pin available named *motion.analog-out-03* that can be changed in G-Code with the M67/M68 commands. This pin will reduce the velocity to the percentage specified in the command.

* *M67 E3 Q0* would set the velocity to 100% of *CutFeedRate*.
* *M67 E3 Q40* would set the velocity to 40% of *CutFeedRate*.
* *M67 E3 Q60* would set the velocity to 60% of *CutFeedRate*.
* *M67 E3 Q100* would set the velocity to 100% of *CutFeedRate*.

The minimum percentage allowed is 10%, values below this will be set to 100%.

The maximum percentage allowed is 100%, values above this will be set to 100%.

If you intend to use this feature it would be prudent to add *M68 E3 Q0* to your G-Code preamble and postamble so you start and end at a known state.

TIP: Another way of achieving the same result is to use *F#<_hal[plasmac.cut-feed-rate]* with a multiplier.

----
F[#<_hal[plasmac.cut-feed-rate] * 0.6]
----

IMPORTANT: *G-Code THC* AND *Velocity Based THC* ARE NOT ABLE TO BE USED if *Cutter Compensation* IS IN EFFECT, AN ERROR MESSAGE WILL BE DISPLAYED.

WARNING: If Cut Feed Rate in the Run Panel is set to Zero then PlasmaC will use *motion.requested-velocity* for the THC calculations which is not a very reliable way of velocity based THC and is not recommended.

NOTE: All references to CutFeedRate mean Cut Feed Rate as displayed in the Run Panel.

[[cutter-compensation]]

=== Cutter Compensation

To use cutter compensation you will need to use G41.1, G42.1 and G40 with the kerf width HAL pin:

* *G41.1 D#<_hal[plasmac_run.kerf-width-f]>* ; for left of programmed path
* *G42.1 D#<_hal[plasmac_run.kerf-width-f]>* for right of programmed path
* *G40* to turn compensation off

IMPORTANT: IF *Cutter Compensation* IS IN EFFECT *G-Code THC*, *Velocity Based THC* AND *Overcut* ARE NOT ABLE TO BE USED, AN ERROR MESSAGE WILL BE DISPLAYED.

[[ihs-skip]]

=== Initial Height Sense Skip

IHS may be skipped in one of two different ways:

If THC is disabled then skip IHS if the start of the cut is less than *Skip IHS* distance from the last successful probe.

If THC is enabled then skip IHS if the start of the cut is less than *Skip IHS* distance from the end of the last cut.

A value of zero for *Skip IHS* will disable IHS skipping.

Any errors encountered on a cut will disable IHS skipping for the next cut if it was enabled.

=== Probing

Probing may be with either ohmic sensing or a float switch, it is also possible to combine both with the float switch providing a fallback to ohmic probing.

If your torch does not support ohmic probing you could have a separate probe next to the torch. In this case you would extend the probe below the torch. The probe must NOT extend more than your minimum Cut Height below the torch and this offset distance is entered as the *ohmic-probe-offset* in the Config Panel.

Probing setup is done in the Motion frame of the Config Panel.

PlasmaC can probe at the full Z axis velocity so long as your machine has enough movement in the float switch to absorb any overrun. If your machine is suitable you could set Probe Height to near the Z axis minimum and do all probing at full speed.

NOTE: Probe Height is the height above the minimum Z axis limit.

[[cut-types]]

=== Cut Types

PlasmaC allows two different cut types:

* Pierce and Cut - runs the loaded G-Code program to pierce then cut.
* Pierce Only - converts then runs the loaded G-Code program to do piercing only.

Pierce Only mode is useful for thick materials which may produce enough dross on the material surface from piercing to interfere with the torch while cutting. This enables the entire sheet to be pierced and cleaned off before cutting.

This also enables near end of life consumables to be used for piercing and they can be swapped out for good consumables to be used in cutting.

There are two ways of enabling this feature:

* Program a <<button-cut, custom user button>> to toggle between the cut types.
* Adding a line *#<pierce-only> = 1* in the G-Code file before the first cut to enable Pierce Only mode for the current file.

If using a custom user button then the GUI will automatically reload the file when the cut type is toggled.

=== Hole Cutting - Intro

It is recommended that any holes to be cut have a diameter no less than one and a half times the thickness of the material to be cut.

It is also recommended that holes with a diameter of less than 32mm (1.26") are cut at 60% of the feed rate used for profile cuts. This should also lock out THC due to velocity constraints.

PlasmaC can utilise G-Code commands usually set by a CAM Post Processor (PP) to aid in hole cutting or if you do not have a PP or your PP does not support these methods then PlasmaC can automatically adapt the G-Code to suit. This automatic mode is disabled by default.

There are three methods available for improving the quality of small holes.

. Velocity Reduction: Reduce the velocity to approximately 60% of the *CutFeedRate*.
. Arc Dwell: Keep the torch on for a short time at the end of the hole while motion is stopped to allow the arc to catch up.
. Overcut: Turn the torch off at the end of the hole then continue along the path.

NOTE: If both *Arc Dwell* and *Overcut* are active at the same time then *Overcut* will take precedence.

IMPORTANT: *Overcut* IS NOT ABLE TO BE USED IF CUTTER COMPENSATION IS IN EFFECT, AN ERROR MESSAGE WILL BE DISPLAYED.


=== Hole Cutting - G-Code Commands

Your G-Code commands are set up either by a CAM Post Processor (PP) or by hand coding.

[[velocity-reduction]]

[underline]*Velocity Reduction*

If a hole requires a reduced velocity then set the velocity with *M67 E3 Q60* which would set the velocity to 60% of *CutFeedRate*.

See the <<velocity_thc,Velocity Based THC>> section.

Sample code:

----
G21 (metric)
G64 P0.005
M52 P1 (allow paused motion)
F#<_hal[plasmac.cut-feed-rate]> (feed rate from cut parameters)
G0 X10 Y10
M3 $0 S1 (start cut)
G1 X0
M67 E3 Q60 (reduce feed rate to 60%)
G3 I10 (the hole)
M67 E3 Q0 (restore feed rate to 100%)
M5 $0 (end cut)
G0 X0 Y0
M2 (end job)
----

[underline]*Arc Dwell*

Hold motion for a time by setting *Pause At End* in the Cut Parameters frame of the <<run-panel, Run Panel>>

Sample code:

----
G21 (metric)
G64 P0.005
M52 P1 (allow paused motion)
F#<_hal[plasmac.cut-feed-rate]> (feed rate from cut parameters)
G0 X10 Y10
M3 $0 S1 (start cut)
G1 X0
M67 E3 Q60 (reduce feed rate to 60%)
G3 I10 (the hole)
M67 E3 Q0 (restore feed rate to 100%)
M5 $0 (end cut)
G0 X0 Y0
M2 (end job)
----

[[overcut]]

[underline]*Overcut*

The torch can be turned off at the end of the hole by setting the *motion.digital-out-03* pin with the M-Codes *M62* or *M64*. After turning the torch off it is necessary to allow the torch to be turned on again before beginning the next cut by resetting the *motion.digital-out-03* pin with the M-Codes *M63* or *M65*, this will be done automatically by the PlasmaC G-Code parser if it reaches an M5 command without seeing a *M63 P3* or *M65 P3*.

After the torch is turned off the hole path will be followed for a default length of 4mm (0.157"). This distance may be specified by adding #<oclength> = n to the G-Code file.

* *M62 P3* will turn the torch off (synchronised with motion)
* *M63 P3* will allow the torch to be turned on (synchronised with motion)
* *M64 P3* will turn the torch off (immediately)
* *M65 P3* will allow the torch to be turned on (immediately)

Sample code:

----
G21 (metric)
G64 P0.005
M52 P1 (allow paused motion)
F#<_hal[plasmac.cut-feed-rate]> (feed rate from cut parameters)
G0 X10 Y10
M3 $0 S1 (start cut)
G1 X0
M67 E3 Q60 (reduce feed rate to 60%)
G3 I10 (the hole)
M62 P3 (turn torch off)
G3 X0.8 Y6.081 I10 (continue motion for 4mm)
M63 P3 (allow torch to be turned on)
M67 E3 Q0 (restore feed rate to 100%)
M5 $0 (end cut)
G0 X0 Y0
M2 (end job)
----

[[hole-cutting]]

=== Hole Cutting - Automatic

PlasmaC has the ability to automatically modify the G-Code to reduce the velocity and/or apply *Overcut*.

The default hole size for PlasmaC hole sensing is 32mm (1.26").  It is possible to change this value with the following command:

* #<h_diameter> = nn - To set a diameter in the same units system as the rest of the G-Code file.

The default velocity for PlasmaC small holes is 60% of the current feed rate.  It is possible to change this value with the following command:

* #<h_velocity> = nn - to set the percentage of the current feed rate required.

PlasmaC hole sensing is enabled/disabled by setting the following G-Code parameter. It is disabled by default.

* #<holes> = 1 - Causes PlasmaC to reduce the speed of holes less than 32mm (1.26") to 60% of *CutFeedRate*.
* #<holes> = 2 - As well as the velocity reduction above it also turns the torch off at the end of the hole and follows the hole path.
* #<holes> = 3 - Causes PlasmaC to reduce the speed of holes less than 32mm (1.26") and arcs less than 16mm (0.63") to 60% of *CutFeedRate*.
* #<holes> = 4 - As well as the velocity reduction above it also turns the torch off at the end of the hole and follows the hole path.

[underline]*Arc Dwell*

Hold motion for a time by setting *Pause At End* in the Cut Parameters frame of the <<run-panel, Run Panel>>

Specify #<holes> = 1 to allow velocity reduction.

Sample code:

----
G21 (metric)
G64 P0.005
M52 P1 (allow paused motion)
F#<_hal[plasmac.cut-feed-rate]> (feed rate from cut parameters)
#<holes> = 1 (velocity reduction for holes)
G0 X10 Y10
M3 $0 S1 (start cut)
G1 X0
G3 I10 (the hole)
M5 $0 (end cut)
G0 X0 Y0
M2 (end job)
----

[underline]*Overcut*

The default overcut length for PlasmaC hole sensing is 4mm (0.157").  It is possible to change this value with the following command:

* #<oclength> = n to specify an overcut length  in the same units system as the rest of the G-Code filedifferent, if this parameter is not specified the default is 4mm (0.157").

Specify #<holes> = 2 to allow velocity reduction and overcut.

Sample code:

----
G21 (metric)
G64 P0.005
M52 P1 (allow paused motion)
F#<_hal[plasmac.cut-feed-rate]> (feed rate from cut parameters)
#<holes> = 2 (overcut for holes)
#<oclength> = 6.5 (optional, 6.5mm overcut length)
G0 X10 Y10
M3 $0 S1 (start cut)
G1 X0
G3 I10 (the hole)
M5 $0 (end cut)
G0 X0 Y0
M2 (end job)
----

NOTE: It is OK to have multiple and mixed hole commands in a G-Code file.

=== Single Cut

A single cut is a single unidirectional cutting move often used to cut a sheet into smaller pieces prior to running a G-Code program.

The machine needs to be homed before commencing a single cut.

A single cut will commence from the machines current X/Y position.

[underline]*Automatic Single Cut*

This is the preferred method and the parameters for this method are entered in the Run Panel.

. Jog to the required X/Y start position. +
. Set required Cut Feed Rate in Cut Parameters of the Run Panel. +
. Enter the length of the cut along the X and/or Y axes. +
. Press the *Start Cut* button and the cut will commence.


[underline]*Pendant Single Cut*

If you have a pendant that can start and stop the spindle plus jog the X and Y axes then you can manually perform a single cut.

. Jog to the required X/Y start position. +
. Set the required feed rate with the Jog Speed slider. +
. Start the procedure by starting the spindle. +
. After probing the torch will fire. +
. When the Arc OK is received the machine can be jogged along the cut line using the jog buttons. +
. When the cut is complete stop the spindle. +
. The torch will turn off and the Z axis returns to the starting position.

[underline]*Manual Single Cut In Axis*

. Jog to the required X/Y start position. +
. Set the required feed rate with the Jog Speed slider. +
. Start the procedure by pressing *F9*. +
. After probing the torch will fire. +
. When the Arc OK is received the machine can be jogged along the cut line using the jog keys. +
. When the cut is complete press *F9* or *Esc*. +
. The torch will turn off and the Z axis returns to the starting position.

[underline]*Manual Single Cut In Gmoccapy*

If you wish to use the keyboard jogging keys then enable keyboard shortcuts in the Hardware tab of the Settings page, otherwise use the GUI jog buttons.

. Jog to the required X/Y start position. +
. Set the required feed rate with the Jog Speed slider. +
. Enter MDI mode. +
. Start the procedure by entering *M3 S1*. +
. Enter Manual mode. +
. After probing the torch will fire. +
. When the Arc OK is received the machine can be jogged along the cut line using the jog buttons (or jog keys if enabled). +
. When the cut is complete press *Esc*. +
. The torch will turn off and the Z axis returns to the starting position.

[[mesh-mode]]

=== Mesh Mode (expanded metal)

Expanded metal is able to be cut provided your machine has a pilot arc torch and it is capable of constant pilot arc mode.

Mesh mode disables torch height control and also ignores a lost Arc OK signal during a cut. It can be selected by checking the Mesh Mode checkbutton in the Run Panel.

If you have <<pm_comms, RS485>> communications enabled with a Hypertherm Powermax plasma cutter then selecting mesh mode will disable the Cut Mode spinbutton in the Run Panel and it will select cut mode 2 (CPA). When mesh mode is disabled then the Cut Mode spinbutton will be re-enabled and the original cut mode will be restored.

It is also possible to start a cut without receiving the Arc OK signal by checking the Ignore Arc OK checkbutton on the Run Panel.

You can enable/disable this mode at any time during a job.

[[ignore-ok]]

=== Ignore Arc OK

Ignore Arc OK mode disables torch height control, will begin a cut without requiring an Arc OK signal and also ignores a lost Arc OK signal during a cut.

This mode can be selected by:

. checking the Ignore Arc OK checkbutton in the Run Panel. +
. setting HAL pin motion.digital-out-01 to 1 from G-Code.

----
M62 P1 or M64 P1 (enable Ignore Arc OK)
M63 P1 or M65 P1 (disable Ignore Arc OK)
----

This mode may also be used in conjunction with Mesh Mode if you don't require the Arc OK signal to begin the cut.

You can enable/disable this mode at any time during a job.

[[cut-recovery]]

== Cut Recovery

image::images/plasmac_cut_recovery.png[width=40%]

This dialog box feature allows the torch to be moved away from the cut path during a <<paused-motion, paused motion>> event in order to position the torch over a scrap portion of the material being cut so that the cut restarts with a minimized arc-divot. This function is only available from a user-programmed button in the Extras panel and is only valid while motion is paused.

It is generally preferable to make torch position adjustments from the point at which paused motion occurred, however if moving along the cut path is necessary prior to setting the new start point, the user may use the paused motion controls (Rev, Fwd, and a jog-speed slider) at the top of the dialog box. Once the user is satisfied with the positioning of the torch along the cut path, moving off the cut path is achieved by pressing the direction buttons. Each press of the direction button will move the torch a distance equivalent to the kerf width of the currently selected material.

Once the torch has been moved off the cut path by using the direction buttons, the paused motion controls (Rev, Fwd, and a jog-speed slider) at the top of the dialog box will be disabled.

Pressing Cancel (or the X in the title bar) will cause the torch to move back to where it was positioned prior to moving the torch with the direction buttons and the dialog box will close.

Once the torch position is satisfactory, press Resume Cut or the GUI’s Resume button (Pause symbol) and the cut will resume from the new position. The dialog box will close when the torch returns to the original paused motion location.

[[shape-library]]

== Conversational Shape Library

image::images/plasmac_conversational.png[width=40%]

The conversational shape library consists of several basic shapes and functions and is available from the *Extras* tab in the Gui. It is not meant to be a CAD/CAM replacement and there are limitations to what can be achieved.

Blank entries in the shape dialogs will use the current setting at the time. e.g. If *X start* was blank then the current X axis position would be used.

All lead-ins and lead-outs are arcs except for:

* Small holes
* Stars

The cut order is the in the same order as the shape was built.

Pressing *Return* on the keyboard while editing parameters will automatically show the preview of the shape if there are enough parameters entered to create the shape. Clicking checkboxes will do the same.

The *New* button will remove the current G-Code file and load a blank G-Code file.

The *Save* button opens a dialog allowing the current shape to be saved as a G-Code  file.

The *Settings* button allows changing the global settings.

The *Quit* button will close the Conversational Panel, all edits will be discarded.

The *Send* button will close the Conversational Panel and load the current shape into LinuxCNC. If the last edit was not added then it will be discarded.

The *Preview* button will display a preview of the current shape provide the required information is present.

The *Continue* button is for lines and arcs only and allows another segment to be added to the current segment/segments.

The *Add* button will store the current shape into the current job.

The *Undo* button will revert to the previous stored state. If there have been no edits since the last store then it will stay at the current state.

If there is a G-Code file loaded in LinuxCNC when the Conversational Panel is opened then that code will be imported into conversational as the the first shape of the job. If this code is not required then it can be removed with the New button.

NOTE: All distances are in machine units relative to the current User Coordinate System and all angles are in degrees.

=== Settings

Global settings for the shape library can be set by pressing *Settings* in the Conversational Panel. This will display all the available settings parameters:

* Preamble
* Postamble
* Origin (one of centre or bottom left)
* Lead-in length
* Lead-out length
* Small hole diameter
* Small hole speed
* Window Size

Any internal circle that has a diameter less than *Small hole diameter* is classed as a small hole. It will have a straight lead-in with a length the lesser of the radius of the hole and the specified lead-in length. It will also have its feed rate set to *Small hole speed*.

Pressing the *Save* button will save all the settings as displayed and will change the window size to the displayed size.

=== Single Shape

. Select the shape you wish to create which will display the available parameters.
. Enter the appropriate values and press *Preview* to display the shape.
. If the shape is not correct, edit the values and press *Preview* and the new shape will be displayed. Repeat until you are satisfied with the shape.

=== Lines And Arcs

Lines and arcs have an additional option in that they are able to be strung together to create a complex shape.

There are two line types and three arc types available.

. Line from start point and end point
. Line from start point, length and angle
. Arc from start point, waypoint and end point
. Arc from start point, end point and radius
. Arc from start point, length, angle and radius

To use lines and arcs:

. Select Lines and Arcs
. Select the type of line to create
. Enter the desired parameters
. Preview the shape
. If satisfied with the shape press Continue
. Change the line type if needed and continue this procedure until the shape is complete.

If you wish to create a closed shape then you will need to create any required leadin as the first segment of the shape. If a leadout is required it will need to be the last segment of the shape.

NOTE: At this stage there is no automatic option for a leadin/leadout if the shape is closed. +
It is intended that this will be available in the future as well as kerf width compensation.

=== Group Of Shapes

Multiple shapes can be added together to create a complex group.

The cut order of the group is determined by the order in which the individual shapes are added to the group.

Once a shape is added to the group it cannot be edited or removed.

Groups cannot be edited, only added to.

. Create the first shape as in *Single Shape*.
. Press *Add* and the shape will be added to the group.
. If you wish to add another version of the same shape then edit the required parameters and press *Add* when you are satisfied with the shape.
. If you wish to add a different shape, select that shape and create as in *Single Shape*.
. Repeat until you have added all the required shapes to complete the group. 

=== Rotate

The rotate feature will rotate the current code displayed in the Preview tab, this can be a single shape, a group or an imported G-Code file.

Arrays created with Conversational may be rotated but imported arrays cannot be rotated.

Rotation will not work on G-Code that is mathematically calculated, the values need to be specified.

. Create a shape, a group or use the imported G-Code file.
. Press *Rotate* to open the rotate dialog.
. Enter the appropriate values in the rotate dialog and press *Preview* to display the rotated code.
. If the rotation is not correct, edit the values and press *Preview* and the new rotated code will be shown. Repeat until you are satisfied with the rotated code.
. Press *Add* to complete the procedure.

=== Array

An array can be created from a shape, a group or an imported G-Code file.

Arrays created with Conversational may be arrayed but imported arrays cannot be arrayed.

The cut order of an array is from left to right, starting at the bottom row and ending at the top row.

. Create a shape, a group or use the imported G-Code file.
. Press *Array* to open the array dialog.
. Enter the appropriate values in the array dialog and press *Preview* to display the array.
. If the array is not correct, edit the values and press *Preview* and the new array will be shown. Repeat until you are satisfied with the array.
. Press *Add* to complete the procedure.

=== Saving A Job

The current job displayed in the Preview Panel may be saved at any time by using the bottom *Save* button.

=== Running A Job

To run a job, press the *Finish* button which will close the Conversational Panel and return to LinuxCNC.

[[scribe]]

== Scribe

An scribe may be operated by PlasmaC in addition to the plasma torch, this is disabled by default so as not to affect existing configurations.

Using a scribe requires usage of the LinuxCNC tool table, Tool 0 is assigned to the plasma torch and Tool 1 is assigned to the scribe. The scribe X and Y axes offsets from the plasma torch need to be entered into the LinuxCNC tool table. The plasma torch offsets will always be zero. The tools are selected by the *Tn M6* command then a *G43 H0* is required to apply the offsets. PlasmaC is then started with a *M3 $n S1* command. For *n*, use 0 for plasma cutting or 1 for scribing.

There are two HAL output pins used to operate the scribe, one to arm the scribe which moves the scribe to the surface of the material then after a <<scribe-config, delay>> the other to start the scribe, then after a <<scribe-config, delay>> motion will begin.

Using PlasmaC after enabling the scribe then requires selecting either the torch or the scribe in each G-Code file as a LinuxCNC tool.

To enable scribing, see <<multi-tool, multiple tools>>.

If you have not yet assigned the HAL pins for the scribe in the Configurator then you will need to do so by invoking the <<modify-config, reconfigure>> mode of the Configurator.

The scribe is now active and the arming action may be tested by issuing a *M3 $1 S1* command in the MDI input. This will cause the scribe to arm but will not start the scribe.

The next step is to open the tool table editor in the GUI and enter the X and Y axes offsets. These are the distances in X and Y from the centre of the torch nozzle. In most cases, if standing at the front of the machine if the scribe is to the right of the torch it would be a positive value and if the scribe is to the rear of the torch it would also be a positive value. The offsets for the torch should always be zero.

The final step is to set the <<scribe-config, scribe delays>> required:

. *Arm Delay* allows time for the scribe to descend to the surface of the material.
. *On Delay* allows time for the scribe to start before motion begins.

Save the Config parameters.

The material can then be lined up with the torch as previously and the offsets can be applied so both tools operate at the correct coordinates.

To use the scribe from G-Code:

----
...
M52 P1 (paused motion on)
F#<_hal[plasmac.cut-feed-rate]>
T1 M6 (select scribe)
G43 H0 (apply offsets)
M3 $1 S1 (start plasmac with scribe)
.
.
T0 M6 (select torch)
G43 H0 (apply offsets)
G0 X0 Y0 (parking position)
M5 $1 (end)
----

It is a good idea to switch back to the torch at the end of the program before your final rapid parking move so your machine is always in the same state at idle.

You can switch between the torch and the scribe any number of times during a program by using the above code and issuing *M3 $0 S1* to start PlasmaC with the torch.

Issuing M3 S1 (without $n) will cause the machine to behave as if an *M3 $0 S1* had been issued and issuing M5 (without $n) will cause the machine to behave as if an *M5 $0* had been issued, so the machine will attempt a torch cut. This is to provide compatibility for previous G-Code files.

WARNING: If you have an existing manual toolchange in your machine .hal file then PlasmaC will convert it to an automatic toolchange.

[[spotting]]

== Spotting

To achieve spotting prior to drilling etc, PlasmaC can pulse the torch for a short duration to mark the drill spot.

This is done by first setting the arc voltage threshold in the <<config-panel, Config Panel>>. If the threshold voltage is set to zero then the delay timer will begin from when the torch on signal was sent. If the threshold voltage is set above zero then the delay timer will begin when the arc voltage reaches the threshold voltage.

Then set the delay time in the <<config-panel, Config Panel>>. When the delay is complete, the torch will turn off. Times are adjustable from 0 to 9999 milli-seconds.

The torch is then turned on in G-Code with the *M3 $2 S1* command which selects the plasma torch as a spotting tool.

To enable spotting, see <<multi-tool, multiple tools>>.

LinuxCNC requires some motion between an *M3* command and a *M5* command so a minimal movement at a high speed is programmed.

An example G-Code is:

----
G21 (metric)
F99999 (high feed rate)
.
.
G0 X10 Y10
M3 $2 S1 (spotting on)
G91 (relative distance mode)
G1 X0.000001
G90 (absolute distance mode)
M5 $2 (spotting off)
.
.
G0 X0 Y0
G90
M2
----

NOTE: The *high feed rate* is to ensure that the motion is at the machines highest feed rate.

IMPORTANT: SOME PLASMA CUTTERS WILL NOT BE SUITABLE FOR THIS FEATURE. +
IT IS RECOMMENDED THAT YOU CARRY OUT SOME TEST SPOTTING TO ENSURE THAT YOUR PLASMA CUTTER IS CAPABLE OF UTILISING THIS FEATURE.

== Error Messages

There are a number of error messages printed by PlasmaC. They could probably be split into two groups, *Critical* and *Warning*.

=== Critical Errors

Critical errors will cause the program to pause, the operator needs to clear the cause of the error.

If the error was during cutting then forward or reverse motion is allowed to enable the machine to be positioned to recommence the cut.

When the error is cleared the program may be resumed.

These errors indicate the corresponding sensor was activated during cutting.

* *breakaway switch activated program is paused*
* *float switch activated program is paused*
* *ohmic probe activated program is paused*
* *valid arc lost program is paused*

These errors indicate the corresponding sensor was activated before probing commenced.

* *ohmic probe detected before moving to probe height program is paused*
* *float switch detected before moving to probe height program is paused*
* *breakaway switch detected before moving to probe height program is paused*

The Z axis reached the bottom limit before the workpiece was detected.

* *bottom limit reached while probing down program is paused*

The workpiece is too high for any safe rapid removes.

* *material too high for safe traverse program is paused*

One of these values in Cut Parameters in the Run Panel is invalid.

* *invalid pierce height or invalid cut height or invalid cut volts*

No arc has been detected after attempting to start the number of times indicated by Arc Start Attempts in the Config Panel.

* *no arc detected after <n>d start attempts program is paused*

THC has caused the bottom limit to be reached while cutting.

* *bottom limit reached while THC moving down program is paused*

THC has caused the top limit to be reached while cutting.

* top limit reached while THC moving up program is paused*


=== Warning errors

Warning errors have no effect on a running program and are informational only.

These errors indicate the corresponding sensor was activated before a probe test commenced.

* *ohmic probe detected before moving to probe height*
* *float switch detected before moving to probe height*
* *breakaway switch detected before moving to probe height*

This indicates that probe contact was lost before probing up to the zero point.

* *probe trip error while probing*

This indicates the bottom limit was reached during a probe test.

* *bottom limit reached while probe testing*

This indicates that the safe height has been reduced due to THC raising the Z axis during cutting.

* *safe traverse height has been reduced*

== INI File

PlasmaC requires some specific .ini file variables as follows:

=== Common

[[ini-mode]]

*[PLASMAC]* Section

----
MODE                = 0 (use external arc voltage in for Arc Voltage)
                        (use external arc voltage in for Arc OK)
                    = 1 (use external arc voltage in for Arc Voltage)
                        (use external arc ok in for Arc OK)
                    = 2 (Use external arc ok in for Arc OK)
                        (use external up/down for THC)

CONFIG_DISABLE      = 0 (0=enable or 1=disable the PlasmaC Config Panel)
PAUSED-MOTION-SPEED = n (multiply cut-feed-rate by this value for paused motion speed)
TORCH-PULSE-TIME    = n (torch on time when manual pulse requested)
BUTTON_n_NAME       = <NAME> (the name of a custom user buttons)
BUTTON_n_CODE       = <CODE> (the code run by a custom user button)
BUTTON_n_IMAGE      = <IMAGE> (the image displayed by buttons 10~19)
----

*[FILTER]* Section

----
PROGRAM_EXTENSION       = .ngc (filter gcode files)
ngc                     = ./plasmac/plasmac_gcode.py
nc                      = ./plasmac/plasmac_gcode.py
tap                     = ./plasmac/plasmac_gcode.py
----

[[rs274]]

*[RS274NGC]* Section

----
RS274NGC_STARTUP_CODE = o<metric_startup> call (machine startup G-Code)
SUBROUTINE_PATH       = ./:./plasmac:../../nc_files/subroutines (./ must be in this path)
FEATURES              = 12 (for reading .ini and HAL variables)
USER_M_PATH           = ./:./plasmac (for M190 material change)
----

IMPORTANT: SEE <<path-tolerance, PATH TOLERANCE>>

*[HAL]* Section

----
TWOPASS = on (needed for multiple .hal files)
HALFILE = <machine_name>.hal (your base machine .hal file)
HALFILE = plasmac.tcl (the standard PlasmaC .hal file )
HALFILE = <machine_name>_connections.hal (PlasmaC connections to the machine)
HALFILE = HALUI   = halui (required)
----

The <machine_name>.hal file has *num_spindles=[TRAJ]SPINDLES* appended to the end of the *loadrt motmod* line to allow the addition of an <<scribe, scribe>> if required.

NOTE: You could place custom HAL commands in <machine_name>_connections.hal as this file is not overwritten by an upgrade.

*[TRAJ]* Section

----
SPINDLES = 3
----

*[AXIS_X]* Section

----
MAX_VELOCITY     = double the value in the corresponding joint
MAX_ACCELERATION = double the value in the corresponding joint
OFFSET_AV_RATIO  = 0.5
----

*[AXIS_Y]* Section

----
MAX_VELOCITY     = double the value in the corresponding joint
MAX_ACCELERATION = double the value in the corresponding joint
OFFSET_AV_RATIO  = 0.5
----

*[AXIS_Z]* Section

----
MIN_LIMIT        = the top of your slats or just below
MAX_VELOCITY     = double the value in the corresponding joint
MAX_ACCELERATION = double the value in the corresponding joint
OFFSET_AV_RATIO  = 0.5
----

NOTE: PlasmaC uses the External Offsets feature for all Z axis motion, and for moving the X and/or Y axis for a consumable change while paused, for more information on this feature, please read <<cha:external-offsets,External Axis Offsets>> in the Linuxcnc documentation.

[[axis-ini]]

=== Axis GUI Specific

*[PLASMAC]* Section

----
FONT        = sans 10 (valid font sizes are from 9 to 15 inclusive)
THEME       = Clearlooks (any installed theme, only for the plasmac tabs)
WINDOW_SIZE = 0 (0 = minimum size to suit font, 1 = maximised, width x height = custom size)
AXIS_ORIENT = portrait
----

Defaults for the above if they are not specified are:

----
FONT        = sans 10
THEME       = current system theme
WINDOW_SIZE = minimum size to suit font
AXIS_ORIENT = landscape
----

Changing the FONT size changes the minimum window size. PlasmaC requires a larger window size than the standard Axis window. Window size varies depending on whether you have the Run Panel as a Tab or a Panel on the right side. If using portrait mode then window height will vary depending on whether or not you have a rotary axis. If the window doesn't completely fit in the screen then you will need to reduce the font size.

Custom window size is specified as width x height e.g. 1600 x 900. Spaces are ignored but may be used for readability and *x* may be lower or upper case.

NOTE: WINDOW_SIZE has replaced MAXIMISED. For backwards compatibility these names are interchangeable.

[[axis-display-section]]

*[DISPLAY]* Section

----
TOOL_EDITOR       = tooledit x y
USER_COMMAND_FILE = plasmac_axis.py.py

EMBED_TAB_NAME    = Statistics
EMBED_TAB_COMMAND = gladevcp -c plasmac_stats -x <XID> -u ./plasmac/plasmac_stats.py -H ./plasmac/plasmac_stats.hal ./plasmac/plasmac_stats.glade

#use one of the next two

#run frame in tab behind preview
EMBED_TAB_NAME    = Plasma Run
EMBED_TAB_COMMAND = gladevcp -c plasmac_run -x <XID> -u ./plasmac/plasmac_run.py -H ./plasmac/plasmac_run.hal ./plasmac/plasmac_run_tab.glade

#run frame in panel on left side
#GLADEVCP = -c plasmac_run -u ./plasmac/plasmac_run.py -H ./plasmac/plasmac_run.hal ./plasmac/plasmac_run_panel.glade

EMBED_TAB_NAME    = Plasma Config
EMBED_TAB_COMMAND = gladevcp -c plasmac_config -x <XID> -u ./plasmac/plasmac_config.py -H ./plasmac/plasmac_config.hal ./plasmac/plasmac_config.glade

EMBED_TAB_NAME    = Extras
EMBED_TAB_COMMAND = gladevcp -c plasmac_wizards -x {XID} -u ./plasmac/plasmac_wizards.py ./plasmac/plasmac_wizards.glade

----

The Run Window can be displayed as one of:

* A panel on the right side of the Axis GUI which is suitable for widescreen displays.
* A tab behind the Preview tab which is suitable for 4:3 ratio displays.

=== Gmoccapy GUI Specific

[[gmoccapy-display-section]]

*[DISPLAY]* section

----
EMBED_TAB_NAME     = plasmac_buttons
EMBED_TAB_LOCATION = box_cooling
EMBED_TAB_COMMAND  = gladevcp -c plasmac_buttons -x <XID> -u ./plasmac/plasmac_buttons.py -H ./plasmac/plasmac_buttons.hal ./plasmac/plasmac_buttons.glade
EMBED_TAB_NAME     = plasmac_control
EMBED_TAB_LOCATION = box_spindle
EMBED_TAB_COMMAND  = gladevcp -c plasmac_control -x <XID> -u ./plasmac/plasmac_control.py -H ./plasmac/plasmac_control.hal ./plasmac/plasmac_control.glade
EMBED_TAB_NAME     = Statistics
EMBED_TAB_LOCATION = ntb_preview
EMBED_TAB_COMMAND  = gladevcp -c plasmac_stats -x <XID> -u ./plasmac/plasmac_stats.py -H ./plasmac/plasmac_stats.hal ./plasmac/plasmac_stats.glade
EMBED_TAB_NAME     = Plasma Run

#use one of the next two

#run panel in tab behind preview
EMBED_TAB_LOCATION  = ntb_preview
EMBED_TAB_COMMAND   = gladevcp -c plasmac_run -x <XID> -u ./plasmac/plasmac_run.py -H ./plasmac/plasmac_run.hal ./plasmac/plasmac_run_tab.glade

#run panel in panel on left side
#EMBED_TAB_LOCATION = box_left
#EMBED_TAB_COMMAND  = gladevcp -c plasmac_run -x <XID> -u ./plasmac/plasmac_run.py -H ./plasmac/plasmac_run.hal ./plasmac/plasmac_run_panel.glade

EMBED_TAB_NAME     = Plasma Config
EMBED_TAB_LOCATION = ntb_preview
EMBED_TAB_COMMAND  = gladevcp -c plasmac_config -x <XID> -u ./plasmac/plasmac_config.py -H ./plasmac/plasmac_config.hal ./plasmac/plasmac_config.glade
EMBED_TAB_NAME     = plasmac_monitor
EMBED_TAB_LOCATION = box_tool_and_code_info
EMBED_TAB_COMMAND  = gladevcp -c plasmac_monitor -x <XID> -u ./plasmac/plasmac_monitor.py -H ./plasmac/plasmac_monitor.hal ./plasmac/plasmac_monitor.glade

EMBED_TAB_NAME     = Extras
EMBED_TAB_LOCATION = ntb_preview
EMBED_TAB_COMMAND  = gladevcp -c plasmac_wizards -x {XID} -u ./plasmac/plasmac_wizards.py ./plasmac/plasmac_wizards.glade

----

The Run Panel can be displayed as one of:

* A panel on the left side of the Gmoccapy GUI which is suitable for widescreen displays.
* A tab behind the Preview tab which is suitable for 4:3 ratio displays.

[[custom-user-buttons]]

== Custom User Buttons

There are buttons available that are programmable in the .ini file.

Five buttons are available in the main window of the Axis GUI, numbered 1~5 from left to right.

Four buttons are available in the main window of the Gmoccapy GUI, numbered 1~4 from top to bottom.

An additional ten buttons are available in the Extras panel, numbered 10~19 from top left to bottom right.

All .ini file settings for the buttons are in the [PLASMAC] section.

=== Button Names

The text that appears on the button is set the following way:

----
BUTTON_n_NAME = HAL Show
----

Where n is the button number and *HAL Show* is the text.

For text on multiple lines in Axis, split the text with a \

----
BUTTON_n_NAME = HAL\Show
----

=== Button Code

Buttons can run <<button-cmds, External Commands>>, <<button-code, G-Code>> or any of four special functions, <<button-probe, Probe Test>>, <<button-ohmic, Ohmic Test>>, <<button-cut, Cut Type>> or <<button-consumables, Change Consumables>>. In addition to this, buttons 10~19 in the Extras panel can run the special function <<button-recovery, cut-recovery>>, <<button-load, load a G-Code>> program or display a custom image.

[[button-cmds]]

[underline]*External Commands*

To run an external command, the command is preceded by a % character.

----
BUTTON_n_CODE = %halshow
----

[[button-code]]

[underline]*G-Code*

To run G-Code, just enter the code to be run.

----
BUTTON_n_CODE = G0 X100
----

To run an existing subroutine.

----
BUTTON_n_CODE = o<my_subroutine> call
----

.ini file variables can be entered by using {} (you must put a space after the })

----
BUTTON_n_CODE = G0 X{JOINT_0 HOME} Y1
BUTTON_n_CODE = G53 G0 Z[{AXIS_Z MAX_LIMIT} - 1.001]
----

Multiple codes can be run by separating the codes with a \

----
BUTTON_n_CODE = G0 X0 Y0 \ G1 X5 \ G1 Y5
----

External commands and G-Code may be mixed on the same button.

----
BUTTON_n_CODE = %halshow \ g0x.5y.5 \ %halmeter
----

[[button-probe]]

[underline]*Probe Test*

----
BUTTON_n_CODE = probe-test 30
----

PlasmaC will begin a probe and when the probe is detected, the Z axis will rise to the Pierce Height currently displayed in the Run Panel. It will then wait in this state for the time specified (in this case 30 seconds) then it will return the Z axis to the top.

[[button-ohmic]]

[underline]*Ohmic Test*

----
BUTTON_n_CODE = ohmic-test
----

PlasmaC will enable the Ohmic Probe Enable and if the ohmic probe is sensed, the LED indicator in the monitor panel will light. The main purpose of this is to allow a quick test for a shorted torch tip.

[[button-cut]]

[underline]*Cut Type*

----
BUTTON_n_CODE = cut-type
----

This button if selected will toggle between the two <<cut-types, cut types>>.

[[button-consumables]]

[underline]*Change Consumables*

----
BUTTON_n_CODE = change-consumables X10 Y10 F1000
----

This button moves the torch to the specified coordinates when the machine is paused to allow easy access to change consumables.

Valid entries are Xnnn Ynnn Fnnn. F is mandatory and at least one of X or Y are required.

The X and Y entries are in absolute machine coordinates. If X or Y are missing then the current coordinate for that axis is used.

There are three methods to return to the previous coordinates:

- Press the button again and the torch will return and the machine will wait for a resume command.
- Resume the program which causes the torch to return then the program will begin running.
- Stop the program which causes the torch to return then the program will abort.

[[button-recovery]]

[underline]*Cut Recovery*

----
BUTTON_n_CODE = cut-recovery
----

This brings up the <<cut-recovery, cut recovery>> dialog which allows the torch to move away from the cut to find a good piece of material to restart the cut from. This function is only available from the Extras panel and is only valid while paused.

[[button-load]]

[underline]*Load*

Buttons 10~19 in the Extras Panel are able to load a G-Code program by using the following format.

----
BUTTON_n_CODE = load path/to/G-Code.ngc
----

The path is relative to the directory specified by *PROGRAM_PREFIX* in the .ini file. This is usually ~/linuxcnc/nc_files, so if your G-Code file was in a subdirectory of your *PROGRAM_PREFIX* directory named *plasma* then the entry would be *plasma/G-Code.ngc*.

=== Button Image

Buttons 10~19 in the Extras Panel are able to display an image by using the following format. If an image is specified then this will take precedence and the image will be displayed rather than the button name.

----
BUTTON_n_IMAGE = path/to/image.png
----

The path is relative to the configuration directory, so if your image was in a subdirectory of your configuration directory named *images* then the entry would be *images/image.png*.

All images are displayed in a 60 x 60 format.

[[material-file]]

== Material File

PlasmaC uses a file containing cut parameters for materials. This file is used for <<material-handling, material handling>>.

The file name is derived from *[EMC]MACHINE* in the in file, so a machine named *METRIC_PLASMAC* would have a material file named *metric_plasmac_material.cfg*.

The following variables are mandatory and an error message will appear if any are not found when the material file is loaded.

* PIERCE_HEIGHT
* PIERCE_DELAY
* CUT_HEIGHT
* CUT_SPEED

The following variables are optional. If any are not detected or have no value assigned, they will be assigned a value of 0 and no error message will appear.

* NAME
* KERF_WIDTH
* THC
* PUDDLE_JUMP_HEIGHT
* PUDDLE_JUMP_DELAY
* CUT_AMPS
* CUT_VOLTS
* PAUSE_AT_END
* GAS_PRESSURE
* CUT_MODE

WARNING: It is the responsibility of the operator to ensure that the variables are included if they are a requirement for the G-Code to be run.

The material file uses the following format:

----
[MATERIAL_NUMBER_1]
NAME                = name
KERF_WIDTH          = value
THC                 = value (0 = off, 1 = on)
PIERCE_HEIGHT       = value
PIERCE_DELAY        = value
PUDDLE_JUMP_HEIGHT  = value
PUDDLE_JUMP_DELAY   = value
CUT_HEIGHT          = value
CUT_SPEED           = value
CUT_AMPS            = value (for info only unless Powermax communications is enabled)
CUT_VOLTS           = value (modes 0 & 1 only, if not using auto voltage sampling)
PAUSE_AT_END        = value
GAS_PRESSURE        = value (only used for Powermax communications)
CUT_MODE            = value (only used for Powermax communications)
----

It is possible to add new material, delete material or edit existing material from the <<run-buttons, Run Panel.>>

It is also possible to edit the material file with a text editor while LinuxCNC is running and then after any changes have been saved, press *Reload* in the Run Panel to reload the material file.

== Example Configurations

There are example configuration files for both the Axis and Gmoccapy GUIs which use the PlasmaC HAL component to simulate plasma cutting machines.

* metric_plasmac.ini
* imperial_plasmac.ini

If you have copied any example configs to your ~/linuxcnc/configs directory then they are able to be updated by running the Configurator in Upgrade mode. This will replace any copied plasmac system file with a link to the latest version you have upgraded to.

== NGC Samples

There are some sample G-Code files in nc_files/plasmac.

== Test Panel

There is a ./test directory in the source which has a simple Test Panel and associated python file which can be used to test the example configuration as referenced in the .ini file.

If you wish to use this in your own sim configuration then you will need to create a link to this directory and edit your .ini file to suit.

== Upgrade An Existing LinuxCNC Configuration

The method of upgrading is dependent on the type of LinuxCNC installation:

=== Upgrade LinuxCNC

From a terminal:

----
$ sudo apt-get update
$ sudo apt-get dist-upgrade
----

== Upgrade PlasmaC

=== Automatic Upgrade

After you have upgraded LinuxCNC, PlasmaC will test if it needs an upgrade when LinuxCNC is started. If it finds that it needs upgrading it will automatically proceed with the upgrade. After the upgrade is complete you may get a warning that LinuxCNC needs to be restarted. This depends on which files needed changing.

=== Manual Upgrade

If you do not wish to allow PlasmaC to do automatic upgrades then you can prevent this by adding *MANUAL_UPGRADE = 1* to the [PLASMAC] section of the .ini file:

----
MANUAL_UPGRADE            = 1
----

You would then need to manually upgrade PlasmaC by opening a terminal and running the configurator:

----
$ python linuxcnc/<your_configuration_directory>/configurator.py
----

The selection window is now visible:

image::images/plasmac_configurator_home_used.png[width=30%]

Select *Upgrade* from the selection window, this shows an info dialog, select *Continue* and the Upgrade window will display.

image::images/plasmac_configurator_upgrade.png[width=40%]

Select the .ini file of the PlasmaC configuration you wish to upgrade, click *Upgrade* and your PlasmaC configuration will be upgraded.

[[modify-config]]

== Reconfigure An Existing PlasmaC Configuration

The Configurator is only able to modify:

* The HAL pins connecting PlasmaC to the machine.
* The mode used by PlasmaC.
* The position of the Run Panel in the GUI.

Reconfiguring a Plasmac configuration is done from the Configurator which is located in your configuration directory.

To start the configurator open a terminal and enter:

----
$ python linuxcnc/<your_configuration_directory>/configurator.py
----

The selection window is now visible:

image::images/plasmac_configurator_home_used.png[width=30%]

Select *Reconfigure* from the selection window, this shows an info dialog, select *Continue* and the Reconfigure window will display.

image::images/plasmac_configurator_reconfigure.png[width=40%]

Select the .ini file of the PlasmaC configuration you wish to reconfigure.

If you change modes then you will notice that entry boxes change depending on the currently selected mode.

When all entries are correct, click *Reconfigure* and your PlasmaC configuration will be reconfigured.

Entry descriptions can be found <<configurator-table, here>>

NOTE: Machine Name and .hal File can not be modified.

== Change Type Of LinuxCNC Installation

If you have changed the type of LinuxCNC installation from Buildbot to Run In Place or vice versa you will need to run the Configurator from the new LinuxCNC installation directory, NOT from the ~/linuxcnc/configs directory. This is required to reset the file links for the correct installation type.

From a terminal do one of the following:

Reset to a new Buildbot installation:

----
$ python /usr/share/doc/linuxcnc/examples/sample-configs/by_machine/plasmac/configurator.py
----

Reset to a new Run In Place installation:

----
$ python ~/linuxcnc-dev/configs/by_machine/plasmac/configurator.py
----

== Materialverter

This application is used to convert existing tool tables into PlasmaC material files it can also create a material file from manual user input to entry fields.

At this stage the only conversions available are from SheetCam and Fusion360.

Sheetcam tool tables are complete and the conversion is fully automatic. The SheetCam tool file must be in the SheetCam .tools format.

Fusion360 tool tables do not have all required fields so the user is prompted for missing parameters. The Fusion360 tool file must be in the Fusion360 .json format.

If you have a format you would like converted, create a *New Topic* in the https://forum.linuxcnc.org/plasmac[PlasmaC forum] section of the https://forum.linuxcnc.org/[LinuxCNC forum].

Materialverter may be run from a GUI file manager by double clicking on *materialverter.py* in your configuration directory or may be run from a terminal with the following command:

----
$ python ~/linuxcnc/configs/<machine_name>/materialverter.py
----

This will bring up the materialverter dialog:

image::images/plasmac_material_main.png[width=30%]

Select one of:

* Manual - to manually create a new material file.
* SheetCam - to convert a SheetCam tool file.
* Fusion360 - to convert a Fusion360 tool file.

For SheetCam only, select whether you would like a metric or imperial output file.

For a conversion, select the Input File you wish to have converted.

Select the Output File you wish to write to, this would normally be ~/linuxcnc/configs/<machine_name>_material.cfg, although you could select a different file and hand edit your <machine_name>_material.cfg file.

Click Create/Convert and your new material file will be created.

For a Manual creation or a Fusion360 conversion a dialog will show with all available parameters displayed for input. Any entry marked with pass:[***] is mandatory and all other entries are optional depending on your configuration.

image::images/plasmac_material_dialogs.png[width=40%]

NOTE: If you select ~/linuxcnc/configs/<machine_name>_material.cfg then if this file already exists it will be overwritten.


[[pm_comms]]

== Hypertherm Powermax Communications

Communications can be established with a Hypertherm Powermax plasma cutter that has a RS485 port. This then enables the setting of *Cut Mode*, *Cutting Amperage* and *Gas Pressure* automatically from the *Cut Parameters* of the material file.

If Gas Pressure is set to Zero then the Powermax will automatically calculate the required pressure from the Cut Mode, Cut Current, torch type and torch length.

Changing the cutting mode will set the gas pressure to zero causing the machine to use its automatic gas pressure mode.

The maximum and minimum values of these parameters are read from the plasma cutter and the related spin-buttons in the Cut Parameters are then limited by these values. Gas pressure can not be changed from zero until communications have been established.

This feature is enabled by setting the correct port name for the PM_PORT variable in the [PLASMAC] section of the .ini file. If the PM_PORT variable is not set in the .ini file then the widgets associated with this feature will not be visible.

----
[PLASMAC]
PM_PORT = /dev/ttyusb0
----

If you are unsure of the name of your port there is a python script in the configuration directory that will show all available ports and can also be used to test communications with the plasma unit prior to using this feature in PlasmaC. To use the test script enter the following in a terminal.

----
$ python ~/user/linuxcnc/configs/<your_config>/pmx_test.py
----

The gas pressure units display, either psi or bar, is determined by the data received during initial setup of the communication link and is then shown next to the Gas Pressure spinbutton on the Run Panel.


The Powermax machine will go into remote mode after communications have been established and will be controlled remotely. The connection can be validated by observing the Powermax display.

To switch the Powermax back to local mode you can either:

.  Disable Powermax Comms from the Run panel
.  Close LinuxCNC which will put the Powermax into local mode during shutdown.
.  Powerdown the Powermax for 30 seconds and then power it back on.

TIP: If Powermax communications is active then selecting <<mesh-mode, Mesh Mode>> will automatically select CPA mode in the Powermax unit.

NOTE: To use the Powermax communictions feature it is necessary to have the python pyserial module installed. +
If pyserial is not installed an error message will be displayed.

To install pyserial, type the following in a terminal:

----
sudo apt-get install python-serial
----

A typical <<rs485_connections, connection diagram>> is shown in the appendix of this document as well as confirmed working interfaces.


[[mesa-thcad]]

== Mesa THCAD

The Mesa THCAD is the most common way of obtaining the arc voltage from a plasma cutter. The THCAD may be used for parallel port configs or for configs using other Mesa Electronics hardware.

The preferred method is to setup the required parameters for the THCAD in your <machine_name>.hal file.

=== Parallel Port Config

An example parallel port config using a link:http://linuxcnc.org/docs/html/man/man9/encoder.9.html[software encoder].

THCAD jumper settings *UNIPOLAR* and *F/64*

NOTE: If your computer has good latency then you may be able to use *F/32*

----
loadrt encoder num_chan=1
setp encoder.0.counter−mode 1
setp encoder.0.position−scale -1
addf encoder.update-counters base-thread
addf encoder.capture-position servo-thread
net arc-voltage-raw parport.1.pin-04-in encoder.0.phase-A
----

You then need to note that the *Arc Voltage HAL Pin* entry in the PlasmaC Configurator will be:

----
encoder.0.velocity
----

=== Mesa 7i96 Config:

An example Mesa 7i96 config using the onboard hardware encoder. Other Mesa hardware will be similar but with a different board identifier.

THCAD jumper settings *UNIPOLAR* and *F/32*

----
setp  hm2_7i96.0.encoder.00.scale -1
setp  hm2_7i96.0.encoder.00.filter 1
setp  hm2_7i96.0.encoder.00.counter-mode 1
----

You then need to note that the *Arc Voltage HAL Pin* entry in the PlasmaC Configurator will be:

----
hm2_7i96.0.encoder.00.velocity
----

NOTE: There is a <<lowpass, lowpass filter>> available which may be useful if using a THCAD and there is a lot of noise on the returned arc voltage.

=== Obtaining The Divider Ratio

[underline]*THCAD-10*

If connecting to a plasma CNC port then the divider ratio is selected from the plasma machine.

If connecting to the plasma machines full arc voltage then a common setup is a 1 megOhm resistance from arc negative to THCAD negative and a 1 megOhm resistance from arc positive to THCAD positive. This gives a full scale reading of 210V. The THCAD can handle over-voltages up to 500V so this is not a problem.

To get the divider ratio use (R1 + R2 + 100000) / 100000 so for the above it would be (1000000 + 1000000 + 100000) / 100000 giving a ratio of 21.

IMPORTANT: IF YOU ARE USING A HF START PLASMA POWER SUPPLY THEN EACH OF THESE RESISTANCES SHOULD BE MADE UP OF SEVERAL HIGH VOLTAGE RESISTORS.

[underline]*THCAD-300*

This is connected to the plasma machines full arc voltage and the divider ratio = 1

=== Calibration Values

This is to obtain the starting values for Voltage Offset and Voltage Scale in the Config Panel.

If you look at the rear of the THCAD you will see a calibration sticker with:

----
    THCAD-nnn
                 
 0V  121.1 kHz
 5V  925.3 kHz
----

or similar values, these are the frequencies generated by the THCAD for 0 volts and full scale volts respectively.

You can now calculate the values as shown below or use https://jscalc.io/calc/NTr5QDX6WgMThBVb[this online calulator]

[underline]*Voltage Scale*

Use the formula:

----
Divider_Ratio / ((THCAD_Full_Scale_Frequency - THCAD_0V_Frequency) / THCAD_Frequency_Divider / THCAD_Full_Scale_Voltage)
----

This result will be used for setting *Voltage Scale* in the Config Panel when setting up the configuration.

THCAD-10 example with a jumper setting of F/32 would be:

----
21 / ((925300 - 121100) / 32 / 10) = 0.00835613
----

For our calculation above, we used 21 from our divider calculation, 32 from the jumper setting *F/32* and 10 which is the full scale reading of the THCAD card itself.

THCAD-300 example would be:

----
1 / ((925300 - 121100) / 32 / 300) = 0.01193732
----

For our calculation above, we used 1 as our divider ratio, 32 from the jumper setting *F/32* and 300 which is the full scale reading of the THCAD card itself.


[underline]*Voltage Offset*

Use the formula:

----
THCAD_0V_Frequency / THCAD_Frequency_Divider
----

This result will be used for setting *Voltage Offset* in the Config Panel when setting up the configuration.

The THCAD-10 and THCAD-300 examples above would be:

----
121100 / 32 = 3784.375
----


== Support

On line help and support are available from the https://forum.linuxcnc.org/plasmac[PlasmaC forum] section of the https://forum.linuxcnc.org/[LinuxCNC forum].

== Appendix


=== Plasmac Specific Gcodes

[width="100%",cols="1,2"]
|===
|*Description*|*Code*
|Begin <<multi-tool, cut>>
   |M3 $0 S1
|End <<multi-tool, cut>>|M5 $0
|Begin <<scribe, scribe>>
   |M3 $1 S1
|End <<scribe, scribe>>
   |M5 $1
|Begin <<spotting, centre spot>>
   |M3 $2 S1
|End <<spotting, centre spot>>
   |M5 $0
|End all the above
   |M5 $-1 
|Select a <<material-handling, material>>
   |M190 Pn +
    n denotes material number
|Wait for <<material-handling, material>> change confirmation
   |M66 P3 L3 Q1 +
    Q1 is number of seconds to wait, 
    may need to be increased for very 
    large material files
|Set feed rate from <<material-handling, material>>
   |F#<_hal[plasmac.cut-feed-rate]>
|Disable <<thc, THC>>
   |M62 P2 (synchronised with motion) +
    M64 P2 (immediate)
|Enable <<thc, THC>>
   |M63 P2 (synchronised with motion) +
    M65 P2 (immediate)
|Disable <<overcut, Torch>>
   |M62 P3 (synchronised with motion) +
    M64 P3 (immediate)
|Enable <<overcut, Torch>>
   |M63 P3 (synchronised with motion) +
    M65 P3 (immediate)
|Set <<velocity_thc, velocity>> to a percentage of feed rate
   |M67 E3 Qn (synchronised with motion) +
    M68 E3 Qn (immediate) +
    n is the percentage to set +
    10 is the minimum, below this will set to 100% +
    *It is recommended to have M68 E3 Q0 in preamble and postamble*
|Cutter <<cutter-compensation, compensation>> - left of path
   |G41.1 D#<_hal[plasmac_run.kerf-width-f]>
|Cutter <<cutter-compensation, compensation>> - right of path
   |G42.1 D#<_hal[plasmac_run.kerf-width-f]>
|Cutter <<cutter-compensation, compensation>> off
   |G40 +
    *Note that M62 through M68 are invalid while cutter compensation is on*
|Cut <<hole-cutting, holes>> at 60% feed rate
   |#<holes> = 1 +
    for holes less than 32mm (1.26") diameter
|Cut <<hole-cutting, holes>> at 60% feed rate, +
turn torch off at hole end, + 
continue hole path for overcut
   |#<holes> = 2 +
    for holes less than 32mm (1.26") diameter
    overcut length = 4mm (0.157")
|Cut <<hole-cutting, holes>> and arcs at 60% feed rate
   |#<holes> = 3 +
    for holes less than 32mm (1.26") diameter +
    for arcs less than 16mm (0.63") radius
|Cut <<hole-cutting, holes>> and arcs at 60% feed rate, +
turn torch off at hole end, + 
continue hole path for overcut
   |#<holes> = 4 +
    for holes less than 32mm (1.26") diameter +
    for arcs less than 16mm (0.63") radius +
    overcut length = 4mm (0.157")
|Specify <<hole-cutting, hole>> diameter for +
#<holes> = 1 ~ 4
   |#<h_diameter> = n (use the same units system as the rest of the G-Code file)
|Specify <<hole-cutting, hole>> velocity for +
#<holes> = 1 ~ 4
   |#<h_velocity> = n (set the percentage of the current feed rate)
|Specify <<overcut, overcut>> length
   |#<oclength> = n (use the same units system as the rest of the G-Code file)
|Specify <<cut-types, pierce-only>> mode
   |#<pierce-only> = n (0=normal cut mode, 1=pierce only mode)
|Enable <<ignore-ok, Ignore Arc OK>>
   |M62 P1 (synchronised with motion) +
    M64 P1 (immediate)
|Disable <<ignore-ok, Ignore Arc OK>>
   |M63 P1 (synchronised with motion) +
    M65 P1 (immediate)
|Create or edit materials. +
options: +
1 - Create temporary default +
2 - Add if not existing +
3 - Overwrite if existing else add new +
   |mandatory parameters: +
    (o=<option>, nu=<nn>, na=<ll>, ph=<nn>, pd=<nn>, ch=<nn>, fr=<nn>) +
    optional parameters: +
    kw=<nn>, th=<nn>, ca=<nn>, cv=<nn>, pe=<nn>, gp=<nn>, cm=<nn>, jh=<nn>, jd=<nn>
|===

=== Plasmac Gcode Examples

[width="100%",cols="1,2"]
|===
|*Description*|*Example*
|Select material and do a normal cut
   |M190 P3 +
    M66 P3 L3 Q1 +
    F#<_hal[plasmac.cut-feed-rate]> +
    M3 $0 S1 +
    . +
    . +
    M5 $0
|Set velocity to 100% of CutFeedRate
   |M67 E3 Q0 or M67 E3 Q100
|Set velocity to 40% of CutFeedRate
   |M67 E3 Q60
|Set velocity to 40% of CutFeedRate
   |M67 E3 Q40
|Cut a hole with 60% reduced speed using velocity setting
   |G21 (metric) +
    G64 P0.05 +
    M52 P1 (allow paused motion) +
    F#<_hal[plasmac.cut-feed-rate]> +
    G0 X10 Y10 +
    M3 $0 S1 (start cut) +
    G1 X0 +
    M67 E3 Q60 (reduce feed rate to 60%) +
    G3 I10 (the hole) +
    M67 E3 Q0 (restore feed rate to 100%) +
    M5 $0 (end cut) +
    G0 X0 Y0 +
    M2 (end job)
|Cut a hole with 60% reduced speed using the #<holes> command
   |G21 (metric) +
    G64 P0.05 +
    M52 P1 (allow paused motion) +
    \#<holes> = 1 (velocity reduction for holes) +
    F#<_hal[plasmac.cut-feed-rate]> +
    G0 X10 Y10 +
    M3 $0 S1 (start cut) +
    G1 X0 +
    G3 I10 (the hole) +
    M5 $0 (end cut) +
    G0 X0 Y0 +
    M2 (end job)
|Cut a hole with overcut using torch disable
   |G21 (metric) +
    G64 P0.05 +
    M52 P1 (allow paused motion) +
    F#<_hal[plasmac.cut-feed-rate]> +
    G0 X10 Y10 +
    M3 $0 S1 (start cut) +
    G1 X0 +
    M67 E3 Q60 (reduce feed rate to 60%) +
    G3 I10 (the hole) +
    M62 P3 (turn torch off) +
    G3 X0.8 Y6.081 I10 (continue motion for 4mm) +
    M63 P3 (allow torch to be turned on) +
    M67 E3 Q0 (restore feed rate to 100%) +
    M5 $0 (end cut) +
    G0 X0 Y0 +
    M2 (end job) +
|Cut a hole with overcut using the #<holes> command
   |G21 (metric) +
    G64 P0.05 +
    M52 P1 (allow paused motion) +
    \#<holes> = 2 (overcut for holes) +
    F#<_hal[plasmac.cut-feed-rate]> +
    G0 X10 Y10 +
    M3 $0 S1 (start cut) +
    G1 X0 +
    G3 I10 (the hole) +
    M5 $0 (end cut) +
    G0 X0 Y0 +
    M2 (end job) +
|Cut a hole with 6.5mm overcut using the #<holes> command
   |G21 (metric) +
    G64 P0.05 +
    M52 P1 (allow paused motion) +
    \#<holes> = 2 (overcut for holes) +
    #<oclength> = 6.5 (6.5mm overcut length) +
    F#<_hal[plasmac.cut-feed-rate]> +
    G0 X10 Y10 +
    M3 $0 S1 (start cut) +
    G1 X0 +
    G3 I10 (the hole) +
    M5 $0 (end cut) +
    G0 X0 Y0 +
    M2 (end job)
|Select scribe and select torch at end of scribing
   |. +
    . +
    M52 P1 (paused motion on) +
    F#<_hal[plasmac.cut-feed-rate]> +
    T1 M6 (select scribe) +
    G43 H0 (apply offsets) +
    M3 $1 S1 (start plasmac with scribe) +
    . +
    . +
    T0 M6 (select torch) +
    G43 H0 (apply offsets) +
    G0 X0 Y0 (parking position) +
    M5 $1 (end)
|Hole centre spotting. +
  |(Requires a small motion command or nothing happens) +
    G21 (metric) +
    F99999 (high feed rate) +
    G0 X10 Y10 +
    M3 $2 S1 (spotting on) +
    G91 (relative distance mode) +
    G1 X0.000001 +
    G90 (absolute distance mode) +
    M5 $2 (spotting off) +
    G0 X0 Y0 +
    G90 +
    M2 +
|Create temporay default material
   |(o=1, nu=2, na=5mm Mild Steel 40A, ph=3.1, pd=0.1, ch=0.75, fr=3000)
|Edit material, if not existing create a new one
   |(o=3, nu=2, na=5mm Mild Steel 40A, ph=3.1, pd=0.1, ch=0.75, fr=3000, kw=1.0)
|===

[[rs485_connections]]

=== RS485 Connections

Hypertherm Powermax 125:

image::images/plasmac_rs485_pmx.png[]

Sunnix SER5037A PCI Card with breakout board:

image::images/plasmac_rs485_sunnix.png[]

Dtech DT-5019 USB to RS485 converter adapter:

image::images/plasmac_rs485_dtech.png[]

[[reed-arc-ok]]

=== Arc OK With A Reed Relay

An effective and very reliable method of obtaining an Arc OK signal from a plasma power supply without a CNC port is to mount a reed relay inside a non-conductive tube and wrap and secure three turns of the work lead around the tube.

This assembly will now act as a relay that will switch on when current is flowing through the work lead which only occurs when a cutting arc has been established.

This will require that PlasmaC be operated in Mode 1 rather than Mode 0. See the <<ini-mode, INI File>> and <<plasmac-mode, PlasmaC Modes>> sections for more information.

image::images/plasmac_reed_arc_ok.png[]

