Hello Guest it is January 23, 2022, 07:39:48 AM

Author Topic: How do I get my X, Y, and Z axis DROs to reset in this script?  (Read 18406 times)

0 Members and 1 Guest are viewing this topic.

This script centers my end mill on the part to set up for a perfectly centered slot to be cut along the X axis.
I
t does 4 things...
1) It probes down to the top (Z axis) of the part and records this position
2) It probes over to the front and back of the part (Y axis), records the position of each
3) It probes over to the left and right of the part (X axis), records the position of each
4) It moves the Z axis so it just touches the top of the part, the Y axis to the middle of the part, and the X axis to the middle of the part

Once the script completes, I manually reset the X, Y, and Z DROs and run my G-Code which cuts the slot in the parts.

I've never been able to successfully add a function to the script that will reset the X, Y, and Z DROs automatically upon completion. You can see my attempt below but it does not reset any of the DROs. Can someone suggest the appropriate command to accomplish this?
Thank you,
-Aaron

Code: [Select]
Rem VBScript To center mill On quick relase handle In preparation For slot cutting

If GetOemLed (825) <> 0 Then 'Check to see if the probe is already grounded or faulty
Code "(Probe plate is grounded, check connection and try again)"
Else
FeedCurrent = GetOemDRO(818) 'Get the current settings
XCurrent = GetDro(0)
YCurrent = GetDro(1)

Code "G4 P1" 'Pause 1 second to give time to position probe plate
Code "F2" 'slow feed rate to 2 ipm

Rem Probe Down

ZNew = Zcurrent - 1 'set scan to top edge of part - up to 1 inch of travel
Code "G31 Z" &ZNew 'move down to scan for top edge
While IsMoving() 'wait for the move to finish
Wend
ZTop = GetVar(2002) 'get the probe touch location

Code "G0 Z" &ZTop + .25 'rapid move .25 inches above part surface
Code "G0 Y" &YCurrent + .75 'Move to far end of part for next scan start point
Code "G0 Z" &ZTop - .1 'Move down to .1 inches below part top edge

Rem Probe foward

Code "G31 Y" &YCurrent 'Scan back edge
While IsMoving()
Wend
YPos1 = GetVar(2001) 'Record back edge position

Code "G0 Y" &YPos1 + .25 'Move .25 inches away from last scanned edge
Code "G0 Z" &ZTop +.25 'Move up to .25 above part surface
Code "G0 Y" &YPos1 - 1.25 'Move 1.25 inches to front edge of part
Code "G0 Z" &ZTop - .1 'Move down to .1 inches below part top edge

Rem Probe backward

Code "G31 Y" &YPos1 'Scan for front edge of part
While IsMoving()
Wend
YPos2 = GetVar(2001) 'record front edge of part

YCenter = (YPos1 + YPos2) / 2 'calculate Y axis center
Code "G0 Y" &YPos2 - .25 'Move .25 inches away from from edge of part
Code "G0 Z" &ZTop + .25 'Move .25 inches above part surface

Rem move To the center

Code "G0 Y" &YCenter 'Move to Y axis center location
Code "G0 X" &XCurrent + .825 'Move 1 inch to right for right edge of part probe
Code "G0 Z" &ZTop - .4 'Move down to .4 inches below part top edge

Rem Probe Left

Code "G31 X" &XCurrent - 1.5 'Move into left edge of part to determine right edge
While IsMoving() 'wait for the move to finish
Wend
XPos1 = GetVar(2000) 'record location of right edge of part
Code "G0 X" &XPos1 + .25 'Move .25 inches away from last scanned edge
Code "G0 Z" &ZTop +.25 'Move up to .25 invhrd sbovr part surface
Code "G0 X" &XPos1 - 1.25 'Move 1.5 inches left side of part
Code "G0 Z" &ZTop - .4 'Move down to .4 inches below part top edge

Rem Probe Right

Code "G31 X" &XPos1 + 1.5
While IsMoving()
Wend
XPos2 = GetVar(2000)

