Machsupport Forum

Mach Discussion => VB and the development of wizards => Topic started by: agauger on May 10, 2009, 01:18:57 PM

Title: How do I get my X, Y, and Z axis DROs to reset in this script?
Post by: agauger on May 10, 2009, 01:18:57 PM
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   
 
   
Title: Re: How do I get my X, Y, and Z axis DROs to reset in this script?
Post by: MachineMaster 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
Title: Re: How do I get my X, Y, and Z axis DROs to reset in this script?
Post by: Teyber on May 11, 2009, 12:37:42 AM
sorry NOOB here.

what language is this?
Title: Re: How do I get my X, Y, and Z axis DROs to reset in this script?
Post by: MachineMaster on May 11, 2009, 02:04:32 AM
A version of visual basic supported in Mach3
Title: Re: How do I get my X, Y, and Z axis DROs to reset in this script?
Post by: agauger 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   
Title: Re: How do I get my X, Y, and Z axis DROs to reset in this script?
Post by: MachineMaster 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.
Title: Re: How do I get my X, Y, and Z axis DROs to reset in this script?
Post by: vmax549 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
Title: Re: How do I get my X, Y, and Z axis DROs to reset in this script?
Post by: agauger 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
Title: Re: How do I get my X, Y, and Z axis DROs to reset in this script?
Post by: agauger 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.

