Machsupport Forum

Mach Discussion => VB and the development of wizards => Topic started by: PCH on February 24, 2021, 02:41:50 PM

Title: autotoolzero
Post by: PCH on February 24, 2021, 02:41:50 PM
I know my vb script is good.  I have changed out a gecko servo drive and now my z axis is not traveling down to touch plate even though I have 4" of travel.  I goes down various depths but will not go down to touch plate. It does retract to the designated height though.  Not sure what to do.  Any help is appreciated.
Title: Re: autotoolzero
Post by: ZASto on February 25, 2021, 02:55:34 AM
So, show us your script. Maybe it is not quite good.
Title: Re: autotoolzero
Post by: PCH on February 25, 2021, 12:51:15 PM
Here is my VB script:
It was working fine before I changed out my drive and now it will not go down to touch plate.   Stops a various depths


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

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 P3" ' this delay gives me time to get from computer to hold probe in place
Code "G90 G31Z-4. F4" '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 exact 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, .250) ' change .060 to your plate thickness and then adjust for final accuracy
Sleep 200 'Pause for Dro to update.
Code "G1 Z1. F50" 'put the Z retract height you want here, must be greater than the touch plate thickness
While IsMoving ()
Wend
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 applicable
End If
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   
Title: Autozerotool
Post by: PCH on February 25, 2021, 08:54:55 PM
My z axis is just retracting to set height.  It will not go down to touchplate.  My VB file is set to travel 4" before it gives up.  When I go to diagnostics and clip on line to router before initiate the zero button the digitizer flashes on intermitently.  .I do not think this should be happening.   Any suggestions would be great.  I am out of options.  Please help
Title: Re: Autozerotool
Post by: Graham Waterworth on February 25, 2021, 09:57:38 PM
Is this a new set up and macro or an old one that is now failing.
Title: Re: autotoolzero
Post by: Graham Waterworth on February 25, 2021, 10:12:40 PM
The way the script is written it uses G90 G31 so if you have offsets or have changed the z datum point the 4" move is relative to that. Also if a tool offset is active with a height offset not equal to zero that can also change the distance.

In most cases probing is done in G91 moves.
Title: Re: Autozerotool
Post by: PCH on February 26, 2021, 06:59:05 AM
Well it a new gecko 30x servo drive.  A newer version of the one I replaced.  And it is the VB script I have used all along which worked great until now.
Here is the script:
Code "G90 G31Z-4. F4" '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 exact 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, .250) ' change .060 to your plate thickness and then adjust for final accuracy
Sleep 200 'Pause for Dro to update.
Code "G1 Z1. F50" 'put the Z retract height you want here, must be greater than the touch plate thickness
While IsMoving ()
Wend
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 applicable
End If
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   
Title: Re: autotoolzero
Post by: PCH on February 26, 2021, 07:02:03 AM
So if I change the G90 to G91 in script that would do it?
Code "G90 G31Z-4. F4" 'probing move, can set the feed rate here as well as how far to move
Title: Re: autotoolzero
Post by: PCH on February 26, 2021, 07:13:44 AM
where would the z datum be that I would have inadvertently changed.
Title: Re: autotoolzero
Post by: PCH on February 26, 2021, 07:14:58 AM
also...thanks for getting back to me.
Title: Re: Autozerotool
Post by: TPS on February 26, 2021, 08:33:57 AM
but your new drive will drive 4" if youd do G91 Z-4 f10 for example in MDI Input
Title: Re: autotoolzero
Post by: PCH on February 27, 2021, 08:42:30 AM
Will give this a try this morning
Title: Re: autotoolzero
Post by: PCH on February 27, 2021, 10:03:10 AM
Yes the string worked and the z axis went down 4".....how do I edit the VB script to initiate this downward movement..thank you
Title: Re: autotoolzero
Post by: TPS on February 27, 2021, 10:41:56 AM
Change:
Code: [Select]
  Code "G90 G31 Z-4. F4" 'probing move, can set the feed rate here as well as how far to move
to:
Code: [Select]
  Code "G91 G31 Z-4. F4" 'probing move, can set the feed rate here as well as how far to move
