Hello Guest it is March 29, 2024, 01:03:04 AM

Author Topic: Automatic G28 after, initial Reset and homing for your use  (Read 9170 times)

0 Members and 1 Guest are viewing this topic.

Offline poppabear

*
  • *
  •  2,235 2,235
  • Briceville, TN, USA
    • View Profile
Automatic G28 after, initial Reset and homing:

If you want this to be an automatic function you can make a Macro pump, and a custom Macro as well see below.

Instructions for use:

1). Goto Home/limits and set where you want your G28 position to be (note, this will also activate your "Safe Z" if you have it ticked and set.
2). In Mach goto: Operator>VB scripter and click on it.
3). Copy and past the code below for "MacroPump.m1s" into the window, goto: File>SaveAs in that window, and name it: "MacroPump.m1s", NOTE: make sure the directory you are saving it to IS the Profile you are running under the Macros folder. I.e. if you are running standard MachMill then the path would be Mach3/Macros/Mach3Mill.
4). Then delete the code from the window, then copy and paste in the: "M900.m1s" do a "saveas" like you did above but call it M900.
5). then close the VB scripter window.
6). goto: Config>General and tick the button called "Run Macropump".
7). Close Mach3, and then reopen it.
8). when it comes back up, hit Reset, then your Ref-All button, your machine will home itself, then it will move to your G28 offset.

NOTE: if for any reason you hit a Reset after the intital G28, Mach will not "UnRef" the homes. Thus when you come back out of a reset it will not automatically re-G28 since the Refed axis LED are still referenced. If you wanted it to redo the G28 again without closing Mach3, you would have to put a "DeRef axis" in the Reset button, OR, the Macropump.

Here is the Macropump code:

'**********MacroPump.m1s

'Function: "Home Offset after Ref".
'the below makes sure that all three axis x, y, z are refed.
'the counter makes sure this code only runs once per reset.

RefOnce = GetUSERDRO(2000)  'counter DRO

If NOT(GetOEMLED(807)) and Not(GetOEMLED(808)) and Not(GetOEMLED(809)) and RefOnce = 0 Then
Code "m900"   'sends machine to your offsets macro
SetUserDRO(2000,1) 'sets counter to 1 so this code drops out.
End If

If GetOEMLED(800) Then
SetUserDRO(2000,0) 'sets counter to 0 when reset.
End If

'*******here is the M900.m1s code:

'm900.m1s

Code "G4 P1"
While IsMoving()
WEnd
Code "G28"
While IsMoving()
WEnd


'Enjoy,
'Scott
fun times
Re: Automatic G28 after, initial Reset and homing for your use
« Reply #1 on: December 25, 2009, 09:30:45 AM »
Is it possible to change a little bit this macro so it perform an automatic "reference all axis" after initial reset, and if any of axes is unreferenced? I have tried some changes, but couldn't manage it to works :-(

Cheers

Offline poppabear

*
  • *
  •  2,235 2,235
  • Briceville, TN, USA
    • View Profile
Re: Automatic G28 after, initial Reset and homing for your use
« Reply #2 on: December 29, 2009, 01:54:53 PM »
sure in Screen Designer, open the RESET button, put the VB code for reference axis (how every many you need).
Note this will ref your axis each time you push the Reset button.

DoButton( 24 ) 'ref z
DoButton( 23 ) 'ref y
DoButton( 22 ) 'ref x
DoButton( 25 ) 'ref a
DoButton( 26 ) 'ref b
DoButton( 27 ) 'ref c


fun times
Need Automatic G code to do REF A
« Reply #3 on: October 18, 2013, 07:44:17 AM »
I need to add some "G" cod :)e to do an automatic REF ALL HOME at the end of my program.
Can any one help?
Allen

Offline ger21

*
  • *
  •  6,295 6,295
    • View Profile
    • The CNC Woodworker
Re: Automatic G28 after, initial Reset and homing for your use
« Reply #4 on: October 18, 2013, 11:57:42 AM »
Save your homing script as an M999.m1s and call the M999 in your g-code.
Gerry

2010 Screenset
http://www.thecncwoodworker.com/2010.html

JointCAM Dovetail and Box Joint software
http://www.g-forcecnc.com/jointcam.html
Re: Automatic G28 after, initial Reset and homing for your use
« Reply #5 on: October 18, 2013, 02:54:02 PM »
Gary,

Thanks for the reply. I am not very familiar with the VB script. Do you and exaple?

Allen
 :D