Hello Guest it is December 13, 2019, 05:00:34 AM

Author Topic: off the shelf auto zero script issue  (Read 755 times)

0 Members and 1 Guest are viewing this topic.

off the shelf auto zero script issue
« on: June 01, 2019, 03:08:54 PM »
i have been using the following script i got from youtube for auto zero .
you have a plate a certain thickness the tool will touch retract then come in slow ,retract  add the plate thickness and give you a z height from the part .

i have used this a few times on my mill.

i have an issue either with the script or my set up .

every now and again   it touches , stops  but instead of retracting it up  .it goes in the opposite direction and pushes into the plate .for me z zero is top of stock

any ideas??


i have been using the following script i got from youtube for auto zero .
you have a plate a certain thickness the tool will touch retract then come in slow ,retract  add the plate thickness and give you a z height from the part .

i have used this a few times on my mill.

i have an issue either with the script or my set up .

every now and again   it touches , stops  but instead of retracting it up  .it goes in the opposite direction and pushes into the plate .for me z zero is top of stock

any ideas?
i have been using the following script i got from youtube for auto zero .
you have a plate a certain thickness the tool will touch retract then come in slow ,retract  add the plate thickness and give you a z height from the part .

i have used this a few times on my mill.

i have an issue either with the script or my set up .

every now and again   it touches , stops  but instead of retracting it up  .it goes in the opposite direction and pushes into the plate .for me z zero is top of stock

any ideas?



REM Updated 30 Aug 2018
REM Auto Tool Zero Z- Metric 2 pass Version
REM Based On the BigTex script
REM (09 Feb 2018)  Hint added To Material Thickness offset request box.
REM (20 Feb 2018)  Request To touch the touch the touchoff plate To the bit To start probing added. Thanks To Glen Higgs For this addition.
REM (27 Jul 2018)  Minor changes To Error Handling And Grammer correction
REM (30 Aug 2018)  Feedrate override safety Reset And restore added.

PlateThickness = 19.86 'Enter Z-plate thickness here
DownStroke = -100 'Set the down stroke to find probe
DownFeedRate = 250 'Set the down FeedRate
RetractStroke = 10 'Set the retract Stroke
RetractFeedRate = 1000 'Set the retract FeedRate
SmallRetractStroke = 1 'Retract 1mm for a 2nd pass
SmallDownFeedRate = 25 'Set the slow down FeedRate for 2nd pass
SmallDownStroke = -(SmallRetractStroke *2) 'Set down stroke for 2nd pass as twice the retract distance.
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
CurrentFeedOverride = GetOEMDRO(821)'Get current Feedrate override setting

REM Request Material Thickness offset
Offset  = InputBox("Enter Material Thickness offset          Hint: To probe from the Spoilboard surface, enter the nominal thickness of the material.  Enter '0' or leave blank if probing from the material surface", "Material Offset", "") 

REM  Touch plate To Cutter To Begin probe.
message "Briefly touch the plate to the bit to start probing for zero."
Touched_Flag = False
   count = 40
seconds = 60
    For i = 1 To 600
        If GetOEMLed(825) <> 0 Then               
            Beep
            Touched_Flag = True
            Exit For
        End If
        count = count - 1
        If count = 0 Then ' 1 second elapsed
            count = 40
            seconds = seconds -1
        End If
        Sleep 25
   Next i
If Touched_Flag = False Then
    message "The Auto Zero timed out, no touch detected"
    Exit Sub
End If

REM 1st Pass at fast rate

sleep 2000  'give time to remove block from tool and position
REM Code "(Z axis 1st pass)" 'puts this message in the status bar   
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 P2" ' this delay gives me time to get from computer to hold probe in place
SetOEMDRO(821,100)  'Reset feedrate overide to 100% for safety
Code "G90 G31 Z" &DownStroke &" F" &DownFeedRate 'probing move
While IsMoving() 'wait while it happens
Wend
ZProbePos = GetVar(2002) 'get the exact point the probe was hit
If Abs(ZprobePos) <= Abs(DownStroke)-0.1 Then 'Check if the probe has been found
Code "G0 Z" &ZProbePos 'go back to that point, always a very small amount of overrun
While IsMoving ()
Wend
Call SetDro (2, 0) 'set the Z axis DRO to whatever is set as plate thickness less the offset value
Code "G4 P0.25" 'Pause for Dro to update.
Code "G1 Z" &SmallRetractStroke &" F" &RetractFeedRate 'retract
While IsMoving ()
Wend
REM Code "(Z axis 2nd pass)" 'puts this message in the status bar   
Else
Rem Code "G0 Z0" 'retract to start pos
While IsMoving ()
Wend
Code "(Z-Plate not found, check connection or stroke and try again)" 'puts this message in the status bar
Code "F" &CurrentFeed 'Returns to prior feed rate
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
Exit Sub
End If
Else
Code "(Z-Plate is grounded, check connection and try again)" 'this goes in the status bar if aplicable
End If
Code "F" &CurrentFeed 'Returns to prior feed rate
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

