Probing is one of the great basic functions of a CNC setup. Easily find the top, edges of you work piece, or even find the centre of a hole.
I'll explain here how to set up a Z axis Auto Touch Off plate for a router.
This is very simple. For a G540, or any BOB that uses inputs shorted to ground: I use a piece of blank PCB wired to pin 13 on my breakout board. I then have a wire from ground to an alligator clip on my spindle. When the tool touches down on the plate, a circuit is completed from ground to pin 13.
On my newer machines, I use a Mesanet 7i76. This has sinking inputs. They require +ve voltage connected to the input to trigger. This is a problem with my touch off plate, as the spindle is grounded, and connecting 12V to it via the touch off plate results in a short to ground. The solution is to have a pull up resistor. The wiring is: Ground connected to the tool. PCB plate connected to input of 7i76. A 2.2k resistor between the PCB plate and 12V. This 'pulls' the input high, then it goes low when the PCB and tool form a circuit to ground. In this setup, the pin is always high (triggered) except when the probe touches, so I invert the input in LinuxCNC.
A standard install of LinuxCNC has everything you need.
We are going to use G38.2 (probe toward workpiece, stop on contact, signal error if failure ) and G10 L20 P1 Z (Set Coordinate System to a calculated value that makes the current coordinates become the given value)
We are going to need to modify your .ini file, your .hal file, custompanel.xml, and custom_postgui.hal. We'll also need to create a file '100.ngc' and place that in the nc_files folder.
.hal first up:
#limits debounce to stop false triggers loadrt debounce cfg=2 #change to the number you want setp debounce.0.delay 100 #this sets the delay 100 iterations of the base thread addf debounce.0 base-thread net deb-probe-in debounce.0.0.in <= parport.0.pin-13-in-not net probe-in debounce.0.0.out net probe-in => motion.probe-input
- PYVCP = custompanel.xml
- HALUI = halui
- HALFILE = Router.hal #the name of your hal file
- HALFILE = custom.hal
- POSTGUI_HALFILE = custom_postgui.hal
- # add halui MDI commands here (max 64)
- MDI_COMMAND = o100 call
net remote-o100 halui.mdi-command-00 <= pyvcp.o100
I'm using a cheap pendant which works great, so I want to be able to trigger it from my pendant, as well as the custom panel (could also just get rid of the custom panel and only use the pendant). This means we have to be a little more fancy in custom_postgui.hal
loadrt or2 count=6 #because I have 5 other or functions in my pendant setup addf or2.5 servo-thread net pendantz input.0.btn-start or2.5.in0 net remote-o100 pyvcp.o100 or2.5.in1 net touchoffz or2.5.out halui.mdi-command-00
100.ngc (goes in nc_files folder remember):
- o100 sub
- ( Set current Z position to 0 so that we will always be moving down )
- G10 L20 P0 Z0
- ( Probe to Z-10 at F25 [Uses machine units, I work in mm, this is meant to be slow!] )
- G38.2 Z-10 f25
- ( Set Z0 at point where probe triggers with offset of +1.47 [this is the thickness of my PCB plate. You must adjust this for your plate / setup] )
- G10 L20 P0 Z1.47
- ( Rapid up to Z10 above the material )
- G0 Z10
- o100 endsub
<?xml version='1.0' encoding='UTF-8'?> <pyvcp> <button> <halpin>"o100"</halpin> <text>"Touch Off Z"</text> <font>('fixed',10)</font> </button> </pyvcp>
That should be all you need to get your Z Touch Off Plate going. I just clip the alligator clip on to my spindle, put the pcb under the tool (resting on top of the workpiece) and hit the button and end up with a perfectly zeroed Z axis. This is great for manual tool changing like on a router.
Many thanks to strokercrate from CNCZone for supplying the code which formed the basis for the above.