Hello Guest it is April 18, 2024, 12:18:29 PM

Author Topic: Programing Question  (Read 3149 times)

0 Members and 1 Guest are viewing this topic.

Programing Question
« on: May 07, 2014, 08:13:00 PM »
I am working on a custom Homing/Referencing script and would like help with some code.

In my script I want to pause the code to wait for the referencing process to finish. The code that I am using is:

DoOemButton(1023)   'Home Y
While IsMoving
Sleep(1000)
Wend

This code was developed from a number of examples from the forum but it does not seem right to me.

The way I would translate it would be;  While the machine is still homing the Y axis wait 1 second and then run the rest of the code.  

What I want to do is wait until the referencing process is complete and then run the rest of the code.

Is this code correct?

Is there a better way to write this script?

Offline ger21

*
  • *
  •  6,295 6,295
    • View Profile
    • The CNC Woodworker
Re: Programing Question
« Reply #1 on: May 07, 2014, 09:47:05 PM »
You no longer need to use the Sleep(xx) in the While IsMoving. That was changed many years ago.
All you normally need to wait for movement to end is:

While IsMoving()
Wend

However, when homing, you shouldn't even need the While IsMoving. Try just using the
DoOEMButtin(1023) by itself, and see if you have any issues. The macro should wait until homing is complete before it continues. If you find that it  doesn't, then try:

DoOEMButton(1023)
While IsMoving()
Wend
Gerry

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

JointCAM Dovetail and Box Joint software
http://www.g-forcecnc.com/jointcam.html
Re: Programing Question
« Reply #2 on: May 07, 2014, 10:03:32 PM »
This all came about because the custom homing script on a gantry style plasma machine was not working properly.  I actually had to increase the sleep time to correct it.  Now it stops before homing is complete if the gantry is too far from home.

I will  try what you suggest and see what happens.

Thanks for your help.

Offline ger21

*
  • *
  •  6,295 6,295
    • View Profile
    • The CNC Woodworker
Re: Programing Question
« Reply #3 on: May 08, 2014, 06:34:19 AM »
Quote
Now it stops before homing is complete if the gantry is too far from home.

Do the Ref's LED's light up when it stops? It shouldn't be stopping, even if your Home script was just the one DoEOMBUtton line.
Gerry

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

JointCAM Dovetail and Box Joint software
http://www.g-forcecnc.com/jointcam.html
Re: Programing Question
« Reply #4 on: May 08, 2014, 01:09:46 PM »
I ran into an issue where i was slowly losing counts at high speeds (later realized it was too much weight for the stepper motor to go at those speeds) and i got a script to calibrate an offset of the home values so that all of my points would still line up.  My logic was that I know that there is some error in my position relative to home (or is not even homed) and by looking at the home flag variable i was able to home the axies fairly well.  For the homing process i just moved the x axis to the right at 10mm steps till home flag was active then moved to the left by 1mm steps till it was inactive, then moved it to the right at 0.1mm steps till it was active and finally to the left at 0.01mm steps till it was inactive.  Save current position as new_home and then when ever you want to move relative to it you just subtract the new_home position form where you want to go.

Flags for homing, may be different numbers on yours but easy to find.
x-axis GetOEMLED(830)
y-axis GetOEMLED(833)
z-axis GetOEMLED(836)

If you would like i can try and dig up the old code i used ofr this, not sure if i still have it though.

Matt