REM 2nd pass at slow rate

DoOEMButton (1010) 'zero the Z axis so the probe move will start from here
Code "G4 P1" ' this delay gives me time to get from computer to hold probe in place
Code "G90 G31 Z" &SmallDownStroke &" F" &SmallDownFeedRate 'probing move
While IsMoving() 'wait while it happens
Wend
ZProbePos = GetVar(2002) 'get the exact point the probe was hit
If Abs(ZprobePos) <= Abs(SmallDownStroke)-0.1 Then 'Check if the probe has been found
Code "G0 Z" &ZProbePos 'go back to that point, always a very small amount of overrun
While IsMoving ()
Wend
Call SetDro (2, PlateThickness - offset) 'set the Z axis DRO to whatever is set as plate thickness less the offset value
Code "G4 P0.25" 'Pause for Dro to update.
Code "G1 Z" &RetractStroke + PlateThickness &" F" &RetractFeedRate 'retract
While IsMoving ()
Wend
Code "(Z axis is now zeroed)" 'puts this message in the status bar   
Else
Code "G0 Z0" 'retract to start pos
While IsMoving ()
Wend
Code "(Z-Plate not found, check connection or stroke and try again)" 'puts this message in the status bar
End If
Code "F" &CurrentFeed 'Returns to prior feed rate
SetOEMDRO(821,CurrentFeedOverride) 'Return feedrate override to previous value
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
Exit Sub     
« Last Edit: June 01, 2019, 03:11:35 PM by chessie »

Offline ger21

*
  • *
  •  6,291 6,291
    • View Profile
    • The CNC Woodworker
Re: off the shelf auto zero script issue
« Reply #1 on: June 01, 2019, 03:16:40 PM »
Are you using the parallel port, or a motion controller?
If a motion controller, which one?
Gerry

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

JointCAM Dovetail and Box Joint software
http://www.g-forcecnc.com/jointcam.html
Re: off the shelf auto zero script issue
« Reply #2 on: June 01, 2019, 03:24:54 PM »
Parallel ports

Online TPS

*
  •  1,411 1,411
    • View Profile
Re: off the shelf auto zero script issue
« Reply #3 on: June 02, 2019, 03:08:42 AM »
had a quick look to the code.

here it is asking for a Offset:
Code: [Select]
REM Request Material Thickness offset
Offset  = InputBox("Enter Material Thickness offset          Hint: To probe from the Spoilboard surface, enter the nominal thickness of the material.  Enter '0' or leave blank if probing from the material surface", "Material Offset", "") 

Offset is written with capital O


here this value is used:
Code: [Select]
Call SetDro (2, PlateThickness - offset) 'set the Z axis DRO to whatever is set as plate thickness less the offset value

offset is written with small o

correct this, copy the complete code into VB Scripter window and use ||> key to step through and see where (witch line) the
code goes wrong.


anything is possible, just try it.
if you find some mistakes, in my bad bavarian english,they are yours.
Re: off the shelf auto zero script issue
« Reply #4 on: June 02, 2019, 07:35:19 AM »
Thanks
i changed the o and it still does it .   the first  time i start mach3 it works ok . if i try again instead of retract fast for 2nd touch it goes fast in opposite direction and broke my touchplate.

  Then if you do nothing and wait it starts to creep the z slowly in the - direction .
i guess its my set up as this is used by alot of people i presume with no problems


Online TPS

*
  •  1,411 1,411
    • View Profile
Re: off the shelf auto zero script issue
« Reply #5 on: June 02, 2019, 07:45:17 AM »
give this code a try:

Code: [Select]
REM Updated 30 Aug 2018
REM Auto Tool Zero Z- Metric 2 pass Version
REM Based On the BigTex script
REM (09 Feb 2018)  Hint added To Material Thickness offset request box.
REM (20 Feb 2018)  Request To touch the touch the touchoff plate To the bit To start probing added. Thanks To Glen Higgs For this addition.
REM (27 Jul 2018)  Minor changes To Error Handling And Grammer correction
REM (30 Aug 2018)  Feedrate override safety Reset And restore added.

PlateThickness = 19.86 'Enter Z-plate thickness here
DownStroke = -100 'Set the down stroke to find probe
DownFeedRate = 250 'Set the down FeedRate
RetractStroke = 10 'Set the retract Stroke
RetractFeedRate = 1000 'Set the retract FeedRate
SmallRetractStroke = 1 'Retract 1mm for a 2nd pass
SmallDownFeedRate = 25 'Set the slow down FeedRate for 2nd pass
SmallDownStroke = -(SmallRetractStroke *2) 'Set down stroke for 2nd pass as twice the retract distance.
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
CurrentFeedOverride = GetOEMDRO(821)'Get current Feedrate override setting

