A tutorial to show the configuration of Mach3 (with standard screens) to find the center of a hole or pipe.
the code is IN MILLIMETERS if you wish to use Imperial measurements you will have to edit the code accordingly.
You must get this right or you could damage your machine or probe or worse!!
I was not able to find a tutorial that started at the beginning for the novice, so why not have one here.
This tutorial assumes you have fitted a probe on your system, and assigned it to an input, and that the large digitise led on the diagnostics tab in Mach3 lights when you activate it.
Some of the buttons in Mach3, although shown on the screens do not do anything when pressed, this is because they have no code or script assigned to them.(Great idea that)
In the few steps to follow, we will assign some code to a button for center finding, this procedure can be used with other buttons as well, as long as you can find the code for the button you wish to assign it too. The script/code we will be using is not mine, it has several authors as it has evolved over time and Iím sure it will evolve further in the future.
Ok first things first.
There may be a better way to do this but as nobody seems to have done it as a tutorial Iím having a go. if you have a better way then submit it as a tutorial of your own and by all means pop a link to it in this thread, after all the more views the better, but letís not make this any more complicated than it needs to be. If you have clever dick comments then keep them to yourself as this is not a debate, or pm me :)
Of course if you have constructive comments then please donít be shy and at the end of this we should have a nice little tutorial for the site.. (Thatís why we are members isnít it)
The Main screen in Mach3
Select the Offsets Tab indicated
This screen has a number of functions that can be performed using a probe/edge finder this tutorial will be using a touch probe, select the operator button in the file menu bar indicated below.
As we are assigning a function to a button select button script from the dropdown menu
This will cause all the buttons that can be assigned to flash, select the centering button indicated below.
A code box for the selected button will appear, Copy the code at the bottom of the post into this box.
And donít forget to save it as indicated in the picture
And thatís it!!
Assuming the probe is fitted and working, using jog, move the probe down (5mm or more will do) into the hole or pipe you wish to have the machine centered to. And hit the Red circled button..
Rem VBScript To center probe inside a pipe
If GetOemLed (825) <> 0 Then 'Check to see if the probe is already grounded or faulty
Code "(Probe plate is grounded, check connection and try again)"
FeedCurrent = GetOemDRO(818) 'Get the current settings
XCurrent = GetDro(0)
YCurrent = GetDro(1)
Code "G4 P1" 'Pause 1 second to give time to position probe plate
Code "F100" 'slow feed rate to 4 ipm 100mm
Rem Probe Left
XNew = Xcurrent - 75 'probe 3 inches to left 75mm
Code "G31 X" &XNew
While IsMoving() 'wait for the move to finish
XPos1 = GetVar(2000) 'get the probe touch location
Code "G0 X" &XCurrent 'rapid move back to start point
Rem Probe Right
XNew = XCurrent + 75 'probe 3 inches to right 75mm
Code "G31 X" &XNew
XPos2 = GetVar(2000)
XCenter = (XPos1 + XPos2) / 2 'center is midway between XPos1 and XPos2
Code "G0 X" &XCenter 'rapid move to the x center location
Rem Probe up
YNew = YCurrent + 75
Code "G31 Y" &YNew
YPos1 = GetVar(2001)
Code "G0 Y" &YCurrent
Rem Probe down
YNew = YCurrent - 75
Code "G31 Y" &YNew
YPos2 = GetVar(2001)
YCenter = (YPos1 + YPos2) / 2
Rem move To the center
Code "G0 Y" &YCenter
While IsMoving ()
Code "F" &FeedCurrent 'restore starting feed rate
DoOEMButton ( 1008 )
DoOEMButton ( 1009 )
Just copy this code into the box when prompted this version will zero the X,Y when Finished.
I always run it twice
this tutorial works on my machine...but use it at your own risk!!
RickAlways bear in mind that your own resolution to succeed is more important than any other - Abe Lincoln
Long shot you may see this as it's been just about a year since you did this! but anyway,
In your code, does it have anywhere to specify the diameter of the probe being used? So say I have a 5mm probe, then the software knows that the centre of the probe is actually 2.5mm offset from the edge that has just touched?
This is the line (A tutorial to show the configuration of Mach3 (with standard screens) to find the center of a hole or pipe.)
So the diameter of the tool is irreverent as the tool (probe) will touch BOTH sides of the hole and then divide by two and thus cancel out...Clive
Correct but if he's not probing a bore then he needs the info, he did say edge
Now the proud owner of my own personal CNC machine happy days.
Of course if you want to find an edge then you will need the diameter of the tool stroke probe
Last edited by Clive S; 02-07-2016 at 08:25 AM...Clive
Clives correct the basic code below doesn't need tip Dia to work.! . . . But this code is not safe and only has basic error checking.?
For instance it doesn't check to see if set to machine coordinates and warn the user or at least change on the fly and return when done.
The code gets the current value from WORK coordinate DRO and then adds +/- 75mm travel distance to variable which it then uses this value for G31 probe command.
If control set to G90 absolute coordinates before the probe is activated then will try to go to the value but in machine coordinates which could and will be very different to WORK coordinates.!! . . . . CRASH BANG SNAPPPPPP.
Well said Dean I had not read the code in that detail and you are correct the code does need changing but to be fair to Ricardoco he does state run at your own risk...Clive
...and this is one reason why soft limits are useful? Although I guess you will snap the probe first anyway!
Last edited by Neale; 02-07-2016 at 03:55 PM.
The Following User Says Thank You to JAZZCNC For This Useful Post:
By HiltonSteve in forum Tool & Tooling TechnologyReplies: 18Last Post: 12-11-2013, 05:23 PM
By craigrobbo in forum Computer SoftwareReplies: 0Last Post: 21-09-2012, 05:20 PM
By maritimesbob in forum Probing, Digitizing & ScaningReplies: 4Last Post: 02-09-2012, 10:22 PM
By Robin Hewitt in forum Tool & Tooling TechnologyReplies: 13Last Post: 03-02-2012, 06:49 PM
By luke11cnc in forum Probing, Digitizing & ScaningReplies: 28Last Post: 31-01-2012, 12:16 AM