Title: Re: autotoolzero
Post by: PCH on February 27, 2021, 11:33:50 AM
NOPE...STILL MOVES UPWARD WHEN I INITIATE THE AUTO ZERO TOOL...what can I try next
btw in diagnostics my digitizer led is flashing intermittently ....not sure why
Title: Re: autotoolzero
Post by: TPS on February 27, 2021, 11:45:03 AM
pls put this code at the beginning of your macro:

Code: [Select]
'probe already active ?
If GetOEMLed(825) Then
DoOEMButton(1003)
MsgBox "probe input activ",vbOK + vbCritical ,"error !"
End If

if a box with "probe input activ" is comming up you have to check your probe Input/wiring
Title: Re: autotoolzero
Post by: PCH on February 27, 2021, 02:41:19 PM
getting script error message....how critical is the text with respect to spacing....can you put it in the script I posted so I know exactly where it goes.   thanks
Title: Re: autotoolzero
Post by: TPS on February 28, 2021, 03:26:14 AM
pls post your complete code.
Title: Re: autotoolzero
Post by: PCH on February 28, 2021, 07:53:41 AM
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

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 P3" ' this delay gives me time to get from computer to hold probe in place
Code "G90 G31Z-4. F4" '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 exact 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, .250) ' change .060 to your plate thickness and then adjust for final accuracy
Sleep 200 'Pause for Dro to update.
Code "G1 Z1. F50" 'put the Z retract height you want here, must be greater than the touch plate thickness
While IsMoving ()
Wend
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 applicable
End If
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   
Title: Re: autotoolzero
Post by: TPS on February 28, 2021, 10:07:40 AM
this code is running here:

Code: [Select]
Sub Main()
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

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

Sleep(3000) ' this delay gives me time to get from computer to hold probe in place
Code "G31 Z-4. F4" ' 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 exact 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, .250) ' change .060 to your plate thickness and then adjust for final accuracy
Sleep 200 ' Pause for Dro to update.
Code "G1 Z1. F50" ' put the Z retract height you want here, must be greater than the touch plate thickness
While IsMoving ()
Wend

Code "(Z axis is now zeroed)" 'puts this message in the status bar
Code "F" &CurrentFeed 'Returns to prior feed rate
Else
Message "Z-Plate is grounded, check connection and try again" 'this goes in the status bar if applicable
End If

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   
End Sub

and z-axis is going down.
Title: Re: autotoolzero
Post by: PCH on February 28, 2021, 01:33:11 PM
nope....its like its ignoring every line of code until it gets to this one:  Code "G1 Z1. F50"    ' put the Z retract height you want here, must be greater than the touch plate thickness
Title: Re: autotoolzero
Post by: TPS on March 01, 2021, 01:52:26 AM
- open Main Menue -> Operator -> VB Script Editor
- copy/paste into the Editor
- use  >|| button to excecute code line by line
- see what code is doing

as sayed code was working here
Title: Re: autotoolzero
Post by: PCH on March 01, 2021, 02:21:19 PM
Is this what I put in the macro and where?


>|| button to excecute code line by line
Title: Re: autotoolzero
Post by: TPS on March 02, 2021, 02:23:12 AM

1. open Main Menue -> Operator -> VB Script Editor

2. copy/paste the complete code into the Editor

3. use  >|| button to excecute code line by line

4. see what code is doing
Title: autotoolzero
Post by: PCH on March 02, 2021, 05:43:15 PM
Ok...I have discovered the my macro will run if I do connect my wires to the breakout board.   But as soon as I connect them the after starting the auto zero script the z axis stops and then retracts to said height of 1 inch that is in the macro.
So befuttled.  Been at this for 2 days.  Must be a wiring issue I think.  Just about ready to get a new breakout board...maybe its a grounding issue.  Very frustrating..Need Help!!!
Title: Re: autotoolzero
Post by: TPS on March 04, 2021, 02:59:05 AM
there are a few possibilities for the failue:

-wiring
-electric noise on your wiring
-defective BOB
Title: Re: autotoolzero
Post by: PCH on March 04, 2021, 06:59:45 AM
Yep....ordered new breakout board and power supply.  Will do some rewiring.  Hope this works.  Thank you