XCenter = (XPos1 + XPos2) / 2 'center is midway between XPos1 and XPos2
Code "G0 X" &XPos2 - .25 'Move .25 inches away from from edge of part
Code "G0 Z" &ZTop + .25 'Move .25 inches above part surface
Code "G0 X" &XCenter 'rapid move to the x center location
Code "G0 Z" &ZTop 'Place mill at 0 Z height

Code "F" &FeedCurrent  'restore starting feed rate

Rem Reset DROs

Call SetDro (0,0.00) 'reset X axis DRO
Call SetDro (1,0.00) 'reset Y axis DRO
Call SetDro (2,0.00) 'reset Z axis DRO

End If   
 
   
Re: How do I get my X, Y, and Z axis DROs to reset in this script?
« Reply #1 on: May 10, 2009, 10:51:00 PM »
Change


   Call SetDro (0,0.00)      'reset X axis DRO
   Call SetDro (1,0.00)      'reset Y axis DRO
   Call SetDro (2,0.00)      'reset Z axis DRO
   

to

       SetMachZero(0)
       SetMachZero(1)
       SetMachZero(2)


Darrell
Re: How do I get my X, Y, and Z axis DROs to reset in this script?
« Reply #2 on: May 11, 2009, 12:37:42 AM »
sorry NOOB here.

what language is this?
Re: How do I get my X, Y, and Z axis DROs to reset in this script?
« Reply #3 on: May 11, 2009, 02:04:32 AM »
A version of visual basic supported in Mach3
Re: How do I get my X, Y, and Z axis DROs to reset in this script?
« Reply #4 on: May 11, 2009, 07:13:14 PM »
Well I made the suggested change but the DROs still do not reset after the script completes the probe points.
Any other thoughts or suggestions?
Thanks,
-Aaron

Code: [Select]
Rem VBScript To center mill On quick relase handle In preparation For slot cutting

If GetOemLed (825) <> 0 Then 'Check to see if the probe is already grounded or faulty
Code "(Probe plate is grounded, check connection and try again)"
Else
FeedCurrent = GetOemDRO(818) 'Get the current settings
XCurrent = GetDro(0)
YCurrent = GetDro(1)

Code "G4 P1" 'Pause 1 second to give time to position probe plate
Code "F2" 'slow feed rate to 2 ipm

Rem Probe Down

ZNew = Zcurrent - 1 'set scan to top edge of part - up to 1 inch of travel
Code "G31 Z" &ZNew 'move down to scan for top edge
While IsMoving() 'wait for the move to finish
Wend
ZTop = GetVar(2002) 'get the probe touch location

Code "G0 Z" &ZTop + .25 'rapid move .25 inches above part surface
Code "G0 Y" &YCurrent + .75 'Move to far end of part for next scan start point
Code "G0 Z" &ZTop - .1 'Move down to .1 inches below part top edge

Rem Probe foward

Code "G31 Y" &YCurrent 'Scan back edge
While IsMoving()
Wend
YPos1 = GetVar(2001) 'Record back edge position

Code "G0 Y" &YPos1 + .25 'Move .25 inches away from last scanned edge
Code "G0 Z" &ZTop +.25 'Move up to .25 above part surface
Code "G0 Y" &YPos1 - 1.25 'Move 1.25 inches to front edge of part
Code "G0 Z" &ZTop - .1 'Move down to .1 inches below part top edge

Rem Probe backward

Code "G31 Y" &YPos1 'Scan for front edge of part
While IsMoving()
Wend
YPos2 = GetVar(2001) 'record front edge of part

YCenter = (YPos1 + YPos2) / 2 'calculate Y axis center
Code "G0 Y" &YPos2 - .25 'Move .25 inches away from from edge of part
Code "G0 Z" &ZTop + .25 'Move .25 inches above part surface

Rem move To the center

Code "G0 Y" &YCenter 'Move to Y axis center location
Code "G0 X" &XCurrent + .825 'Move 1 inch to right for right edge of part probe
Code "G0 Z" &ZTop - .4 'Move down to .4 inches below part top edge

Rem Probe Left

