Hello Guest it is April 25, 2024, 09:22:50 PM

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

0 Members and 1 Guest are viewing this topic.

Offline poppabear

*
  • *
  •  2,235 2,235
  • Briceville, TN, USA
    • View Profile
Re: How do I get my X, Y, and Z axis DROs to reset in this script?
« Reply #10 on: May 15, 2009, 12:45:22 PM »
If you want to Zero the X, Y, and Z axis use this:

DoOEMButton(1008) 'zero X
DoOEMButton(1009) 'zero Y
DoOEMButton(1010) 'zero Z

'scott
fun times
Re: How do I get my X, Y, and Z axis DROs to reset in this script?
« Reply #11 on: May 15, 2009, 02:47:47 PM »
At the suggestion of vmax549, I upgraded my Mach3 version from R2.63 to R3.042.020. This did not change anything. I also took the suggestion of poppabear, and used the DoOEMButton(1008) command instead. This too, made no change. Lastly, I moved the reset commands to the very end of the script (after the End If statement). This also did not make any difference.
I'm guessing the reset commands are functioning as they should but the code in the script has made the Zero value something other than Zero. This would explain why the DROs are being reset to the same values each time regardless of what they were before the scipt was run.

Again, once the script completes, the DRO values are reset as follows:
The X axis DRO is changed to +0.6105 (this number does vary slightly on occasion)
The Y axis DRO is changed to +0.0000
The Z axis DRO is changed to +0.4000

I'll go over the code in my script to see if I can identify the culprit. I've included it below incase someone else spots it first. I'll post my findings once I come of with something.

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

DoOEMButton(1008) 'zero X
DoOEMButton(1009) 'zero Y
DoOEMButton(1010) 'zero Z
Re: How do I get my X, Y, and Z axis DROs to reset in this script?
« Reply #12 on: May 16, 2009, 03:59:19 PM »
Well it's not a perfect solution but it works...
I wrote all the necessary G-Code for cutting the needed slot into my pieces into the script itself. Instead of referencing everything from DRO Zero, I just referenced the code against the variable that holds the DRO value for the center of the part on the X, Y, and Z axis.
Lastly, I'm hoping to find a way to repeat this whole process 4 times as the jig I've made to hold these parts while the slots are being cut holds 4 pieces. If I copy the entire script and paste it again at the end after an X axis move to the next part (2 inches to the right), it does start the probing but then moves back to a position on the previous part. I may have to reassign all the variables to something new each time the script repeats to avoid conflicts from the previous variable values.
I thought that each time I reran a retrieve value command it would overwrite the previous value (XCurrent = GetDro(0) should overwrite the value of XCurrent  with the revised DRO value each time, no?)

Here is my revised script...
Code: [Select]
Rem VBScript To center mill On quick relase handle In preparation For slot cutting

Rem *** Begin PROBE SCRIPT HERE For PART 1 ***

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

Code "(Beginning Z axis probe)"

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

Code "(Beginning Y axis probe)"

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

Code "(Moving to Y axis center position)"

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

Code "(Beginning X axis probe)"

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 inches above 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 'Move into right edge of part to determine right edge
While IsMoving() 'wait for the move to finish
Wend
XPos2 = GetVar(2000) 'record location of left edge of part

Code "(Moving to X axis center position)"

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 "(Moving to Z axis 0 position)"

Code "G0 Z" &ZTop 'Place mill at 0 Z height

Code "F" &FeedCurrent  'restore starting feed rate
End If

Code "(Begin slot cutting program for first handle.)"

Rem Begin 1st handle slot cutting program

XNewCenter = GetDro(0) 'Record New X center position
YNewCenter = GetDro(1) 'Record New Y center position
XOffset = -.5 'Set offset from X axis center (- value for more right, + value for more left)
XOffsetCenter = XNewCenter - XOffset

Code "F5" 'Set feedrate to 5 IPM

Code "(Slot cutting to being in 5 seconds...)"
Code "G04 P1" 'delay 1 seconds
Code "(Slot cutting to being in 4 seconds...)"
Code "G04 P1" 'delay 1 seconds
Code "(Slot cutting to being in 3 seconds...)"
Code "G04 P1" 'delay 1 seconds
Code "(Slot cutting to being in 2 seconds...)"
Code "G04 P1" 'delay 1 seconds
Code "(Slot cutting to being in 1 second...)"
Code "G04 P1" 'delay 1 seconds

