PDA

View Full Version : Probe Centering with Mach3 Tutorial



Ricardoco
02-06-2013, 07:56 PM
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

9004


Select the Offsets Tab indicated
9005

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.

9006

As we are assigning a function to a button select button script from the dropdown menu
9007

This will cause all the buttons that can be assigned to flash, select the centering button indicated below.
9008

A code box for the selected button will appear, Copy the code at the bottom of the post into this box.

9009
And donít forget to save it as indicated in the picture
9010

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..

9011


The Code
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)"
Else
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
Wend
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
While IsMoving()
Wend
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
While IsMoving()
Wend
YPos1 = GetVar(2001)

Code "G0 Y" &YCurrent

Rem Probe down

YNew = YCurrent - 75
Code "G31 Y" &YNew
While IsMoving()
Wend
YPos2 = GetVar(2001)

YCenter = (YPos1 + YPos2) / 2


Rem move To the center

Code "G0 Y" &YCenter
While IsMoving ()
Wend

Code "F" &FeedCurrent 'restore starting feed rate

DoOEMButton ( 1008 )
DoOEMButton ( 1009 )

End If

The Code

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!!
Rick

halfpenny
01-07-2016, 05:28 PM
Hey Ricardoco!

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?

Thanks

Clive S
01-07-2016, 06:41 PM
Hey Ricardoco!

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?

Thanks

The post is 3 years old but.

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.

Dean jeffery
02-07-2016, 08:26 AM
Correct but if he's not probing a bore then he needs the info, he did say edge [emoji23]


Now the proud owner of my own personal CNC machine happy days.

Clive S
02-07-2016, 10:23 AM
Correct but if he's not probing a bore then he needs the info, he did say edge [emoji23]


Now the proud owner of my own personal CNC machine happy days.The way I have read it is that the code (in this case) is only as stated and been setup to find the centre of a hole and not an edge finder. But I stand to be corrected if I have miss read it.

Of course if you want to find an edge then you will need the diameter of the tool stroke probe

JAZZCNC
02-07-2016, 11:36 AM
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.

Clive S
02-07-2016, 05:20 PM
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.

Neale
02-07-2016, 05:54 PM
...and this is one reason why soft limits are useful? Although I guess you will snap the probe first anyway!

Clive S
02-07-2016, 06:46 PM
...and this is one reason why soft limits are useful? Although I guess you will snap the probe first anyway!In my opinion PROVIDING you have homed the machine soft limits are well worth having.

JAZZCNC
02-07-2016, 08:19 PM
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.

There's more wrong with it than just this and to me with no disrepect to anyone but people shouldn't post Code unless they know it's safe.! . . . Saying use at own risk isn't acceptable to me.:thumbdown: