Hello Guest it is August 08, 2020, 04:39:49 AM

Author Topic: A faster [REF ALL HOME] script for MACH3  (Read 1403 times)

0 Members and 1 Guest are viewing this topic.

Offline reuelt

*
  •  440 440
    • View Profile
A faster [REF ALL HOME] script for MACH3
« on: April 25, 2019, 06:28:58 PM »
' Faster Ref. ALL Home script by Reuel
Speak (" FASTER Referencing all home.") 'VOICE Alert

Message "************ FASTER Reference all home Started************"
Sleep (1000) ' Pause 1 second
CurrentFeed = GetOemDRO(818) 'Get the current feedrate to return to later
CurrentAbsInc = GetOemLED(48) 'Get the current G90/G91 state
CurrentGmode = GetOemDRO(819) 'Get the current G0/G1 state

DoOEMButton( 1024 ) ' Ref (home) Z Axis
While IsMoving()
Wend
DoOEMButton(135)  ' Zero Z Encoder

Code "G90"
Code "G53 G0 Y25"  '25 mm may be change to 1 inch
While IsMoving()
Wend
Code "G53 G0 X25"  '25 mm may be change to 1 inch
While IsMoving()
Wend

Code "F1200"
DoOEMButton( 1023 ) ' Ref Y Axis
DoOEMButton( 1022 )' Ref X Axis
DoOEMButton( 1025 )' Ref A Axis

DoOEMButton(134)  ' Zero Y Encoder
DoOEMButton(133)  ' Zero X Encoder
DoOEMButton(136)  ' Zero A Encoder
While IsMoving()
Wend

Code "G54"
If CurrentAbsInc = 0 Then 'if G91 was in effect before then return to it
Code "G91"
End If
If CurrentGMode = 0 Then 'if G0 was in effect before then return to it
Code "G0"
End If   


Speak ("FASTER Reference all home Completed") 'Voice Alert
Message "************  FASTER Reference all home Completed************"     



'idea is to get Z to the top slowly first (for safety) then move Y and X at G0 speed to 25mm from home switches and then move slowly towards the switch. The slow speed part is still controlled by speed % settings in config || motor home/soft limits as usual.
' Change 25 (mm) to 1 (inch) in 2 places if you use inches units.

'suggestions to improve on it welcomed
"the gift of God is eternal life through Jesus Christ our Lord"

Offline ZASto

*
  •  284 284
    • View Profile
Re: A faster [REF ALL HOME] script for MACH3
« Reply #1 on: April 25, 2019, 06:39:24 PM »
You can put units checking in your script ti make it universal :)

Code: [Select]
If GetOEMLED(801) Then
  Code "G53 G0 Y1"
Else
  Code "G53 G0 Y25"
End If

If you are giving someone a solution and you do not know the native units of that persons machine setting.

;)
Make no mistake between my personality and my attitude.
My personality is who I am.
My attitude depends on who you are.

Offline reuelt

*
  •  440 440
    • View Profile
Re: A faster [REF ALL HOME] script for MACH3
« Reply #2 on: April 25, 2019, 07:19:19 PM »
Thanks
Do you know how make the script grab the data from the "SLOW ZONE" column of  in config | motor home/soft limits?
Then it is not only units independent but also slow zone distance can be easily changed by users too.

Reuel
« Last Edit: April 25, 2019, 07:22:53 PM by reuelt »
"the gift of God is eternal life through Jesus Christ our Lord"

Offline reuelt

*
  •  440 440
    • View Profile
Re: A faster [REF ALL HOME] script for MACH3
« Reply #3 on: April 26, 2019, 04:33:30 AM »
'  Faster Ref. ALL Home script by Reuel  updated thanks to ZASto & TPS - now works in either imperial or metric unit

Speak (" FASTER Referencing all home.") 'VOICE Alert

Message "************ FASTER Reference all home Started************"
Sleep (1000) ' Pause 1 second
CurrentFeed = GetOemDRO(818) 'Get the current feedrate to return to later
CurrentAbsInc = GetOemLED(48) 'Get the current G90/G91 state
CurrentGmode = GetOemDRO(819) 'Get the current G0/G1 state

DoOEMButton( 1024 ) ' Ref (home) Z Axis
While IsMoving()
Wend
DoOEMButton(135)  ' Zero Z Encoder

Code "G90"
If GetOemLed(801) Then 'imperial units check
  Code "G53 G0 Y1 X1"  'fast move to Y1 X1 in inches
Else
  Code "G53 G0 Y25 X25" 'fast move to Y25 X25 in mm
End If
While IsMoving()
Wend

DoOEMButton( 1023 )' Ref Y Axis
DoOEMButton( 1022 )' Ref X Axis
DoOEMButton( 1025 )' Ref A Axis
DoOEMButton( 1026 )' Ref B Axis
DoOEMButton( 1027 )' Ref C Axis

DoOEMButton(134)  ' Zero Y Encoder
DoOEMButton(133)  ' Zero X Encoder
DoOEMButton(136)  ' Zero A Encoder
DoOEMButton(137)  ' Zero B Encoder
DoOEMButton(138)  ' Zero C Encoder
While IsMoving()
Wend

Code "G54"
If CurrentAbsInc = 0 Then 'if G91 was in effect before then return to it
Code "G91"
End If
If CurrentGMode = 0 Then 'if G0 was in effect before then return to it
Code "G0"
End If   


Speak ("FASTER Reference all home Completed") 'Voice Alert
Message "************  FASTER Reference all home Completed************"     
« Last Edit: April 26, 2019, 04:39:16 AM by reuelt »
"the gift of God is eternal life through Jesus Christ our Lord"