Code "M1000" 'Horn on
Code "G04 P.3" 'delay .3 seconds
Code "M1001" 'Horn off
Code "G04 P1" 'delay 1 seconds

Code "G0 Z" &ZTop + .25 'Place mill at .25 inches above parts
Code "G0 X" &XOffsetCenter - .6 'Place mill .6 inches to the left of the part
Code "M3 S0" 'Turn on spindle
Code "M1002" 'Turn on Air

Code "(Pass 1 of 14 - .04 inches)"

Code "G0 Y" &YNewCenter - .005 'Place mill .005 inches forward of center
Code "G0 Z" &ZTop - .04 'Place mill to .04 inches depth
Code "G1 X" &XOffsetCenter + .6 'Cut Left to Right
Code "G0 Y" &YNewCenter + .005 'Place mill .005 inches backward of center
Code "G1 X" &XOffsetCenter - .6 'Cut Right to Left

Code "(Pass 2 of 14 - .08 inches)"

Code "G0 Y" &YNewCenter - .005 'Place mill .005 inches forward of center
Code "G0 Z" &ZTop - .08 'Place mill to .08 inches depth
Code "G1 X" &XOffsetCenter + .6 'Cut Left to Right
Code "G0 Y" &YNewCenter + .005 'Place mill .005 inches backward of center
Code "G1 X" &XOffsetCenter - .6 'Cut Right to Left

Code "(Pass 3 of 14 - .12 inches)"

Code "G0 Y" &YNewCenter - .005 'Place mill .005 inches forward of center
Code "G0 Z" &ZTop - .12 'Place mill to .12 inches depth
Code "G1 X" &XOffsetCenter + .6 'Cut Left to Right
Code "G0 Y" &YNewCenter + .005 'Place mill .005 inches backward of center
Code "G1 X" &XOffsetCenter - .6 'Cut Right to Left

Code "(Pass 4 of 14 - .16 inches)"

Code "G0 Y" &YNewCenter - .005 'Place mill .01 inches forward of center
Code "G0 Z" &ZTop - .16 'Place mill to .16 inches depth
Code "G1 X" &XOffsetCenter + .6 'Cut Left to Right
Code "G0 Y" &YNewCenter + .005 'Place mill .005 inches backward of center
Code "G1 X" &XOffsetCenter - .6 'Cut Right to Left

Code "(Pass 5 of 14 - .20 inches)"

Code "G0 Y" &YNewCenter - .005 'Place mill .005 inches forward of center
Code "G0 Z" &ZTop - .20 'Place mill to .20 inches depth
Code "G1 X" &XOffsetCenter + .6 'Cut Left to Right
Code "G0 Y" &YNewCenter + .005 'Place mill .005 inches backward of center
Code "G1 X" &XOffsetCenter - .6 'Cut Right to Left

Code "(Pass 6 of 14 - .24 inches)"

Code "G0 Y" &YNewCenter - .005 'Place mill .005 inches forward of center
Code "G0 Z" &ZTop - .24 'Place mill to .24 inches depth
Code "G1 X" &XOffsetCenter + .6 'Cut Left to Right
Code "G0 Y" &YNewCenter + .005 'Place mill .005 inches backward of center
Code "G1 X" &XOffsetCenter - .6 'Cut Right to Left

Code "(Pass 7 of 14 - .28 inches)"

Code "G0 Y" &YNewCenter - .005 'Place mill .005 inches forward of center
Code "G0 Z" &ZTop - .28 'Place mill to .28 inches depth
Code "G1 X" &XOffsetCenter + .6 'Cut Left to Right
Code "G0 Y" &YNewCenter + .005 'Place mill .005 inches backward of center
Code "G1 X" &XOffsetCenter - .6 'Cut Right to Left

Code "(Pass 8 of 14 - .32 inches)"

Code "G0 Y" &YNewCenter - .005 'Place mill .005 inches forward of center
Code "G0 Z" &ZTop - .32 'Place mill to .32 inches depth
Code "G1 X" &XOffsetCenter + .6 'Cut Left to Right
Code "G0 Y" &YNewCenter + .005 'Place mill .005 inches backward of center
Code "G1 X" &XOffsetCenter - .6 'Cut Right to Left