Code "G31 X" &XCurrent - 1.5 'Move into left edge of part to determine right edge
While IsMoving() 'wait for the move to finish
Wend
XPos1 = GetVar(2000) 'record location of right edge of part
Code "G0 X" &XPos1 + .25 'Move .25 inches away from last scanned edge
Code "G0 Z" &ZTop +.25 'Move up to .25 invhrd sbovr part surface
Code "G0 X" &XPos1 - 1.25 'Move 1.5 inches left side of part
Code "G0 Z" &ZTop - .4 'Move down to .4 inches below part top edge

Rem Probe Right

Code "G31 X" &XPos1 + 1.5
While IsMoving()
Wend
XPos2 = GetVar(2000)

XCenter = (XPos1 + XPos2) / 2 'center is midway between XPos1 and XPos2
Code "G0 X" &XPos2 - .25 'Move .25 inches away from from edge of part
Code "G0 Z" &ZTop + .25 'Move .25 inches above part surface
Code "G0 X" &XCenter 'rapid move to the x center location
Code "G0 Z" &ZTop 'Place mill at 0 Z height

Code "F" &FeedCurrent  'restore starting feed rate

Rem Reset DROs

                SetMachZero(0)                          'reset X axis DRO
                SetMachZero(1)                          'reset Y axis DRO
                SetMachZero(2)                          'reset Z axis DRO

End If   
Re: How do I get my X, Y, and Z axis DROs to reset in this script?
« Reply #5 on: May 11, 2009, 09:30:52 PM »
Well I know that


                SetMachZero(0)                          'reset X axis DRO
                SetMachZero(1)                          'reset Y axis DRO
                SetMachZero(2)                          'reset Z axis DRO

Does reset the machine coordinates to zero for X, Y & Z.
Try putting it in a separate macro and call it after your script before milling the slot.

vmax549

*
Re: How do I get my X, Y, and Z axis DROs to reset in this script?
« Reply #6 on: May 13, 2009, 09:25:55 AM »
SetMachZero(0) is ONLY used to reset the axis(0) MACHINE COOR DRO to zero. IT cannot set to a value and it only sets the machine COOR  position dro. NOW that does effect the value in the USER COOR base but only because you changed the MachineDRO.

SetDRO(0,0.000)     WORKS here

(;-) TP
Re: How do I get my X, Y, and Z axis DROs to reset in this script?
« Reply #7 on: May 13, 2009, 10:55:58 PM »
Ok, the SetDRO (0,0) command does work… almost.
Turns out I was changing the wrong script, thus my changes were not taking affect.
What happens is that I’ve included the SetDRO (0,0) command to run at the end of the script just before the command that restores the original federate. This does work but does not actually change all the DROs to zero. Thinking these problems may have been caused by the script executing the reset commands too quickly, I added a pause command (code “G04 p.5”) between them to give each time to reset before resetting the next DRO. This did not have any affect other then adding a half second between DRO changes.

Here is what happens…
The X axis DRO is changed to +0.6105
The Y axis DRO is changed to +0.0000
The Z axis DRO is changed to +0.4000

I do not know where these figures came from. I moved each axis to a different position and re-ran the script and those same numbers again appear once the SetDRO (0,0), SetDRO (1,0), and SetDRO (2,0) commands are executed in the script.
Any clue why this behavior is occurring? I’m very close to getting everything to function correctly.
Thanks for the responses thus far, they’ve been very helpful!
-Aaron

Code: [Select]
Rem VBScript To center mill On quick relase handle In preparation For slot cutting

If GetOemLed (825) <> 0 Then 'Check to see if the probe is already grounded or faulty
Code "(Probe plate is grounded, check connection and try again)"
Else
FeedCurrent = GetOemDRO(818) 'Get the current settings
XCurrent = GetDro(0)
YCurrent = GetDro(1)

Code "G4 P1" 'Pause 1 second to give time to position probe plate
Code "F2" 'slow feed rate to 2 ipm

Rem Probe Down

ZNew = Zcurrent - 1 'set scan to top edge of part - up to 1 inch of travel
Code "G31 Z" &ZNew 'move down to scan for top edge
While IsMoving() 'wait for the move to finish
Wend
ZTop = GetVar(2002) 'get the probe touch location

