Touch Plate and Probe Functionality

with LinuxCNC 2.8 and Mesa 7i76e

LinuxCNC Logo and and Mesa 7i76e Board

This article documents how to add a touch plate and probing function for the Torsion CNC Router when using a Mesa 7i76e FPGA board and LinuxCNC 2.8

A probe routine can be used to detect the X, Y, and Z zero coordinates after you mount a part or piece of raw stock material on the CNC router bed. This sets the work offsets (e.g. G54) so the machine knows where the part is mounted on the bed and can command all the moves in the G code program relative to the zero point of the part, as was defined in the CAM programming.

Many touch off plates work by applying a ground wire to the spindle or cutting tool and sensing the tool making contact with a plate. The probing routine drives the tool slowly down towards the plate. When the tool makes contact with the touch-off plate, the plate becomes grounded. There is a wire connected to the plate that runs back to an input pin on the control board. When the controller senses ground, it stops the motion and takes note of that Z coordinate. Then the routine can automatically calculate the zero point based on the programmed thickness of the touch-off plate.

With the Mesa 7i76e, the inputs expect to see 24 vdc to read active. Since the touch plate will supply ground when active, a pull-up resistor can be used to pull the input up to 24 vdc when the probe is not active. Inverting the signal in software will make it inactive at 24 vdc. When the cutting tool contacts the touch plate, the input pin will be grounded and read as active.

Wiring

For an input to the Mesa 7i76e, I chose to use TB5 pin 10 which is Input 25, per page 12 of the 7i76e manual.

Run a wire from the +24vdc field power terminal, TB1 pin 4, through a 2k pull up resistor to the input pin, TB5 pin 10.

Run two wires to the touch off plate. One will be hardwired to the DC Ground in the electronics box and have an alligator clip or magnet to attach the wire to the cutting tool or spindle. The other wire from the probe should run back to the input pin on the 7i76e, TB5 pin 10.

The input can be inverted in the software by adding “-not” to the input number. See below.

LinuxCNC setup

Either use Pncconf to select the probe function for the input pin you are using on the 7i76e, or manually update the hal file to associate the 7i76e input pin with the software signal for probe input.

Ensure the following lines are in your hal file:

#  ---probe signal---
    net probe-in     =>  motion.probe-input

Add this under the # external inputs section:

# --- PROBE-IN ---
    net probe-in     <=  hm2_7i76e.0.7i76.0.0.input-25-not

The above changes made the input signal available for use in LinuxCNC. Now a method is needed in the user interface to activate a touch-off or probing routine.

Probe screen installation/setup

I chose to install Probe Screen for finding X and Y zero: https://github.com/linuxcnc-probe-screen/probe-screen-ng

Follow the instructions in the README.md file. I won’t repeat them here.

Z Touch-Off Button

For finding Z zero, which must be done every time a tool is changed during a program, I added a button to the GUI. It is on the same pyvcp panel that was installed for showing spindle speed.

Assuming you’ve already installed Probe Screen above, these are the steps to set up a Z touch-off button.

Add the following code to “pyvcp-panel.xml” to add a button to the GUI. Insert the code towards the end of the file after and before .

<button>
    <relief>RAISED</relief>
    <bd>3</bd>
    <halpin>"ztouch"</halpin><text>"Touch Off Z"</text>
    <font>("Helvetica",16)</font>
</button>

Add this to “custom_postgui.hal”:

# Button for automated Z Touch Off with plate
    net ztouch halui.mdi-command-00 <= pyvcp.ztouch

Add this to your machine’s .ini file:

[HALUI]
    # Z axis touch plate subroutine
    MDI_COMMAND = o<z_touch> call

Create a file in the /psng/macros directory, named “z_touch.ngc” and paste in the following subroutine code. You'll need to change the second-to-last line to account for the plate thickness you are using.

o<z_touch> sub
    ; Cancel all Z offsets
    G92.1
    G49
    G10 L20 P0 Z[#<_hal[axis.z.pos-cmd]>]
    ; Set incremental mode
    G91
    ; Force LinuxCNC to refresh hal pin states prior to reading HAL pin
    M66 E0 L0
    ; Check if probe is already tripped
    O10 if [#<_hal[motion.probe-input]> EQ 1]
        O10 return [-1]
    O10 endif
    G38.2 Z-10 F25	(probe down using a fast feedrate)
    G0 Z0.5		(move up by 0.5mm)
    ; Allow a half second for the probe input to clear
    G4 P0.5
    ; Force LinuxCNC to refresh hal pin states prior to reading HAL pin
    M66 E0 L0
    ; Check if probe is already tripped
    O21 if [#<_hal[motion.probe-input]> EQ 1]
        O21 return [-1]
    O21 endif
    G38.2 Z-1 F1	(probe down using a slow feedrate to get better accuracy)
    G10 L20 P0 Z15.72	(set current WCS Z value = plate thickness)
    G0 Z10		(move up 10mm above work piece)
o<z_touch> endsub

Now when you run LinuxCNC you should see a button on the right side "Touch Off Z". Click this button when you have a tool loaded in the spindle and a touch plate directly below the tool, within a few mm. The routine will be started as the Z axis drives downwards slowly until it makes contact with the touch plate.