Hello Guest it is April 20, 2024, 12:12:48 AM

Author Topic: Auto tool zero  (Read 4306 times)

0 Members and 1 Guest are viewing this topic.

Auto tool zero
« on: January 24, 2022, 06:42:58 PM »
I've downloaded the CNC nuts script and I'm struggling to get the script working on my machine.
The digitize light flashes when the bit contacts the plate.
When I press auto tool zero and touch the plate on the bit to start, it starts to probe but doesn't stop when it makes contact.
Do you know why this would be ?

Im using Mach3 R3.043.062 and a AXbb-E controller

https://www.youtube.com/watch?v=jrUEULgGbFg&t=1050s

If the ports and pins setup was wrong would the digitize light illuminate when I test it?
Re: Auto tool zero
« Reply #1 on: January 25, 2022, 05:15:00 AM »
Please could you post the script so we don't have to go and find it?

You shouldn't need to touch the plate to start!  That's to stop!

The digitise light should show if ports and pins is correct, but maybe you have the sense set wrong?  Is it set active high or low?
Re: Auto tool zero
« Reply #2 on: January 25, 2022, 01:57:49 PM »
Below is the script, it asked you to touch the Proble to start the auto zero, I believe it written into the script.

The digitise light dose light up when they touch, active low is not selected. (when selected the digitise light it on all time and goes off when they contact)


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 = 3.20 '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 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     

       
                 
 
 
     
 
         

Re: Auto tool zero
« Reply #3 on: January 26, 2022, 05:36:56 AM »
Hmmm.  Well for several reasons I don't think the use model is very good for this.  So you have to first manually touch the setter to the end of the tool, then get it in position, hoping that the macro gives you enough time.  So the tool has to be high enough to get the setter underneath, then it moves down quite fast so you aren't waiting all day.  For an ordinary end mill that could work, but for a fine point engraving cutter you have two hazards - when you touch the plate to the point and when the point hits the plate on the probing move. 

I have an alternative macro, which is really just a copy of one I found on here, that works well and is triggered by pressing Auto Tool Zero on the Mach run screen.  My "touch plate" is an isolated spring-loaded button at a known height above the table mounted in a block with a magnet on the bottom that sticks it to the table.  The working macro is on the shop PC so I'll have to search for it but will send you a copy.  It has similarities but differences to the code you posted.  In use I jog the tool just above the centre of the button using an XBox controller, hit the Auto button, the tool moves down rather slowly until it touches, then lifts a little bit, probes down much more slowly until it touches again, sets the Z DRO to the actual setter height, and moves up to Z=50mm.

Offline TPS

*
  •  2,505 2,505
    • View Profile
Re: Auto tool zero
« Reply #4 on: January 26, 2022, 05:55:35 AM »
your script uses Var(2002) for z-probe hitposition.
most of the chinese controller do not support these var's.

try to replace:
 
ZProbePos = GetVar(2002)

by:

ZProbePos = GetDRO(2)


and try.
anything is possible, just try to do it.
if you find some mistakes, in my bad bavarian english,they are yours.
Re: Auto tool zero
« Reply #5 on: January 26, 2022, 11:52:20 AM »
Well for what it's worth here is my code, which I adapted from someone else's found on here.

'Tool Height Setting Macro - JLH v1.1 - 4 March 2013
'This version has a 2-phase approach, fast for speed & slow for precision.
CurrentAbsInc = GetOemLED (48) 'Copy current G90/G91 state
CurrentGMode = GetOemDRO (819) 'Copy current G0/G1 state
CurrentFeed = GetOemDRO (818) 'Copy current feedrate
Contact = 0 'Clear the contact flag
PlateThickness = 38.84 'Touch Plate thickness is set here
ProbeFeed1 = 50 'Fast probing feedrate is set here
ProbeFeed2 = 5 'Slow probing feedrate is set here
SetVar (1, -5) 'Maximum probing distance is set here
SetVar (2, 50) 'Retract height is set here
Code "M5" 'Ensures spindle is not running
Code "G21" 'Ensure metric units are used
Zs = GetOemDRO (61) 'Copy current Z-Scale DRO
Call SetOemDRO (61,1) 'Set Z-Scale DRO to 1
DoOemButton (1010) 'Zero Z-Axis DRO
Code "(Setting Tool Zero)" 'Message for status bar
While IsMoving () 'Wait until task has been completed
Wend
If GetOemLED (825) = 0 Then 'Check to see if touch plate is not already grounded
Code "G90 G31 Z #1 F" & ProbeFeed1 'Fast probing move
While IsMoving () 'Wait until task has been completed
Wend
If GetOemLED (825) = True Then 'Check to see if probe has touched plate
Contact = 1 'Set the contact flag
End If
DoOemButton (1003) 'Clear a possible feed-hold condition
ProbePos = GetVar (2002) 'Exact point probe touched
ProbePos = ProbePos + 1 'Displace probe position upwards by 1mm
Code "G0 Z" & ProbePos 'Lifts probe 1 above fast feed endpoint
While IsMoving () 'Wait until task has been completed
Wend
Code "G90 G31 Z #1 F" & ProbeFeed2 'Slow probing move
While IsMoving () 'Wait until task has been completed
Wend
If GetOemLED (825) = True Then 'Check to see if probe has touched plate
Contact = 1 'Set the contact flag
End If
ProbePos = GetVar (2002) 'Exact point probe touched
Code "G0 Z" & ProbePos 'Lifts probe to exact touch position
While IsMoving () 'Wait until task has been completed
Wend
Call SetDRO (2,PlateThickness) 'Set Z-Axis DRO to Touch Plate thickness
Code "G0 Z #2" 'Retract off Touch Plate to the set height
While IsMoving () 'Wait until task has been completed
Wend
Code "(Z-Axis is now Referenced.)" 'Message for status bar
Code "F" & CurrentFeed 'Restore feedrate to original setting
If Contact = 0 Then 'Probe reached max travel without touching
Code "(ERROR - Probe did not touch.)" 'Message for status bar
Response = MsgBox ("ERROR - Probe did not touch.",37,"Auto Tool Zero")
End If
Else
Code "(ERROR - Touch Plate is grounded.)" 'Message for status bar
Response = MsgBox ("ERROR - Touch Plate is grounded - Check connection.",16,"Auto Tool Zero")
End If
Call SetOemDRO (61,Zs) 'Restore Z-Scale DRO to original setting
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