Hello Guest it is March 28, 2024, 05:32:56 PM

Author Topic: Help with code problem  (Read 5608 times)

0 Members and 1 Guest are viewing this topic.

Help with code problem
« 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

Code: [Select]
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)
Re: Help with code problem
« Reply #1 on: April 04, 2010, 11:08:22 AM »
The last statement, "Code SetDro(0,0) is not setting X to zero.

Does that help?

Offline ger21

*
  • *
  •  6,295 6,295
    • View Profile
    • The CNC Woodworker
Re: Help with code problem
« Reply #2 on: April 04, 2010, 11:33:09 AM »
Instead of

Code SetDro(0,0)

Try

Call SetOEMDro(0,0)
Gerry

2010 Screenset
http://www.thecncwoodworker.com/2010.html

JointCAM Dovetail and Box Joint software
http://www.g-forcecnc.com/jointcam.html
Re: Help with code problem
« Reply #3 on: April 04, 2010, 12:18:48 PM »
Greg,

Thanks for the suggestion but that did not work.

Offline Tweakie.CNC

*
  • *
  •  9,196 9,196
  • Super Kitty
    • View Profile
Re: Help with code problem
« Reply #4 on: April 04, 2010, 01:34:32 PM »
It was almost right.
Try:-

Call SetDRO(0,0)

Tweakie.
PEACE

Offline ger21

*
  • *
  •  6,295 6,295
    • View Profile
    • The CNC Woodworker
Re: Help with code problem
« Reply #5 on: April 04, 2010, 01:35:51 PM »
How about

Call SetOEMDro (800,0)
Gerry

2010 Screenset
http://www.thecncwoodworker.com/2010.html

JointCAM Dovetail and Box Joint software
http://www.g-forcecnc.com/jointcam.html
Re: Help with code problem
« Reply #6 on: April 04, 2010, 02:02:22 PM »
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.

Offline Tweakie.CNC

*
  • *
  •  9,196 9,196
  • Super Kitty
    • View Profile
Re: Help with code problem
« Reply #7 on: April 04, 2010, 02:27:36 PM »
You need to pause the macro to give Mach time to catch up.

Try this:-

While IsMoving()   
    Wend
Call SetDRO(0,0)


Tweakie.
PEACE

Offline ger21

*
  • *
  •  6,295 6,295
    • View Profile
    • The CNC Woodworker
Re: Help with code problem
« Reply #8 on: April 04, 2010, 02:38:10 PM »
And it's Gerry, btw. :)
Gerry

2010 Screenset
http://www.thecncwoodworker.com/2010.html

JointCAM Dovetail and Box Joint software
http://www.g-forcecnc.com/jointcam.html
Re: Help with code problem
« Reply #9 on: April 04, 2010, 03:10:37 PM »
Gerry,

I should know better sorry about your name.

I will add a while move and see if that helps.

Thanks
Nils