Sign in to follow this  
cncchipmaker

Looping Question

Recommended Posts

Depends on the control and how deep it will allow you to go into a sub loop. In the middle of a while do loop I would suggest calling a N Block number and let the N Block number have the M98 call and not in the middle of the While do loop. The while do loop is to check a condition depending on how you structure it. Using the N Block process after the While Do loop is completed allows you to define things and change them verse being in the middle of a while do loop and running into trouble if a reset is hit or any other thing happens that doesn't support the while do loop process to be completed correctly.

Share this post


Link to post
Share on other sites
1 hour ago, C^Millman said:

Depends on the control and how deep it will allow you to go into a sub loop. In the middle of a while do loop I would suggest calling a N Block number and let the N Block number have the M98 call and not in the middle of the While do loop. The while do loop is to check a condition depending on how you structure it. Using the N Block process after the While Do loop is completed allows you to define things and change them verse being in the middle of a while do loop and running into trouble if a reset is hit or any other thing happens that doesn't support the while do loop process to be completed correctly.

Can u then get back to the while-do using a GOTO after the M98 is complete?

Share this post


Link to post
Share on other sites

To my knowledge you cannot jump into the middle of a while loop using GOTO, if that is what you are asking. On my control (Nanotech 350FG), I can use a while loop with an M98 between the WHILE / END without issue. In fact, I am doing so right now.

 

Logically speaking, it is pretty straight forward to do this but whether your specific control will allow it is the real question..and for that I have no answer.

Share this post


Link to post
Share on other sites
11 minutes ago, cncchipmaker said:

Can u then get back to the while-do using a GOTO after the M98 is complete?

What is the process you are trying to complete? You have a WHILE DO process using some logic. Are you using addition, subtraction, Great than, less than for your WHILE DO? A WHILE DO is a loop of a certain process while the WHILE DO LOOP is working you can have it doing soemthing in the M98 process to track your progress.

#500 = 0

#550 = 50

N400 WHILE [#500 LT #550] DO N600

N401 GOTO N700

N600 M98 P2000

N601 GOTO N400

N700 M30

O2000

#500 = #500 +1

G90 Z.25

G81 Z-.500 R.25

G80

G91 X.500

G90 Z.25

M99

Here is a real basic example of allowing your process to count up 50 times and drill 50 holes .500 deep spaced .500 in X. Once it was got to #500 is equal to 50 then it will now go the next N Block number which is 401 and that is to skip ahead to N700 which is M30, but while it is less than 50 it keeps going to N600. After it completes N600 it then goes to N601 which is GOTO N400 and keep repeating the process until #500 is equal to #550. Putting a M98 in the middle of a WHILE DO loop without using conditions would create a loop that should go to infinity. Why would you want to create a process that doesn't have limits?

 

Share this post


Link to post
Share on other sites

DP

Edited by C^Millman
Double Post no reason to repat myself.

Share this post


Link to post
Share on other sites

An M98 should work within a G65 call. I believe you can typically nest 4 levels deep but that is control specific. The CNC Macro programming book by SK Sinha says 4 levels of nesting. He goes into a good amount of detail on the subject. The pertinent info begins on page 30, if you have the book.

Share this post


Link to post
Share on other sites
7 minutes ago, Mhoppe said:

Thanks guys, that answers my questions. I have a specific application for someone in the group and hope to post it.

Share this post


Link to post
Share on other sites

I use M98 or M198 in a while/do loop every day. M173 is either a M98 or M198 dependent on the need in my routers.

I've not tried a G65 call with a M98/M198 but it should work.

O5024 (4 PART CLUSTERTOWER FOR 2 PARTS ROUTER)
 
(-0-)
WHILE[#[#539+600+[1-1]]EQ1]DO1 (SURFACE 2)
IF[#172EQ5101]GOTO211
IF[#172EQ5103]GOTO213
IF[#172EQ5104]GOTO211
#900=[#539+[1-1]]
G91 G00 X0 G54 P[#900]
G90 G00 B0.
M#173 P[#170+2]
GOTO211
END1
(-90-)
N211 WHILE[#[#539+600+[1-1]]EQ1]DO1 (SURFACE 1)
IF[#172EQ5102]GOTO312
IF[#172EQ5103]GOTO213
IF[#172EQ5106]GOTO213
#900=[#539+[1-1]]
G91 G00 X0 G54 P[#900]
G90 G00 B90.
G201B90.
G91 G00 X0 G59
M#173 P[#170+1]
GOTO213
END1
N213 WHILE[#[#539+600+[2-1]]EQ1]DO1 (SURFACE 3)
IF[#172EQ5101]GOTO411
IF[#172EQ5102]GOTO312
IF[#172EQ5105]GOTO312
#900=[#539+[2-1]]
G91 G00 X0 G54 P[#900]
G90 G00 B270.
G201B270.
G91 G00 X0 G59
M#173 P[#170+3]
GOTO312
END1
(-180-)
N312 WHILE[#[#539+600+[2-1]]EQ1]DO1 (SURFACE 2)
IF[#172EQ5101]GOTO411
IF[#172EQ5103]GOTO413
IF[#172EQ5104]GOTO411
#900=[#539+[2-1]]
G91 G00 X0 G54 P[#900]
G90 G00 B0.
M#173 P[#170+2]
GOTO411
END1
(-270-)
N411 WHILE[#[#539+600+[2-1]]EQ1]DO1 (SURFACE 1)
IF[#172EQ5102]GOTO501
IF[#172EQ5103]GOTO413
IF[#172EQ5106]GOTO413
#900=[#539+[2-1]]
G91 G00 X0 G54 P[#900]
G90 G00 B90.
G201B90.
G91 G00 X0 G59
M#173 P[#170+1]
GOTO413
END1
N413 WHILE[#[#539+600+[1-1]]EQ1]DO1 (SURFACE 3)
IF[#172EQ5101]GOTO501
IF[#172EQ5102]GOTO501
IF[#172EQ5105]GOTO501
#900=[#539+[1-1]]
G91 G00 X0 G54 P[#900]
G90 G00 B270.
G201B270.
G91 G00 X0 G59
M#173 P[#170+3]
GOTO501
END1
N501
M99
 
(----------START TOOL PATHS----------)
 

 

Share this post


Link to post
Share on other sites

I think the main limitation here is you can't do an M198 inside of an M198.  Otherwise, not much slowing you down on a fanuc.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

Join us!

eMastercam - your online source for all things Mastercam.

Together, we are the strongest Mastercam community on the web with over 56,000 members, and our online store offers a wide selection of training materials for all applications and skill levels.

Follow us