603,794 active members*
4,732 visitors online*
Register for free
Login
Results 1 to 9 of 9
  1. #1
    Join Date
    Jan 2014
    Posts
    20

    Tool Zero Script Error After G-code Run

    Gents,

    I'm having an issue with my zero tool script, hoping someone can provide some help.

    Whenever I finish running G-Code and try to Auto-Zero my tool again in the Z-axis, the scrip works nothing like it should. If I restart Mach 3 with no G-code loaded and rerun the script it works without issue. Hoping there is an easy fix I'm missing, see below for a copy of my zero script code.

    Script:
    'Z AXIS HOME CODE
    x = MsgBox ("Home Z Axis?", 3,"Z Axis Home")

    If x = 6 Then

    Code "(Getting Ready to Home Z Axis in 5 seconds)"

    PlateHome = 1.485 + 0.2000 'Retract amount from Z Axis home when done.
    PlateHomeCommand = "G0 Z" + CStr(PlateHome)

    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 P5" ' give delay to hold fixture

    Code "G31Z-1 F5" 'probe move slow feed
    While IsMoving() 'wait for it to happen
    Wend

    ZProbePos = GetVar(2002) 'get the exact point the probe was hit
    Code "G0 Z" &ZProbePos 'go back to point
    While IsMoving ()
    Wend

    Call SetDro (2, 1.485) 'set the Z axis DRO to plate thickness
    Code "G4 P0.25" 'Pause for Dro to update.
    Code PlateHomeCommand '"G0 Z0.002" 'put the Z retract height you want here
    x = MsgBox ("Z axis is now zeroed",0,"Z Axis Home")
    Else
    Code "(Z-Plate is grounded, check connection and try again)" 'status bar
    x = MsgBox ("Z-Plate is grounded, check connection and try again",0 ,"Z Axis Home")

    End If
    End If


    Thanks,
    Shawn

  2. #2
    Join Date
    Mar 2003
    Posts
    35494

    Re: Tool Zero Script Error After G-code Run

    Define what "Works nothing like it should" means.
    What does it do?

    Is your g-code changing your motion mode from absolute to incremental, or incremental to absolute?
    Gerry

    UCCNC 2017 Screenset
    http://www.thecncwoodworker.com/2017.html

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

    JointCAM - CNC Dovetails & Box Joints
    http://www.g-forcecnc.com/jointcam.html

    (Note: The opinions expressed in this post are my own and are not necessarily those of CNCzone and its management)

  3. #3
    Join Date
    Jan 2014
    Posts
    20

    Re: Tool Zero Script Error After G-code Run

    ger21,

    Thanks for the fast reply....

    Normally the Zero script works as it should. The auto-tool button is pressed, the tool touches the plate and etc...

    When G-code is loaded, the tool touches the plate at normal speed and then continues to push through it, often breaking the bit, and then retracts to different heights each time.

    I will check the absolute to incremental, or incremental to absolute.

    Thanks for the help and your time.

    Regards,
    Shawn

  4. #4
    Join Date
    Sep 2009
    Posts
    1856

    Re: Tool Zero Script Error After G-code Run

    test with the spindle homed 25 mm or more above your work pieces and see what happens if it does not happen with the spindle homed 25 mm or more above you work pieces its the code where the fault is
    http://danielscnc.webs.com/

    being disabled is not a hindrance it gives you attitude
    [SIGPIC][/SIGPIC]

  5. #5
    Join Date
    Jan 2014
    Posts
    20

    Re: Tool Zero Script Error After G-code Run

    Daniellyall,

    Thanks for the reply, can you offer more about the 25mm? When I test above this height the same thing happens just the movements are not as large.

    ger21,

    When I start Mach 3 I believe I am in "IJ Incremental" mode, but my g-code has G90 in it. Could this be the problem? Please see photo below.

    Click image for larger version. 

Name:	2danexz.jpg 
Views:	1 
Size:	142.1 KB 
ID:	251948

  6. #6
    Join Date
    Mar 2003
    Posts
    35494

    Re: Tool Zero Script Error After G-code Run

    No, IJ mode is different and should have no effect.

    I was wondering if at some point your G90 changed to G91, or the other way around. That could definitely cause what you're seeing.

    It's good practice to have the macro check whether you're in G90 or G91, then set the appropriate mode prior to probing, and return it to the original value when exiting the macro.
    Gerry

    UCCNC 2017 Screenset
    http://www.thecncwoodworker.com/2017.html

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

    JointCAM - CNC Dovetails & Box Joints
    http://www.g-forcecnc.com/jointcam.html

    (Note: The opinions expressed in this post are my own and are not necessarily those of CNCzone and its management)

  7. #7
    Join Date
    Sep 2009
    Posts
    1856

    Re: Tool Zero Script Error After G-code Run

    The 25mm / 1 inch thing is something that can happen with scripts that don't account for retract.
    I would check that what ger21 say is not a problem first or if you use metric I will just post the code I use what has never been a problem for me.
    http://danielscnc.webs.com/

    being disabled is not a hindrance it gives you attitude
    [SIGPIC][/SIGPIC]

  8. #8
    Join Date
    Jan 2014
    Posts
    20

    Re: Tool Zero Script Error After G-code Run

    ger21,

    I have been researching for a macro to do what you say and have had no luck. I believe my code is switching from G90 to G91. Do you know of a macro to do what you are speaking of?

    daniellyall,

    You mind posting/pm'ing the code you use?


    Thanks,
    Shawn

  9. #9
    Join Date
    Mar 2003
    Posts
    35494

    Re: Tool Zero Script Error After G-code Run

    Gerry

    UCCNC 2017 Screenset
    http://www.thecncwoodworker.com/2017.html

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

    JointCAM - CNC Dovetails & Box Joints
    http://www.g-forcecnc.com/jointcam.html

    (Note: The opinions expressed in this post are my own and are not necessarily those of CNCzone and its management)

Similar Threads

  1. Z zero, error in script
    By mobjri in forum Mach Wizards, Macros, & Addons
    Replies: 1
    Last Post: 08-24-2013, 02:58 PM
  2. Script Error since 996
    By velocityxlrg in forum BobCad-Cam
    Replies: 1
    Last Post: 06-12-2013, 05:56 PM
  3. Auto Tool Zero VBA Code gives Syntax Error
    By kiltjim in forum Mach Wizards, Macros, & Addons
    Replies: 2
    Last Post: 02-03-2009, 12:32 AM
  4. Run G-code from script
    By leif_brunosson in forum LinuxCNC (formerly EMC2)
    Replies: 1
    Last Post: 11-11-2008, 08:39 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •