Hello Guest it is March 28, 2024, 05:02:37 PM

Author Topic: Mach3 can only "Auto-tool zero" once per session  (Read 1436 times)

0 Members and 1 Guest are viewing this topic.

Mach3 can only "Auto-tool zero" once per session
« on: January 29, 2021, 04:06:03 AM »
Hello

Since the beginning of me CNC'ing with Mach3 it has only let me automatically zero my tools only once per session (with expections that I have not ran a program before). Every time I want to re-zero a tool, it goes to the probe and stops wayyyyyy above the probe itself and sets the Z value to something like -25.0000, which normally for me should stay in the range of -150.0000 to -180.0000. So everytime I want to zero a new tool, I have to restart Mach3, home all the axises and then auto tool zero it. Is there a way to avoid that?

Offline TPS

*
  •  2,501 2,501
    • View Profile
Re: Mach3 can only "Auto-tool zero" once per session
« Reply #1 on: January 29, 2021, 07:03:33 AM »
Show us your script, and we will see.
anything is possible, just try to do it.
if you find some mistakes, in my bad bavarian english,they are yours.
Re: Mach3 can only "Auto-tool zero" once per session
« Reply #2 on: January 29, 2021, 07:05:14 AM »
How exactly does that work, havent jiggled around with the scripts yet :D

Offline TPS

*
  •  2,501 2,501
    • View Profile
Re: Mach3 can only "Auto-tool zero" once per session
« Reply #3 on: January 29, 2021, 07:07:50 AM »
-Operator -> Edit button script

-Auto tool Zero button should blink now

-click on button -> Editor window Comes up

-copy and paste code into a file

-post file
anything is possible, just try to do it.
if you find some mistakes, in my bad bavarian english,they are yours.
Re: Mach3 can only "Auto-tool zero" once per session
« Reply #4 on: January 29, 2021, 07:11:04 AM »
Show us your script, and we will see.

If you mean the "'Auto-tool zero" script then here it is. There are some Estonian phrases there, but it doesn't really affect anything. They're rather informative.

           
Code: [Select]
MsgBox "Teljed nullimata"
 DoOEMBUTTON(1021)

 Exit Sub
  End If

 If GetOemled(825) <> 0 Then
   MsgBox "Testi raadioandurit"

 Exit Sub
   End If

XWork = GetOEMDRO(800)  ' Get Current X Work Coordinate
YWork = GetOEMDRO(801)  ' Get Current Y Work Coordinate
XMachine = GetOemDRO(83)  ' Get Current X Machine Coordinate
YMachine = GetOemDRO(84)  ' Get Current Y Machine Coordinate
ZMachine = GetOemDRO(85)   ' Get Current Z Machine Coordinate

Code "G49"
Code "G0 G53 Z-1." 'Home Z
code "G53 X216.90 Y3069.85" 'Move into Probe Pos ***EDIT HERE***
DoOEMButton(179) ' machine coordinates
Tool_Number = GetDRO(24)
code "G91 g31 z-200. f300." ' Z liigub alla 300 mm kuni probini
While (IsMoving())
  Sleep 30
Wend

code " g0 z 10" ' Z liigub üles 10  mm


code "G91 g31 z-15 f20." ' Z liigub alla 15 mm kuni probini

While (IsMoving())
  Sleep 10
Wend

If Tool_Number = 0 Then 'Master tool Cal
z = GetOEMDRO(85) 'get Machine ZPos
Call SetOEMDRO(49,z) 'Set g54 z offset
Else

Call SetDRO(24,0) 'Turn off the tool offset by loading tool #0
Height = GetDRO(2) 'Get the pos of the Z axis without the Tool comp on
Call SetDRO(24,Tool_Number) 'Turn the tool Back on so the offset will go to the
Call SetoemDRO(42,Height) 'Set the Tool Height offset
End If

DoOEMButton(181) 'back To program coordinates
code "G0 G90 G53 Z-1.0  F1000"
code "G43"
While (IsMoving())
  Sleep 10
Wend

Code "G0 X" & XWork & " Y" & YWork ' Returns to the previous XY job location
sleep(500)
While IsMoving()
sleep(20)
Wend


rem End If

Offline TPS

*
  •  2,501 2,501
    • View Profile
Re: Mach3 can only "Auto-tool zero" once per session
« Reply #5 on: January 29, 2021, 07:33:08 AM »
Looks like something is missing at the begin of script.

there is a End if without an IF ... Then before?
anything is possible, just try to do it.
if you find some mistakes, in my bad bavarian english,they are yours.
Re: Mach3 can only "Auto-tool zero" once per session
« Reply #6 on: January 29, 2021, 09:00:02 AM »
Looks like something is missing at the begin of script.

there is a End if without an IF ... Then before?

Yup something is indeed missing, I let the mouse go a bit too early. Here is the full script.

Code: [Select]
If getoemled(807) Or getoemled(808) Or getoemled(809) Then 'Kontrolli kas nullimise ledid polevad

MsgBox "Teljed nullimata"
 DoOEMBUTTON(1021)

 Exit Sub
  End If

 If GetOemled(825) <> 0 Then
   MsgBox "Testi raadioandurit"

 Exit Sub
   End If