Code "(Pass 9 of 14 - .36 inches)"

Code "G0 Y" &YNewCenter - .005 'Place mill .005 inches forward of center
Code "G0 Z" &ZTop - .36 'Place mill to .36 inches depth
Code "G1 X" &XOffsetCenter + .6 'Cut Left to Right
Code "G0 Y" &YNewCenter + .005 'Place mill .005 inches backward of center
Code "G1 X" &XOffsetCenter - .6 'Cut Right to Left

Code "(Pass 10 of 14 - .40 inches)"

Code "G0 Y" &YNewCenter - .005 'Place mill .005 inches forward of center
Code "G0 Z" &ZTop - .40 'Place mill to .40 inches depth
Code "G1 X" &XOffsetCenter + .6 'Cut Left to Right
Code "G0 Y" &YNewCenter + .005 'Place mill .005 inches backward of center
Code "G1 X" &XOffsetCenter - .6 'Cut Right to Left

Code "(Pass 11 of 14 - .44 inches)"

Code "G0 Y" &YNewCenter - .005 'Place mill .005 inches forward of center
Code "G0 Z" &ZTop - .44 'Place mill to .44 inches depth
Code "G1 X" &XOffsetCenter + .6 'Cut Left to Right
Code "G0 Y" &YNewCenter + .005 'Place mill .005 inches backward of center
Code "G1 X" &XOffsetCenter - .6 'Cut Right to Left

Code "(Pass 12 of 14 - .48 inches)"

Code "G0 Y" &YNewCenter - .005 'Place mill .005 inches forward of center
Code "G0 Z" &ZTop - .48 'Place mill to .48 inches depth
Code "G1 X" &XOffsetCenter + .6 'Cut Left to Right
Code "G0 Y" &YNewCenter + .005 'Place mill .005 inches backward of center
Code "G1 X" &XOffsetCenter - .6 'Cut Right to Left

Code "(Pass 13 of 14 - .52 inches)"

Code "G0 Y" &YNewCenter - .005 'Place mill .005 inches forward of center
Code "G0 Z" &ZTop - .52 'Place mill to .52 inches depth
Code "G1 X" &XOffsetCenter + .6 'Cut Left to Right
Code "G0 Y" &YNewCenter + .005 'Place mill .005 inches backward of center
Code "G1 X" &XOffsetCenter - .6 'Cut Right to Left

Code "(Pass 14 of 14 - .55 inches)"

Code "G0 Y" &YNewCenter - .005 'Place mill .005 inches forward of center
Code "G0 Z" &ZTop - .55 'Place mill to .55 inches depth
Code "G1 X" &XOffsetCenter + .6 'Cut Left to Right
Code "G0 Y" &YNewCenter + .005 'Place mill .005 inches backward of center
Code "G1 X" &XOffsetCenter - .6 'Cut Right to Left

Code "M1003" 'Turn off Air
Code "M5" 'Turn off spindle

Code "G0 Z" &ZTop + .5 'Raise mill above handle to move to next
Code "G0 X" &XOffsetCenter + 2 'Move mill over top of next handle
Code "G0 Z" &ZTop + .25 'Lower mill to begin probe next handle

Rem *** Begin PROBE SCRIPT AGAIN HERE For PART 2 ***
Re: How do I get my X, Y, and Z axis DROs to reset in this script?
« Reply #13 on: May 17, 2009, 12:51:07 AM »
<quote>
Again, once the script completes, the DRO values are reset as follows:
The X axis DRO is changed to +0.6105 (this number does vary slightly on occasion)
The Y axis DRO is changed to +0.0000
The Z axis DRO is changed to +0.4000</quote>