(http://www.gaugerfamily.com/temp/mach3_screen_shot.jpg)

I am using the MachBlue screen set.
Title: Re: How do I get my X, Y, and Z axis DROs to reset in this script?
Post by: vmax549 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
Title: Re: How do I get my X, Y, and Z axis DROs to reset in this script?
Post by: poppabear 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
Title: Re: How do I get my X, Y, and Z axis DROs to reset in this script?
Post by: agauger 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
Title: Re: How do I get my X, Y, and Z axis DROs to reset in this script?
Post by: agauger 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 ***
Title: Re: How do I get my X, Y, and Z axis DROs to reset in this script?
Post by: MachineMaster 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?
Title: Re: How do I get my X, Y, and Z axis DROs to reset in this script?
Post by: agauger 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.
Title: Re: How do I get my X, Y, and Z axis DROs to reset in this script?
Post by: ellik 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
Title: Re: How do I get my X, Y, and Z axis DROs to reset in this script?
Post by: agauger 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 ***
Title: Re: How do I get my X, Y, and Z axis DROs to reset in this script?
Post by: ellik 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
Title: Re: How do I get my X, Y, and Z axis DROs to reset in this script?
Post by: agauger 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.
Title: Re: How do I get my X, Y, and Z axis DROs to reset in this script?
Post by: vmax549 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

Title: Re: How do I get my X, Y, and Z axis DROs to reset in this script?
Post by: agauger on May 17, 2009, 05:38:28 PM
Quote
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?
Yes...
I tried this for each of the 3 axis - (Setdro(0,0.000) for X, Setdro(1,0.000) for Y and Setdro(2,0.000) for Z. They all work perfectly. The problem must be within the script. I'll see about rewriting the script slightly simplified and see if I can identify the issue(s).
At least I know the Setdro(0,0.000) command works on my machine. This is a milestone in itself.
Title: Re: How do I get my X, Y, and Z axis DROs to reset in this script?
Post by: vmax549 on May 17, 2009, 09:03:28 PM
OK are you saying that at the end of the macro the DROs are readiing something other than 0.000 Or do you mean the machine is out of postion by those amounts while the dros are reading 0.000. ??

I don't see anything in your code that would cause the Dro to reading other than 0.000.

BU I do see a couple of things that may leave it OUT of postion.

Just a thought, (;-) TP

(;-) TP
Title: Re: How do I get my X, Y, and Z axis DROs to reset in this script?
Post by: agauger on May 17, 2009, 09:18:46 PM
Quote
vmax549 - OK are you saying that at the end of the macro the DROs are readiing something other than 0.000 Or do you mean the machine is out of postion by those amounts while the dros are reading 0.000. ??
When the probing script completes, the mill is directly centered on the part both on the X and Y axis. Additionally the mill is at the top of the part- just touching. This is the exact position that I manually reset the X, Y, and Z DROs before running my slot cutting program. The machine positions itself exactly where it should when the probing script completes, it just resets the DROs to something other than zero.
When the DoOEMButton(1008), or Setdro(0,0.000) cammands run at the end of the script, the result is 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 have yet to try adding a delay before running the DRO reset command to give Mach3 a chance to catch the mill up to the executed code.
Quote
vmax549 - BU I do see a couple of things that may leave it OUT of postion.
If you see specific problems with the scipt, please let me know. As I mentioned before, I'm very new at this and would like to corect any mistakes I've made before they get to be habbits.
Cheers.

Title: Re: How do I get my X, Y, and Z axis DROs to reset in this script?
Post by: vmax549 on May 18, 2009, 09:39:27 AM
AS long as it ends at the proper location then all is well(;-).

Try this, Delete the resetting of the DROs from the script. ADD an "end" to the end of the scriptThen let it run to completion.

Then from a seperate script do the dros resetting to zero. Just curious.

There is NOTHING I know of that will effect the Setdro() command from inside your script. It does NOT draw from any inside VAR or DRO so any errant value should NOT show up.

THE ONLY thing I can think of is that the axis has NOT stopped at the time your code is updating the value to zero so there is some overrun at times. 

IF the seperate script cures the problem then on the old script BEFORE the commands to zero the dros add  Code"G04 P0"  this will force Mach to empty the motion  buffer before doing the next command.

Just a thought, (;-) TP

(;-) TP
Title: Re: How do I get my X, Y, and Z axis DROs to reset in this script?
Post by: eddie60 on May 19, 2009, 06:18:37 AM
HI
IM HAVING PROBLEMS WITH THE MACH BLUE SCREEN SCRIPT
I USE METRIC
I HAVE TRIED CHANGING IT MYSELF, I CAN'T GET IT TO WORK
I NEED A SCRIPT THAT CAN FIND THE CENTER OF A 40 mm PIPE
AND MOVE AT ABOUT 100mm A MINUTE
CAN ANYONE HELP ME PLEASE?
EDDIE
Title: Re: How do I get my X, Y, and Z axis DROs to reset in this script?
Post by: agauger on May 19, 2009, 06:42:10 AM
Quote
Try this, Delete the resetting of the DROs from the script. ADD an "end" to the end of the scriptThen let it run to completion.
Then from a seperate script do the dros resetting to zero.
I ran the probe script and the DRO reset script seperately. They both wook as they should. I'll try your suggestion using the END command as well as the G04 P0 command this evening to see if I can get everything working in a single script.
Thanks!
Title: Re: How do I get my X, Y, and Z axis DROs to reset in this script?
Post by: agauger on May 21, 2009, 06:34:32 AM
Well, the END command did not change anything. I also added the G04 P0 command but the DROs are still resetting to values other than zero. I even tried a 10 second wait command (G04 P10) but this did not change anything either. Interesting note though, the DROs changed value prior to the 10 seconds expiring.
By placing the DRO reset commands in a separate script, I can successfully get all 3 axis to reset to zero as they should.
Can you give me an example of how I would call this second script containing only the DRO reset commands from within the first script? I’ve heard calling scripts from within scripts is bad practice but it may just be the fix I’m looking for.
Thanks,
-Aaron
Title: Re: How do I get my X, Y, and Z axis DROs to reset in this script?
Post by: vmax549 on May 21, 2009, 10:21:09 AM
(;-) OK try this Before the DRO updating

While ISMOVING()
Sleep (2000)
Wend

You can try the macro from a macro BUT beware strange things have been known to happen.

Set up the separate code as a separate macro (say M200) then just call the macro from the first macro

Code"M200"

or just 

Call M200

Heck give it a whirl, but please try the WhileIsmoving/sleep thing first

(;-) TP






Title: Re: How do I get my X, Y, and Z axis DROs to reset in this script?
Post by: ellik on May 21, 2009, 11:28:26 PM
Another trick is to add a Sleep(300) just after calling SetDRO, especially if the next line in your script calling a moving the same axis you just changed the DRO for. It looks like there is a synchronization problem between the VB script and the mach driver (probably running in different processes or threads) Otherwise the next move might be executed based on the previous DRO position, not the one you just set.

This solved a problem for me anyway. Worth a try.

EK