586,647 active members*
2,264 visitors online*
Register for free
Login
Results 1 to 3 of 3
  1. #1
    Join Date
    Sep 2006
    Posts
    20

    Auto Tool Zero VBA Code gives Syntax Error

    I have programmed in VBA before, but usually when I make a mistake, I am told exactly what is wrong, or at least where it is. So now that I am trying to add the "Aussie Auto Tool Zero" code with a copper plate, I am lost.

    The thread I am talking about is here: http://www.cnczone.com/forums/showthread.php?t=36099

    I have added the copper plate, and verified that it is working through the diagnostics screen.

    I edited the standard screen to include an LED and a user DRO for the plate thickness input.

    I then simply copied and pasted the code into the already present auto tool zero button.

    Here is the code I used:

    CurrentFeed = GetOemDRO(818) 'Get the current feedrate to return to later
    PlateThickness = GetUserDRO(1151) 'Z-plate thickness DRO

    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
    Code "G31Z-20 F100" 'probing move, can set the feed rate here as well as how far to move
    While IsMoving() 'wait while it happens
    Wend
    ZProbePos = GetVar(2002) 'get the axact point the probe was hit
    Code "G0 Z" &ZProbePos 'go back to that point, always a very small amount of overrun
    While IsMoving ()
    Wend
    Call SetDro (2, PlateThickness) 'set the Z axis DRO to whatever is set as plate thickness
    Code "G4 P0.25" 'Pause for Dro to update.
    Code "G0 Z20" 'put the Z retract height you want here
    Code "(Z axis is now zeroed)" 'puts this message in the status bar
    Code "F" &CurrentFeed 'Returns to prior feed rate
    Else
    Code "(Z-Plate is grounded, check connection and try again)" 'this goes in the status bar if aplicable
    Exit Sub
    End If

    I know I will have to change the distances and the feedrates, but I haven't even gotten it to move at all. As soon as I click on the button, it comes up with a syntax error.

    Am I missing something else that needs editted in the screen? Or am I missing something even more basic?

    Let me know if you need any more information, I am not sure what else someone may need to diagnose the problem, or point me in the right direction.

  2. #2
    Join Date
    Sep 2006
    Posts
    20

    Nevermind.

    I am still not sure what was wrong, but I used some code from mach support site instead of the code listed, and it all works fine. If anyone wishes to clear up why the above code didn't work, by all means, though!

  3. #3
    Join Date
    May 2006
    Posts
    1469
    kiltjim

    The code you posted looks good. Don't know why it was not working for you.

    Just to be sure I was not missing some small typo, I pasted it directly from your post into Mach's VB scripter window and it ran as it should.

    What version of Mach are you running? There have been some versions with with problems running VB

    Greg

Similar Threads

  1. Auto tool zero
    By kentavv in forum Mach Mill
    Replies: 30
    Last Post: 10-08-2010, 05:03 PM
  2. Problems with auto tool zero
    By Mephysto in forum Mach Software (ArtSoft software)
    Replies: 3
    Last Post: 12-15-2008, 01:43 AM
  3. Auto cad 3d draw to g-code
    By jorgeneo560 in forum Autodesk
    Replies: 5
    Last Post: 08-03-2008, 06:27 AM
  4. Auto Tool Zero
    By Moondog in forum Machines running Mach Software
    Replies: 13
    Last Post: 12-23-2006, 01:02 AM
  5. syntax error
    By pyroracing85 in forum G-Code Programing
    Replies: 9
    Last Post: 01-28-2005, 02:09 AM

Posting Permissions

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