Where those numbers are coming from is a real puzzle. Every way that I could think of using
SetDro(0,0.0)
SetDro(1,0.0)
SetDro(2,0.0)
SetDro(3,0.0)
always gave me zeros. Are you set up in inches or millimeters?
Re: How do I get my X, Y, and Z axis DROs to reset in this script?
« Reply #14 on: May 17, 2009, 07:28:36 AM »
Quote
Are you set up in inches or millimeters?
Everything I do is in inches but I will check each step of my workflow to be sure I'm not set to MMs somewhere accidentally.
Re: How do I get my X, Y, and Z axis DROs to reset in this script?
« Reply #15 on: May 17, 2009, 12:15:22 PM »
Before you set the DRO make sure the axis are not moving. I had a similar problem and this is how I solved it.

   currX = GetOEMDRO(800)
   currY = GetOEMDRO(801)
   currZ = GetOEMDRO(802)
   probeRadius = 0.05
   Code "F10"
   
   'Probe down 1 to surfice
   Code "G31 Z" &currZ - 1
   While IsMoving()
   Wend
   probeZ = GetVar(2002)

   'Move to probed location + 0.1
   Code "G0 Z" &probeZ+0.1
   While IsMoving()
   Wend

   'Set DRO once axis has stoped
   Call SetOEMDRO (802, 0.1)

Elli
Re: How do I get my X, Y, and Z axis DROs to reset in this script?
« Reply #16 on: May 17, 2009, 12:52:32 PM »
ellik, I think you're on to something here. In the script below, I included several code comment lines to show the current operation as the script runs. This includes the pass number (Pass 1 of 14 - .04 inches), etc. What I noticed is that Mach3 seems to read several lines ahead of the code it is executing. I have seen a comment of "Pass 13 of 14 - .52 inches" in my status field but the mill may actually only be on pass 9 of 14. This leads me to think it may be trying to run the DRO reset command before the last movement has completed (as you mentioned), thus showing a value other than zero once the machine stops its final movement during the probing operation.
I'll insert a wait command (Code "G04 P10" 'delay 10 seconds) before the SetDRO(0,0.000) command to give the machine a chance to catch up and we'll see what happens.
I'll investigate this further and post my findings.

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

Rem *** Begin PROBE SCRIPT HERE For PART 1 ***

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

Code "(Beginning Z axis probe)"

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

Code "(Beginning Y axis probe)"

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

Code "(Moving to Y axis center position)"

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

Code "(Beginning X axis probe)"

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 inches above 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 'Move into right edge of part to determine right edge
While IsMoving() 'wait for the move to finish
Wend
XPos2 = GetVar(2000) 'record location of left edge of part

Code "(Moving to X axis center position)"

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 "(Moving to Z axis 0 position)"

Code "G0 Z" &ZTop 'Place mill at 0 Z height

Code "F" &FeedCurrent  'restore starting feed rate
End If

Code "(Begin slot cutting program for first handle.)"

Rem Begin 1st handle slot cutting program

XNewCenter = GetDro(0) 'Record New X center position
YNewCenter = GetDro(1) 'Record New Y center position
XOffset = -.5 'Set offset from X axis center (- value for more right, + value for more left)
XOffsetCenter = XNewCenter - XOffset

Code "F5" 'Set feedrate to 5 IPM

Code "(Slot cutting to being in 5 seconds...)"
Code "G04 P1" 'delay 1 seconds
Code "(Slot cutting to being in 4 seconds...)"
Code "G04 P1" 'delay 1 seconds
Code "(Slot cutting to being in 3 seconds...)"
Code "G04 P1" 'delay 1 seconds
Code "(Slot cutting to being in 2 seconds...)"
Code "G04 P1" 'delay 1 seconds
Code "(Slot cutting to being in 1 second...)"
Code "G04 P1" 'delay 1 seconds

Code "M1000" 'Horn on
Code "G04 P.3" 'delay .3 seconds
Code "M1001" 'Horn off
Code "G04 P1" 'delay 1 seconds

Code "G0 Z" &ZTop + .25 'Place mill at .25 inches above parts
Code "G0 X" &XOffsetCenter - .6 'Place mill .6 inches to the left of the part
Code "M3 S0" 'Turn on spindle
Code "M1002" 'Turn on Air

Code "(Pass 1 of 14 - .04 inches)"

Code "G0 Y" &YNewCenter - .005 'Place mill .005 inches forward of center
Code "G0 Z" &ZTop - .04 'Place mill to .04 inches depth
Code "G1 X" &XOffsetCenter + .6 'Cut Left to Right
Code "G0 Y" &YNewCenter + .005 'Place mill .005 inches backward of center
Code "G1 X" &XOffsetCenter - .6 'Cut Right to Left

Code "(Pass 2 of 14 - .08 inches)"