XWork = GetOEMDRO(800)  ' Get Current X Work Coordinate
YWork = GetOEMDRO(801)  ' Get Current Y Work Coordinate
XMachine = GetOemDRO(83)  ' Get Current X Machine Coordinate
YMachine = GetOemDRO(84)  ' Get Current Y Machine Coordinate
ZMachine = GetOemDRO(85)   ' Get Current Z Machine Coordinate

Code "G49"
Code "G0 G53 Z-1." 'Home Z
code "G53 X216.90 Y3069.85" 'Move into Probe Pos ***EDIT HERE***
DoOEMButton(179) ' machine coordinates
Tool_Number = GetDRO(24)
code "G91 g31 z-200. f300." ' Z liigub alla 300 mm kuni probini
While (IsMoving())
  Sleep 30
Wend

code " g0 z 10" ' Z liigub üles 10  mm


code "G91 g31 z-15 f20." ' Z liigub alla 15 mm kuni probini

While (IsMoving())
  Sleep 10
Wend

If Tool_Number = 0 Then 'Master tool Cal
z = GetOEMDRO(85) 'get Machine ZPos
Call SetOEMDRO(49,z) 'Set g54 z offset
Else

Call SetDRO(24,0) 'Turn off the tool offset by loading tool #0
Height = GetDRO(2) 'Get the pos of the Z axis without the Tool comp on
Call SetDRO(24,Tool_Number) 'Turn the tool Back on so the offset will go to the
Call SetoemDRO(42,Height) 'Set the Tool Height offset
End If

DoOEMButton(181) 'back To program coordinates
code "G0 G90 G53 Z-1.0  F1000"
code "G43"
While (IsMoving())
  Sleep 10
Wend

Code "G0 X" & XWork & " Y" & YWork ' Returns to the previous XY job location
sleep(500)
While IsMoving()
sleep(20)
Wend


rem End If
           
   
rem End If
           
   

Offline TPS

*
  •  2,501 2,501
    • View Profile
Re: Mach3 can only "Auto-tool zero" once per session
« Reply #7 on: January 29, 2021, 09:32:32 AM »
how far is your distance from Zhome to probepoint?
anything is possible, just try to do it.
if you find some mistakes, in my bad bavarian english,they are yours.
Re: Mach3 can only "Auto-tool zero" once per session
« Reply #8 on: January 29, 2021, 09:44:47 AM »
how far is your distance from Zhome to probepoint?

It depends on what bit I have on the spindle, but it ranges from 150 to 180mm. None of them go over 200 and the Z stops wayyyyyyy above the probe when I try to auto-tool zero back to back.

For example, at the moment I have a 6mm end mill, the Z value is -160.5828something. If I would try to auto-tool zero again (I have run a few gCodes through in this session), it would change the value to -25.00000.

Offline TPS

*
  •  2,501 2,501
    • View Profile
Re: Mach3 can only "Auto-tool zero" once per session
« Reply #9 on: January 29, 2021, 09:46:44 AM »
made some changes, see wether they help, keep a copy of your existing code!!

Code: [Select]
'X/Y/Z referenced?
If getoemled(807) Or getoemled(808) Or getoemled(809) Then 'Kontrolli kas nullimise ledid polevad
DoOEMBUTTON(1021)
MsgBox "Teljed nullimata"
Exit Sub
End If

'probe input allready active
If GetOemled(825) <> 0 Then
DoOEMBUTTON(1021)
MsgBox "Testi raadioandurit"
Exit Sub
End If

XWork = GetOEMDRO(800)  ' Get Current X Work Coordinate
YWork = GetOEMDRO(801)  ' Get Current Y Work Coordinate
XMachine = GetOemDRO(83)  ' Get Current X Machine Coordinate
YMachine = GetOemDRO(84)  ' Get Current Y Machine Coordinate
ZMachine = GetOemDRO(85)    ' Get Current Z Machine Coordinate

Code "G49" ' cancel tool lenght offset
Code "G0 G53 Z-1" ' Home Z
code "G53 X216.90 Y3069.85" ' Move into Probe Pos ***EDIT HERE***
DoOEMButton(179) ' machine coordinates
Tool_Number = GetDRO(24) ' get actual Tool number

'fast probe
code "G31 Z-200 F300" ' Z liigub alla 300 mm kuni probini
While IsMoving()
Sleep(30)
Wend

code "G91 G0 Z10" ' Z liigub üles 10  mm
Code "G90"
While IsMoving()
Sleep(30)
Wend


'slow probe
code "G31 Z-15 F20" ' Z liigub alla 15 mm kuni probini
While IsMoving()
  Sleep(10)
Wend

If Tool_Number = 0 Then ' Master tool Cal
z = GetOEMDRO(85) ' get Machine ZPos
Call SetOEMDRO(49,z) ' Set g54 z offset
Else
Call SetDRO(24,0) ' Turn off the tool offset by loading tool #0
Height = GetDRO(2) ' Get the pos of the Z axis without the Tool comp on
Call SetDRO(24,Tool_Number) ' Turn the tool Back on so the offset will go to the
Call SetoemDRO(42,Height) ' Set the Tool Height offset
End If

DoOEMButton(181) ' back To program coordinates
code "G0 G90 G53 Z-1  F1000"
code "G43"
While IsMoving()
Sleep 10
Wend

Code "G0 X" & XWork & " Y" & YWork ' Returns to the previous XY job location
sleep(500)
While IsMoving()
sleep(20)
Wend
 
   

anything is possible, just try to do it.
if you find some mistakes, in my bad bavarian english,they are yours.