Code "G0 Z" &ZTop + .25 'rapid move .25 inches above part surface
Code "G0 Y" &YCurrent + .75 'Move to far end of part for next scan start point
Code "G0 Z" &ZTop - .1 'Move down to .1 inches below part top edge

Rem Probe foward

Code "G31 Y" &YCurrent 'Scan back edge
While IsMoving()
Wend
YPos1 = GetVar(2001) 'Record back edge position

Code "G0 Y" &YPos1 + .25 'Move .25 inches away from last scanned edge
Code "G0 Z" &ZTop +.25 'Move up to .25 above part surface
Code "G0 Y" &YPos1 - 1.25 'Move 1.25 inches to front edge of part
Code "G0 Z" &ZTop - .1 'Move down to .1 inches below part top edge

Rem Probe backward

Code "G31 Y" &YPos1 'Scan for front edge of part
While IsMoving()
Wend
YPos2 = GetVar(2001) 'record front edge of part

YCenter = (YPos1 + YPos2) / 2 'calculate Y axis center
Code "G0 Y" &YPos2 - .25 'Move .25 inches away from from edge of part
Code "G0 Z" &ZTop + .25 'Move .25 inches above part surface

Rem move To the center

Code "G0 Y" &YCenter 'Move to Y axis center location
Code "G0 X" &XCurrent + .825 'Move 1 inch to right for right edge of part probe
Code "G0 Z" &ZTop - .4 'Move down to .4 inches below part top edge

Rem Probe Left

Code "G31 X" &XCurrent - 1.5 'Move into left edge of part to determine right edge
While IsMoving() 'wait for the move to finish
Wend
XPos1 = GetVar(2000) 'record location of right edge of part
Code "G0 X" &XPos1 + .25 'Move .25 inches away from last scanned edge
Code "G0 Z" &ZTop +.25 'Move up to .25 invhrd sbovr part surface
Code "G0 X" &XPos1 - 1.25 'Move 1.5 inches left side of part
Code "G0 Z" &ZTop - .4 'Move down to .4 inches below part top edge

Rem Probe Right

Code "G31 X" &XPos1 + 1.5
While IsMoving()
Wend
XPos2 = GetVar(2000)

XCenter = (XPos1 + XPos2) / 2 'center is midway between XPos1 and XPos2
Code "G0 X" &XPos2 - .25 'Move .25 inches away from from edge of part
Code "G0 Z" &ZTop + .25 'Move .25 inches above part surface
Code "G0 X" &XCenter 'rapid move to the x center location
Code "G0 Z" &ZTop 'Place mill at 0 Z height

Rem Reset DROs

SetDro (0,0.00) 'reset X axis DRO
Code "G04 P.5" 'pause .5 seconds
SetDro (1,0.00) 'reset Y axis DRO
Code "G04 P.5" 'pause .5 seconds
SetDro (2,0.00) 'reset Z axis DRO
Code "G04 P.5" 'pause .5 seconds

Code "F" &FeedCurrent  'restore starting feed rate

End If
Re: How do I get my X, Y, and Z axis DROs to reset in this script?
« Reply #8 on: May 14, 2009, 06:22:39 AM »
Also tried the SetOEMDRO(800,0) function as well - with the same result. Do the reset buttons for the X, Y, and Z axis have a OEM value that I could call from the script? I need a command within the script that has the exact affect as pressing each of these buttons.



I am using the MachBlue screen set.

vmax549

*
Re: How do I get my X, Y, and Z axis DROs to reset in this script?
« Reply #9 on: May 14, 2009, 09:25:50 AM »
HI Arrron, WHat version of mach are you using?  WHat you are seeing is a CLUE to what I have been chasing for a while. The fact that the values stayed the same even afer a positional change is a NEW clue/INFO (;-)

 IF all else fails try reloading MACH and try again. I would be interested to see IF that fixed it for a while.

 I have seen what you described and the only way to fix it so far is to reload mach.

HERE the setdro() works just fine without error. 

Just a thought, (;-) TP
« Last Edit: May 14, 2009, 09:30:24 AM by vmax549 »