Code "G0 Y" &YNewCenter - .005 'Place mill .005 inches forward of center
Code "G0 Z" &ZTop - .08 'Place mill to .08 inches depth
Code "G1 X" &XOffsetCenter + .6 'Cut Left to Right
Code "G0 Y" &YNewCenter + .005 'Place mill .005 inches backward of center
Code "G1 X" &XOffsetCenter - .6 'Cut Right to Left

Code "(Pass 3 of 14 - .12 inches)"

Code "G0 Y" &YNewCenter - .005 'Place mill .005 inches forward of center
Code "G0 Z" &ZTop - .12 'Place mill to .12 inches depth
Code "G1 X" &XOffsetCenter + .6 'Cut Left to Right
Code "G0 Y" &YNewCenter + .005 'Place mill .005 inches backward of center
Code "G1 X" &XOffsetCenter - .6 'Cut Right to Left

Code "(Pass 4 of 14 - .16 inches)"

Code "G0 Y" &YNewCenter - .005 'Place mill .01 inches forward of center
Code "G0 Z" &ZTop - .16 'Place mill to .16 inches depth
Code "G1 X" &XOffsetCenter + .6 'Cut Left to Right
Code "G0 Y" &YNewCenter + .005 'Place mill .005 inches backward of center
Code "G1 X" &XOffsetCenter - .6 'Cut Right to Left

Code "(Pass 5 of 14 - .20 inches)"

Code "G0 Y" &YNewCenter - .005 'Place mill .005 inches forward of center
Code "G0 Z" &ZTop - .20 'Place mill to .20 inches depth
Code "G1 X" &XOffsetCenter + .6 'Cut Left to Right
Code "G0 Y" &YNewCenter + .005 'Place mill .005 inches backward of center
Code "G1 X" &XOffsetCenter - .6 'Cut Right to Left

Code "(Pass 6 of 14 - .24 inches)"

Code "G0 Y" &YNewCenter - .005 'Place mill .005 inches forward of center
Code "G0 Z" &ZTop - .24 'Place mill to .24 inches depth
Code "G1 X" &XOffsetCenter + .6 'Cut Left to Right
Code "G0 Y" &YNewCenter + .005 'Place mill .005 inches backward of center
Code "G1 X" &XOffsetCenter - .6 'Cut Right to Left

Code "(Pass 7 of 14 - .28 inches)"

Code "G0 Y" &YNewCenter - .005 'Place mill .005 inches forward of center
Code "G0 Z" &ZTop - .28 'Place mill to .28 inches depth
Code "G1 X" &XOffsetCenter + .6 'Cut Left to Right
Code "G0 Y" &YNewCenter + .005 'Place mill .005 inches backward of center
Code "G1 X" &XOffsetCenter - .6 'Cut Right to Left

Code "(Pass 8 of 14 - .32 inches)"

Code "G0 Y" &YNewCenter - .005 'Place mill .005 inches forward of center
Code "G0 Z" &ZTop - .32 'Place mill to .32 inches depth
Code "G1 X" &XOffsetCenter + .6 'Cut Left to Right
Code "G0 Y" &YNewCenter + .005 'Place mill .005 inches backward of center
Code "G1 X" &XOffsetCenter - .6 'Cut Right to Left

Code "(Pass 9 of 14 - .36 inches)"

Code "G0 Y" &YNewCenter - .005 'Place mill .005 inches forward of center
Code "G0 Z" &ZTop - .36 'Place mill to .36 inches depth
Code "G1 X" &XOffsetCenter + .6 'Cut Left to Right
Code "G0 Y" &YNewCenter + .005 'Place mill .005 inches backward of center
Code "G1 X" &XOffsetCenter - .6 'Cut Right to Left

Code "(Pass 10 of 14 - .40 inches)"

Code "G0 Y" &YNewCenter - .005 'Place mill .005 inches forward of center
Code "G0 Z" &ZTop - .40 'Place mill to .40 inches depth
Code "G1 X" &XOffsetCenter + .6 'Cut Left to Right
Code "G0 Y" &YNewCenter + .005 'Place mill .005 inches backward of center
Code "G1 X" &XOffsetCenter - .6 'Cut Right to Left

Code "(Pass 11 of 14 - .44 inches)"

Code "G0 Y" &YNewCenter - .005 'Place mill .005 inches forward of center
Code "G0 Z" &ZTop - .44 'Place mill to .44 inches depth
Code "G1 X" &XOffsetCenter + .6 'Cut Left to Right
Code "G0 Y" &YNewCenter + .005 'Place mill .005 inches backward of center
Code "G1 X" &XOffsetCenter - .6 'Cut Right to Left

