Hello Guest it is April 19, 2024, 12:24:45 PM

Author Topic: Secondary tool z zero  (Read 2347 times)

0 Members and 1 Guest are viewing this topic.

Secondary tool z zero
« on: December 21, 2016, 11:02:57 AM »
I am struggling with getting the Z height correct after a tool change...eg when doing VCarving and using a flat area tool, I always have lines in the workpeice (wood)...I am as carfefull as I can be when doing the second Z zero (new tool to the top of the work peice with my touch plate), but sometimes it is hard to do, so I am ready to build a second fixed touch off plate...
Have a couple of questions...
from what I have been reading, you touch off your first tool as normal, then touch the first tool on your second plate...do you store this value somewhere?
Haven't got is completely in my head yet, on the next tool change, I understand you go to your fixed plate, after you get the new Z dro, do you add, or subtract the difference from your "stored" number? Or am I missing something simple? I would think you would have to offset you current zero to a new zero based on the second fixed probe, jsut not sure what steps to take...is there some example code somewhere?

Thanks
Leslie
Re: Secondary tool z zero
« Reply #1 on: December 22, 2016, 07:17:45 PM »
I think I have it worked out...simple really (If I am doing it correctly!) just have to grab the remote Z touch value after you set the first tool...then on the next tools, just go remote, probe till it stops, then write the value you got the on the first tool into the Z...I tried to get clever and use the gcode line number to automatically run the correct code...anyway I am posting it for review and comments...



' This routine checks if this is the first time tool change using the current GCode line number
' less than 20 means this is the first tool change
' then it does the correct Z touch off

lnum = GetOEMDro(816)           'Get the current line number in the code window
PlateOffset = GetUserDRO(1151)   'Get plate offset DRO
CurrentFeed = GetOemDRO(818)    'Get the current feedrate to return to later


If lnum < 20 Then ' must be the first one

  If GetOemLed (825) <> 0 Then    'Check to see if the probe is already grounded or faulty
    Code "(Z-Plate is grounded, check connection and try again)" 'this goes in the status bar
  Else
    Code "G4 P1"      'Pause 1 seconds to give time to position probe plate
    Code "F4"         'slow down feedrate to 4 ipm

    'Probe wherever we are
    ZNew = GetDro(2) - 2   'probe move to current z - 2 inches
    Code "G31Z" &ZNew
    While IsMoving()      'wait for probe move to finish
    Wend

    ZNew = GetVar(2002)    'read the touch point
    Code "G0 Z" &ZNew       'move back to hit point incase there was overshoot
    While IsMoving ()
    Wend

    If PlateOffset <> 0 Then
      Call SetDro (2, PlateOffset) 'set the Z axis DRO to  plate thickness
      Code "G4 P0.25"          'Pause for Dro to update.

      'now lets probe at the remote point to get the Z dro offset for subssequent tool changes
      Code "G53F200Z-.1" 'go to a safe Z
      While IsMoving()
      Wend
      CODE "G53F200X0.315Y4.125" 'go to where the remote touch off is
      While IsMoving()
      Wend
      CODE "G53F200Z-2.5"        'come down fast to get us close
      While IsMoving()
      Wend

      MsgBox "Move the touch plate to the remote location. Press okay to continue" ' let the op know
     
      CODE "G31F4Z-2"            'do the probe thing
      While IsMoving()
      Wend

      Code "G4 P1"               'hold on on second for the DRO to update
      tooloffset = GetDro(2)

      SetUserDRO(1205, tooloffset) 'set the Z DRO to the value we got when the initial Z touch was done

      Code "G53F200Z-.1"  'go to a safe Z height
      While IsMoving()
      Wend

      Code "G0X0Y0"       'go back to 0
      
    End If
    Code "F" &CurrentFeed 'Returns to prior feed rate
  End If
Else

  If GetOemLed (825) <> 0 Then       'Check to see if the probe is already grounded or faulty
    Code "(Z-Plate is grounded, check connection and try again)" 'this goes in the status bar if aplicable
  Else
    Code "G4 P1"         'Pause 1 seconds to give time to position probe plate
    PlateOffset = GetUserDRO(1151)   'Get plate offset DRO
    CurrentFeed = GetOemDRO(818)    'Get the current feedrate to return to later
    Code "F4"                  'slow down feedrate to 4 ipm

    Code "G53F200Z-.1"                  'go to a safe Z height
    While IsMoving()
    Wend
    CODE "G53F200X0.315Y4.125"          'go to where the remote touch off is
    While IsMoving()
    Wend
    CODE "G53F200Z-2.5"                 'get close on the Z at a fast rate
    While IsMoving()
    Wend

    MsgBox "Move the touch plate to the remote location. Press okay to continue" ' let the op know

    CODE "G31F4Z-1"         'now lets probe Z
    While IsMoving()
    Wend

    Code "G4 P1"         'give it s second to update
    toolOffset = GetUserDRO(1205)
    Call SetDro (2, toolOffset)      'set the Z DRO to the offsset value we got when we did the first tool

    Code "G53F200Z-.1"         'go to a safe Z height
    While IsMoving()
    Wend

    Code "F" &CurrentFeed       'Returns to prior feed rate

  End If
   
End If
Re: Secondary tool z zero
« Reply #2 on: December 22, 2016, 07:20:56 PM »
I could really clean up the code and get rid of duplicates if there was a way to call scripts from other scripts can this be done? I can have a script for each of the Z touch off moves and call them when needed, even add the calls to the m6Start routing to make it more automated...

An thoughts? Can you call a script from another script?

Thanks
Leslie
Re: Secondary tool z zero
« Reply #3 on: December 23, 2016, 12:57:36 AM »
Why wouldn't RunScript do what I wanted?

‘ Run script example
If RunScript(“MsgBoxScript”) < 0 then
 Msgbox “RunScript returned an error”
Else
 Msgbox “Script ran”
End If
Where the file MsgBoxScript.m1s contains
MsgBox “Message from script file”
Will result show a dialog box with the content “Message from script file”.
Followed by a dialog that says “Script Ran”
Re: Secondary tool z zero
« Reply #4 on: December 23, 2016, 09:02:15 AM »
Figured out the runscript issue...I assumed that Mach3 knew where the script was based on the profile, but it assumes the root of Mach3...just added the path and it works great!