Machsupport Forum

Mach Discussion => General Mach Discussion => Topic started by: AD on November 02, 2019, 12:08:34 PM

Title: Auto Tool Zero - Sets incorrect Z zero (another A/T issue from GCode illiterate)
Post by: AD on November 02, 2019, 12:08:34 PM
OK.. got the Touch Plate hooked up correctly now, and tried two different scripts for Auto Tool Zero..
Issue I am getting is scripts run fine the bit moves down to touch the plate stops and moves up to offset position.
When I hit G0Z0 or Go to Zero, the bit heads down to the alleged 0 but it does not reach the correct 0 for the stock used. It is off by half an inch or so.. with either script.

Thanks much.
Title: Re: Auto Tool Zero - Sets incorrect Z zero (another A/T issue from GCode illiterate)
Post by: TPS on November 02, 2019, 03:35:06 PM
ok first of all, try to learn reading scipts, it is not just copy and paste , and everybody is happy.
ok "your" first script:

Code: [Select]
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

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 P3" 'this delay gives me time to get from computer to hold probe in place
Code "G90 G31Z-4. F4" '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 exact 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, .060) 'change .060 to your plate thickness and then adjust for final accuracy
Sleep 200 'Pause for Dro to update.
Code "G1 Z1. F50" 'put the Z retract height you want here, must be greater than the touch plate thickness
While IsMoving ()
Wend
Code "(Z axis is now zeroed)" 'puts this message in the status bar
Code "F" &CurrentFeed 'Returns to prior feed rate
Else
Code "(Z-Plate is grounded, check connection and try again)" 'this goes in the status bar if applicable
End If

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   

this code line:
Code: [Select]
[color=red] Call SetDro (2, .060) 'change .060 to your plate thickness and then adjust for final accuracy
[/color]

will set your "new" z-Zero to 0.600 how ever it will not be your touch plate height


Title: Re: Auto Tool Zero - Sets incorrect Z zero (another A/T issue from GCode illiterate)
Post by: AD on November 02, 2019, 04:11:53 PM
Well, after some hours of diddling with this, I found that a lot of people have this issue unresolved and that controversy of this "simple" thing has been going on for years. These two scripts I posted have been out for awhile and work like a charm for many, many but not for all. Not sure if the issue is with my cheap USB controller or else..

Now, I am not that uneducated as I jokingly declared and I did of course read carefully and changed the values for the plate thickness, retract offset and the rest,yet the issue is deeper here.

At the moment I got only this: if I ostracize any of codes out there to what I attached as "Dumbo" script I attached here I can get the Auto Tool Zero to lower the bit down touch the plate and stop. This lets me to manually Zero the Z, remove the plate than do G1Z-0.76 which is my plate thickness and Zero the Z again. Hence how I got the name for "my" first script.

So the issue is not with G31 command in my case but rather with setting the DRO to Zero after the bit hits the probe, it looks like.
Title: Re: Auto Tool Zero - Sets incorrect Z zero (another A/T issue from GCode illiterate)
Post by: AD on November 02, 2019, 08:13:15 PM
The answer to my problem was discussed in "New Guy Frustration LOL post", which you can search and read.

The code these guys found to work for Chinese Boards like my STB5100 (USB) is copied bellow..
The issue was about some boards like mine, not supporting the GetVar() command.

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

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 P3" ' this delay gives me time to get from computer to hold probe in place
Code "G90 G31Z-1. F4" 'probing move, can set the feed rate here as well as how far to move
While IsMoving() 'wait while it happens
Wend
ZProbePos = GetOEMDro(802)  'get the exact 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, .766) ' change 0.060 to your plate thickness and then adjust for final accuracy
Sleep 200 'Pause for Dro to update.
Code "G1 Z1. F5" 'put the Z retract height you want here, must be greater than the touch plate thickness
While IsMoving ()
Wend
Code "(Z axis is now zeroed)" 'puts this message in the status bar
Code "F" &CurrentFeed 'Returns to prior feed rate
Else
Code "(Z-Plate is grounded, check connection and try again)" 'this goes in the status bar if applicable
End If
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