Code "(Pass 12 of 14 - .48 inches)"

Code "G0 Y" &YNewCenter - .005 'Place mill .005 inches forward of center
Code "G0 Z" &ZTop - .48 'Place mill to .48 inches depth
Code "G1 X" &XOffsetCenter + .6 'Cut Left to Right
Code "G0 Y" &YNewCenter + .005 'Place mill .005 inches backward of center
Code "G1 X" &XOffsetCenter - .6 'Cut Right to Left

Code "(Pass 13 of 14 - .52 inches)"

Code "G0 Y" &YNewCenter - .005 'Place mill .005 inches forward of center
Code "G0 Z" &ZTop - .52 'Place mill to .52 inches depth
Code "G1 X" &XOffsetCenter + .6 'Cut Left to Right
Code "G0 Y" &YNewCenter + .005 'Place mill .005 inches backward of center
Code "G1 X" &XOffsetCenter - .6 'Cut Right to Left

Code "(Pass 14 of 14 - .55 inches)"

Code "G0 Y" &YNewCenter - .005 'Place mill .005 inches forward of center
Code "G0 Z" &ZTop - .55 'Place mill to .55 inches depth
Code "G1 X" &XOffsetCenter + .6 'Cut Left to Right
Code "G0 Y" &YNewCenter + .005 'Place mill .005 inches backward of center
Code "G1 X" &XOffsetCenter - .6 'Cut Right to Left

Code "M1003" 'Turn off Air
Code "M5" 'Turn off spindle

Code "G0 Z" &ZTop + .5 'Raise mill above handle to move to next
Code "G0 X" &XOffsetCenter + 2 'Move mill over top of next handle
Code "G0 Z" &ZTop + .25 'Lower mill to begin probe next handle

Rem *** Begin PROBE SCRIPT AGAIN HERE For PART 2 ***
Re: How do I get my X, Y, and Z axis DROs to reset in this script?
« Reply #17 on: May 17, 2009, 01:21:39 PM »
The problem here is that the axis will always move a little just after the probe trippes, it can't stop immediately and the distance directly linked to the feed rate used for probing. The location where the axis stops is not the same location where the probe tripped so you will have to take that difference into account either by moving back to the probed location or calculate the delta before setting the DRO.

EK
Re: How do I get my X, Y, and Z axis DROs to reset in this script?
« Reply #18 on: May 17, 2009, 03:51:40 PM »
Quote
The problem here is that the axis will always move a little just after the probe trippes, it can't stop immediately and the distance directly linked to the feed rate used for probing. The location where the axis stops is not the same location where the probe tripped so you will have to take that difference into account either by moving back to the probed location or calculate the delta before setting the DRO.
This is true but I'm not sure it is a factor in this case.
First, the feed rate during the probe sequence is just 2 IPM. Once the touch point is reached, the mill should stop within a few thousandths.
Also, the 2 touch points (YPos1 and YPos2) are noted and the average (center) between the two points is assigned to a new variable, YCenter. The same is true with the X axis (XPos1, XPos2, and XCenter). Once the X and Y center points are both determined, the mill returns to this position and lowers the Z axis to the recorded touch point at the top of the part. It is this point that I'd like the DROs to be reset to X=0, Y=0, Z=0. Given that the touch points are recorded during the touch probe routine and then the mill later returns to this point, there should be no overtravel of the mill, at least I think there wouldn't be. I'm still very green at this stuff.
I have a semi-working solution but it is the principle of the problem that will keep me searching for a solution.

vmax549

*
Re: How do I get my X, Y, and Z axis DROs to reset in this script?
« Reply #19 on: May 17, 2009, 04:29:44 PM »
THe probe trip point is rarely the same as the stopped axis point. That is why mach writes the trip point to the Var and does NOT rely on the axis dro value. The Var on the other hand is extremely accurate(;-)

Trying to calculate the Delta is out because the delta will vary with conditions of the probing.


IF you just go to the VB editor and type in     Setdro(0,0.000)  then run it doe s the x axis DRO change to 0.000?

(;) TP

« Last Edit: May 17, 2009, 04:34:03 PM by vmax549 »