REM Request Material Thickness offset
Offset  = InputBox("Enter Material Thickness offset          Hint: To probe from the Spoilboard surface, enter the nominal thickness of the material.  Enter '0' or leave blank if probing from the material surface", "Material Offset", "") 

REM  Touch plate To Cutter To Begin probe.
message "Briefly touch the plate to the bit to start probing for zero."
Touched_Flag = False
count = 40
seconds = 60
    For i = 1 To 600
        If GetOEMLed(825) <> 0 Then               
            Beep
            Touched_Flag = True
            Exit For
        End If
        count = count - 1
        If count = 0 Then ' 1 second elapsed
            count = 40
            seconds = seconds -1
        End If
        Sleep 25
   Next i
If Touched_Flag = False Then
    message "The Auto Zero timed out, no touch detected"
    Exit Sub
End If

REM 1st Pass at fast rate

sleep 2000  'give time to remove block from tool and position

REM Code "(Z axis 1st pass)" 'puts this message in the status bar   
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
Sleep(500) ' this delay gives me time to get from computer to hold probe in place
SetOEMDRO(821,100)  'Reset feedrate overide to 100% for safety
Code "G90 G31 Z" &DownStroke &" F" &DownFeedRate 'probing move
While IsMoving() 'wait while it happens
Wend
ZProbePos = GetVar(2002) 'get the exact point the probe was hit
If Abs(ZprobePos) <= Abs(DownStroke)-0.1 Then 'Check if the probe has been found
Code "G0 Z" &ZProbePos 'go back to that point, always a very small amount of overrun
While IsMoving ()
Wend
Call SetDro (2, 0) 'set the Z axis DRO to whatever is set as plate thickness less the offset value
Sleep(500) 'Pause for Dro to update.
Code "G1 Z" &SmallRetractStroke &" F" &RetractFeedRate 'retract
While IsMoving ()
Wend
REM Code "(Z axis 2nd pass)" 'puts this message in the status bar   
Else
Rem Code "G0 Z0" 'retract to start pos
While IsMoving ()
Wend
Code "(Z-Plate not found, check connection or stroke and try again)" 'puts this message in the status bar
Code "F" &CurrentFeed 'Returns to prior feed rate
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
Exit Sub
End If
Else
Code "(Z-Plate is grounded, check connection and try again)" 'this goes in the status bar if aplicable
End If

Code "F" &CurrentFeed 'Returns to prior feed rate
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

REM 2nd pass at slow rate

DoOEMButton (1010) 'zero the Z axis so the probe move will start from here
Sleep(1000) ' this delay gives me time to get from computer to hold probe in place
Code "G90 G31 Z" &SmallDownStroke &" F" &SmallDownFeedRate 'probing move
While IsMoving() 'wait while it happens
Wend
ZProbePos = GetVar(2002) 'get the exact point the probe was hit
If Abs(ZprobePos) <= Abs(SmallDownStroke)-0.1 Then 'Check if the probe has been found
Code "G0 Z" &ZProbePos 'go back to that point, always a very small amount of overrun
While IsMoving ()
Wend
Call SetDro (2, PlateThickness - Offset) 'set the Z axis DRO to whatever is set as plate thickness less the offset value
Sleep(500) 'Pause for Dro to update.
Code "G1 Z" &RetractStroke + PlateThickness &" F" &RetractFeedRate 'retract
While IsMoving ()
Wend
Code "(Z axis is now zeroed)" 'puts this message in the status bar   
Else
Code "G0 Z0" 'retract to start pos
While IsMoving ()
Wend
Code "(Z-Plate not found, check connection or stroke and try again)" 'puts this message in the status bar
End If

Code "F" &CurrentFeed 'Returns to prior feed rate
SetOEMDRO(821,CurrentFeedOverride) 'Return feedrate override to previous value
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
Exit Sub     
anything is possible, just try it.
if you find some mistakes, in my bad bavarian english,they are yours.
Re: off the shelf auto zero script issue
« Reply #6 on: June 03, 2019, 10:51:56 AM »
Thanks again
seems to work a treat tried it 10 times and worked no issues

Online TPS

*
  •  1,411 1,411
    • View Profile
Re: off the shelf auto zero script issue
« Reply #7 on: June 03, 2019, 12:37:41 PM »
so i assume in Config -> General Config -> General Configuration -> G04 Dwel in MS is enabled?
Keep it like it is, but the original macro code used G04 for wait step's based on seconds.
i replaced them to sleep's witch are not based on any Setting.
anything is possible, just try it.
if you find some mistakes, in my bad bavarian english,they are yours.