Semi-Manual Lathe setup for EMC2


As lathe work very often consists of very similar turning, facing, boring operations in simple sequences I decided to set up my LinuxCNC lathe with a a number of pre-programmed macros invoked by PyVCP buttons. Below is a screenshot of what it ends up looking like.



A section of xml code defines the extra controls in the pyvcp panel.This is linked in the postgui .HAL file to a set of digital and analogue inputs. The analogue inputs are linked to the text-box values for such parameters as feed rate and finish diameter. The digital pins activate MDI commands defined in the INI file.

The main HAL file is pretty much entirely unchanged, except that the motmod declaration requires a few extra DIO and AIO channels to be added.

loadrt [EMCMOT]EMCMOT servo_period_nsec=[EMCMOT]SERVO_PERIOD num_joints=[TRAJ]AXES num_aio=8 num_dio=10

The tool change buttons are linked to DIO pins which are set to activate snippets of G-code defined in the [HALUI] MDI_COMMAND section of the .ini file . In this case they only bring up the manual toolchange, but if a toolchanger was fitted they would work that too.

The operation butons call subroutines, also defined as MDI_COMMANDS. The code snippets (turning, boring, facing, threading, radius, chamfer) are each called by their associated button. The spinboxes can be changed using the arrows, but they also allow direct entry of the values. However they do not register the value until the spin arows are clicked, so you need to click-up and click-down to enter a value. This is a bit annoying, and there is a patch to fix it, but it is not part of the standard distribution.

Most of the routines begin from the current position (which the G-code determines via a bit of a trick with G92. This could be changed, as newer versions of EMC2 (2.5 onwards) will make the current XYZABCUVW positions available in parameters #5420 to #5428 which is a rather more elegant way to do it.) Typically you would jog to a position just clear of the work, select the operation, surface speed, cut and feed then press the button for the required operation.

Threading and radius are exceptions. Threading begins at the current Z and needs to be either inside or outside the thread diameter to determine if the thread should be internal or external, but then it starts the thread at the "Target X" diameter and cuts to the thread depth. Note that the thread depth box needs to contain twice the thread depth, ie the difference in diameter between the OD and the root diameter.

Radius cuts the specified external radius between a diameter defined by X and a face defined by Z.

In OD turning mode the "radius" box determines the lead-out radius.

The "Angle" box is currently only used by the turning and boring routines. It seems to make nicely matched parts.