Hello Guest it is March 29, 2024, 08:02:49 AM

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - krazyjay95

Pages: 1
1
General Mach Discussion / Auto tool zero scfipt
« on: October 31, 2019, 07:25:50 PM »
I have just set up a home built cnc router and I'm having a few issues with the auto tool zero!!!! When I press the button everything runs great but after I get my message that the z axis has been zeroed, but when I press go to zro button my tool stops short by 4 mm! Not sure what i am doing wrong. Here is the script that I am running I'm hoping someone can help me:

'VB Code Start
'-------------------
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 = 19.19 'Touch Plate thickness is set here
ProbeFeed = 100 'Probing feedrate is set here
SetVar (1, -30) 'Maximum probing distance is set here
SetVar (2, 5) '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
Label1: 'Entry point for Retry
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 already grounded
Code "G90 G31 Z #1 F" & ProbeFeed '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 'Go back to exact point of touch if there was any overrun
While IsMoving () 'Wait until task has been completed
Wend
Call SetDRO (2,PlateThickness) 'Set Z-Axis DRO to Touch Plate thickness
Code "G0 Z 25" 'Retract off Touch Plate the set distance
While IsMoving () 'Wait until task has been completed
Wend
Code "(Z-Axis is now Zeroed.)" '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")
If (Response = 4) Then 'User chose Retry
GoTo Label1 'Retry Probing routine
End If
End If
Else
Code "(ERROR - Touch Plate is grounded.)" 'Message for status bar
Response = MsgBox ("ERROR - Touch Plate is grounded.",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

 '-------------------
'VB Code Stop

Pages: 1