PDA

View Full Version : g31 code probe



warwick
26-02-2017, 01:27 PM
well gentlemen, three months ago i never thought id be asking for help with g code..if im honest i didnt think id be this far in............im after a piece of code to put into mach3 to get my touch off probe working.iv seen some posts on other forums but im not a member so cant copy the code.....weve got my touch off fitted and wired so on my mach plasma screen it shows a digitise light when activated but does nothing more...would like it to zero my dro and lift up to a designated point........

im learning and its a steep curve.if im using the wrong termonology please correct me...............

warwick

Neale
26-02-2017, 02:16 PM
What do you need it to do exactly? You have a probe that will detect the top of the work and set Z DRO to a preset value?

I've just been working on this for my router, based heavily on code published elsewhere (including 53 pages of posts on CNCZone in just one topic, making sure that I had the latest version...). It's pretty straightforward, Just a couple of lines of code to do the work. Plus a couple of dozen lines to sort out issues like units, abs/inc mode, coord display mode, etc...

Be happy to throw something together if you really can't find what you want elsewhere but I would suggest that you pick up a known version from CNCZone - worth signing up to it for that alone.

warwick
26-02-2017, 02:51 PM
What do you need it to do exactly? You have a probe that will detect the top of the work and set Z DRO to a preset value?

I've just been working on this for my router, based heavily on code published elsewhere (including 53 pages of posts on CNCZone in just one topic, making sure that I had the latest version...). It's pretty straightforward, Just a couple of lines of code to do the work. Plus a couple of dozen lines to sort out issues like units, abs/inc mode, coord display mode, etc...

Be happy to throw something together if you really can't find what you want elsewhere but I would suggest that you pick up a known version from CNCZone - worth signing up to it for that alone.

hi, i would like it to touch off on the steel rise to set height and zero the dro....i think.correct me if im wrong....i understand that i will have to modify it for my machine...id seen a topic and some code on cnc zone but im not a member and im a bit funny about just taking content of forums and giving nothing back.hence my build log.....

Neale
26-02-2017, 04:27 PM
id seen a topic and some code on cnc zone but im not a member and im a bit funny about just taking content of forums and giving nothing back.hence my build log.....
I understand your view but I tend to take the attitude that what goes around, comes around. Help when and where you can, take help from wherever you need. It averages out in the end!

A_Camera
27-02-2017, 01:09 PM
...id seen a topic and some code on cnc zone but im not a member and im a bit funny about just taking content of forums and giving nothing back.hence my build log.....
...if it is public and available for you to see then there is nothing wrong with taking that code. If you are not comfortable with that then you have to wait until tonight and hope that I remember, and have time to get back to this thread. I will post my code for Z zero but will probably not have time with guiding you all the way because I no longer use Mach3 and have very little time to play with it. Anyway, the code I will post works for me and have used it quite some time, but it is a pretty simple code.

Probing is really pretty simple, and the simplest is to place your probe a few mm over the touch plate (less than 3 mm in my example), zero Z by clicking on the button and simply type for example: G31 Z-3 F400 (assuming you have mm units). The code will start move your Z towards the touch plate with a speed of 400mm/min and will stop as soon as the probe touches the plate, or as soon as it reaches -3 mm, whichever come first. If the probe stops after it touched the plate you can zero Z again and that's it.

Yes, there are fancier ways of doing it as well but either you take the code you think fits your needs or create your own which fits your ideas of how it should behave. Anyway, I can paste my code in here for anyone to use, but cannot promise to spend time discussing it or how to connect the touch plate/probe and so on. There is plenty public information about this on the Internet.

A_Camera
28-02-2017, 10:33 AM
Sorry, I had no time last night. Will try again tonight.

warwick
28-02-2017, 11:54 AM
Sorry, I had no time last night. Will try again tonight.

its no problem..im greatful of any help :anonymous:

A_Camera
28-02-2017, 08:35 PM
Here is the code I use for the auto Z zero. Use it at your own risk.

Short explanation:

You need to add this code to a button macro. When the code is added and the button is pushed, assuming you have done the configuration right, the Z axis will start moving down at 400mm/min. When the probe touches the touch plate it will stop, back off 0.5mm and will make a new probing at 4mm/min. When probing is done the probe will move up 2mm and the DRO will display the touch probe height + 2mm. This way the probing is extremely accurate. The touch plate height is critical, you have to measure and enter your own value in ZOffset.

Good luck in using it, but please note, use it at your own risk, I take no responsibility for any damage or injury. Test well before the first use, and every time you attach the probe before running the code. You must test it to see if the electrical contact is OK. The probe must be placed less than 20mm above the touch plate, the execution stops if no contact made within 20mm. If you want to change that then change the value of ZMove.


CurrentFeed = GetOemDRO(818)

ZMove = 20.00 'Total lenght of Probe to move before stop or no contact made.
ZOffset = 1.47 ' Plate Hight. Replace the value with your touch plate height
ZSal = ZOffset + 2.00 '+ Free Hight. Will position the probe 2 mm over the material.

StopZmove = 0
If GetOemLed (825)=0 Then
DoOEMButton (1010)
Code "G31 Z-"& ZMove & "F400"
While IsMoving()
Sleep(200)
Wend
Probepos = GetVar(2002)


' Improve accuracy

Code "G0 Z" & Probepos + 0.5 ' Move back a bit to get a new reading
While IsMoving()
Sleep(200)
Wend
Code "G31 Z-" & ZMove & "F4" ' Move very slow for greater accuracy
While IsMoving()
Sleep(200)
Wend

Probepos = GetVar(2002) ' Z var for probe

If Probepos = - ZMove Then
responce = MsgBox ("**ERROR** " , 4 , "Probe **ERROR**" )
Code "G0 Z10"
StopZmove = 1
Code "F" &CurrentFeed
End If
If StopZmove = 0 Then
Code "G0 Z" & Probepos
While IsMoving ()
Sleep (200)
Wend
Call SetDro (2, ZOffset)
Code "G0 Z" & ZSal
While IsMoving()
Sleep(200)
Wend
Code "(Z zeroed)"
Code "F" &CurrentFeed
End If
Else
Code "(Check Ground Probe)"
End If
Exit Sub
'-------------------

warwick
02-03-2017, 01:14 AM
thanks for your help yet again chaps.thankyou

A_Camera
02-03-2017, 08:54 AM
thanks for your help yet again chaps.thankyou

Good luck. I hope this was what you had in mind. Just be careful, the values above are only suitable for my machine and you should be careful before you are comfortable with it. Make sure you are using millimeters, or change the units in the code for inches. If you'd lower the Z with 400in/min, as opposed to 400mm/min which is what I am doing, you'd crash your machine and the probe or the probe plate or the CNC would get some serious damage.