Hello Guest it is December 26, 2024, 09:31:32 PM

Author Topic: Help with Auto tool zero macro?  (Read 13248 times)

0 Members and 1 Guest are viewing this topic.

Help with Auto tool zero macro?
« on: December 17, 2009, 12:21:59 AM »
How can I assign a M number to this macro I found that is for the auto tool zero button.  I would like to be able to use the button to zero the tool, and I would also like to assign a M-number so that immediately after a tool change, the the macro will be ran, the tool will be zeroed and the program then continue.

Example :
M28
T3 M06 G43 H3
M99991 (Auto zero's tool)
M1 (press cycle start to continue)
G0 z.375
......

Also, I would like to know if after the probe is triggered, does the z axis de-accelerate normally, or does it come to an abrupt stop (like when an e-stop is triggered).  I'm afraid the I'll lose steps in absolute coordinates on the z axis with my stepper system.

Here is the macro I found:

Put a user DRO on the screen using Mach's screen utility, Screen4. Assigned it OEM code 1151

Also put a LED for Probe and one for Pause or Dwell. These I will explain later. See the screen grab below as pic.

Assigned the following macro to the "Auto Tool Zero" button.

PlateThickness = GetUserDRO(1151) 'Z-plate thickness DRO

If GetOemLed (825)=0 Then 'Check to see if the probe is already grounded or faulty
DoOEMButton (1010) 'zero the Z axis so the probe move will start from here
Code "G4 P5" ' this delay gives me time to get from computer to hold probe in place
Code "G31Z-40 F500" 'probing move, can set the feed rate here as well as how far to move
While IsMoving() 'wait while it happens
Wend
ZProbePos = GetVar(2002) 'get the axact point the probe was hit
Code "G0 Z" &ZProbePos 'go back to that point, always a very small amount of overrun
While IsMoving ()
Wend
Call SetDro (2, PlateThickness) 'set the Z axis DRO to whatever is set as plate thickness
Code "G4 P0.25" 'Pause for Dro to update.
Code "G0 Z25.4" 'put the Z retract height you want here
Code "(Z axis is now zeroed)" 'puts this message in the status bar
Else
Code "(Z-Plate is grounded, check connection and try again)" 'this goes in the status bar if aplicable
Exit Sub
End If


 
Re: Help with Auto tool zero macro?
« Reply #1 on: December 17, 2009, 10:03:22 AM »
M-macros are created simply by naming the file M*********.m1s.  So, if you want to run a particular macro as M199, put it in a file named M199.m1s.

G31 does obey the acceleration specified for each axis, so it *will* over-shoot if you probe at high speed.

Regards,
Ray L.
Regards,
Ray L.

Offline Greolt

*
  •  956 956
Re: Help with Auto tool zero macro?
« Reply #2 on: December 18, 2009, 01:50:33 AM »
I recognise the comment wording as an old example of mine.  (Which was based on someone else's)

Try a couple of mods, slowing it down for one,

PlateThickness = GetUserDRO(1151) 'Z-plate thickness DRO

If GetOemLed (825)=0 Then 'Check to see if the probe is already grounded or faulty
DoOEMButton (1010) 'zero the Z axis
Code "G4 P2" ' this delay gives me time to get from computer to hold probe in place, 2 seconds
Code "G90 G31 Z-30 F50" 'probing move, can set the feed rate here as well as how far to move
While IsMoving() 'wait while it happens
Wend
ZProbePos = GetVar(2002) 'get the axact point the probe was hit
Code "G0 Z" &ZProbePos 'go back to that point, always a very small amount of overrun
While IsMoving ()
Wend
Call SetDro (2, PlateThickness) 'set the Z axis DRO to whatever is set as plate thickness
Sleep 150 'Pause for Dro to update.
Code "G1 Z30 F200" 'put the Z height to retract to here
Code "(Z axis is now zeroed)" 'puts this message in the status bar
Else
Code "(Z-Plate is grounded, check connection and try again)" 'this goes in the status bar if aplicable
End If
Exit Sub
Re: Help with Auto tool zero macro?
« Reply #3 on: February 01, 2010, 02:52:22 PM »
Can anyone help me.  When I give the code g31 z-3 f5 the router moves but when I touch the probe to the bit the probe lights but the z movement does not stop.  It does not stop when it gets to -4 either I have to hit the stop button.

Offline Greolt

*
  •  956 956
Re: Help with Auto tool zero macro?
« Reply #4 on: February 01, 2010, 06:03:42 PM »
When you say the probe lights, what do you mean?

Look on the diagnostics page.  When the probe "lights" then the "digitize" LED should light.

Greg

PS:  Are you using the LPT or another external pulsing device?
Re: Help with Auto tool zero macro?
« Reply #5 on: February 02, 2010, 01:30:32 AM »
The digitize light on the diagnostic screen lights when the probe touches the router bit.
Re: Help with Auto tool zero macro?
« Reply #6 on: February 02, 2010, 03:20:24 PM »
I am using LPT

Offline ftec

*
  •  88 88
Re: Help with Auto tool zero macro?
« Reply #7 on: February 02, 2010, 04:14:23 PM »
Quote
Code "G90 G31 Z-30 F50" 'probing move, can set the feed rate here as well as how far to move
While IsMoving() 'wait while it happens
Wend


I don't see anything in this code fragment that would stop the Z movement once it has been commenced until it has reached Z-30. So I would assume that there must be internal code within Mach which stops the movement while the program loops  in IsMoving() - Wend and when the digitize led lits. I would check the enabling of the probe and how it is connected and how it has been set up in Input Signal etc.

There is a function IsSuchSignal(SignalID As Integer) with which you could check if the probe signal is valid but I don't know the SignalID constant for the probe input.

PS. Is there a list available of the constants names and values used within Mach. There must be constants also for XHOME, YHOME etc.
« Last Edit: February 02, 2010, 04:23:20 PM by ftec »

Offline Greolt

*
  •  956 956
Re: Help with Auto tool zero macro?
« Reply #8 on: February 02, 2010, 06:51:01 PM »
Quote
Code "G90 G31 Z-30 F50" 'probing move, can set the feed rate here as well as how far to move
While IsMoving() 'wait while it happens
Wend

I don't see anything in this code fragment that would stop the Z movement once it has been commenced until it has reached Z-30.

G31 is a probe move, so it is inherent in the move to stop when the probe input goes active.

Sawdustman,  will the probe move stop when triggered if you manually enter the "G31 Z-30 F50" in the MDI?

Greg
Re: Help with Auto tool zero macro?
« Reply #9 on: February 03, 2010, 01:30:26 AM »
Greg,  The probe does not stop the movement with a manual input either.

Steve