Machsupport Forum
Mach Discussion => General Mach Discussion => Topic started by: SailFl on April 04, 2010, 08:24:13 AM
-
The code I have included is part of X & Y Zero.
When I use the debugger and step through the code, Dro(0) get set to zero. When I run the code, it does not get set to zero. I have tried Call SetDro and Code....
What am I doing wrong.
Thanks
Rem
Rem Test Code For X And Y Zero routine
Rem
XCurrent = GetDro(0) 'Get current X position
YCurrent = GetDro(1) 'Get current Y position
ZCurrent = GetDro(2) 'Get current Z position
FeedRateCurrent = GetOEMDro(818) 'Get the current Feed Rate
NewFeedRate = 10 'Set Feed Rate for macro
Call SetOEMDro(818, NewFeedRate)
Code "(Zero X and Y Macro Running)"
Rem Find the X negative
XNew = XCurrent - 2
Code "G31 X" &XNew
While IsMoving()
Wend
XPos1 = GetVar(2000)
Code "G0 X" &XCurrent
Rem Find the X positive
XNew = XCurrent + 2
Code "G31 X" &XNew
While IsMoving()
Wend
XPos2 = GetVar(2000)
XCenter = (XPos1 + XPos2)/2
Code "G0 X" &XCenter
Code SetDro(0,0)
-
The last statement, "Code SetDro(0,0) is not setting X to zero.
Does that help?
-
Instead of
Code SetDro(0,0)
Try
Call SetOEMDro(0,0)
-
Greg,
Thanks for the suggestion but that did not work.
-
It was almost right.
Try:-
Call SetDRO(0,0)
Tweakie.
-
How about
Call SetOEMDro (800,0)
-
Greg,
I found that also, the 800 number. When I setup through the code it works and the X gets set to zero but when I run the macro it does not get set to zero. I have even put a pause to give it time to update but that does not help either.
SetDro does the same thing.
-
You need to pause the macro to give Mach time to catch up.
Try this:-
While IsMoving()
Wend
Call SetDRO(0,0)
Tweakie.
-
And it's Gerry, btw. :)
-
Gerry,
I should know better sorry about your name.
I will add a while move and see if that helps.
Thanks
Nils
-
Gerry
Adding the While Moving fixed my problem. Thanks for the suggestion.
-
Glad you got it fixed Nathan. ;D
Tweakie.