Jump to content

Welcome to eMastercam

Register now to participate in the forums, access the download area, buy Mastercam training materials, post processors and more. This message will be removed once you have signed in.

Use your display name or email address to sign in:

IF-THEN Statements in G-code


Kirk Emmons
 Share

Recommended Posts

Can a person put an IF-THEN statements in a program.

This for a HAAS 3-Axis Vert. Mill.

For example, this is what I want to do.

Run part of a program

M00

Wait for operator input (a "Y" for yes or a "N" for No)

If the op type y, the program continues on to the end

but if the op types "N" then the program goes back to rerun a certain tool.

Is that scenario easy to do & how do I do it

Link to comment
Share on other sites

Something along the lines of...

 

code:

[sNIPPED]

N2Y-4.2449Z-.0136

N3Y-4.2247Z-.0182

N4Y-4.2195Z-.0202

N5Y-4.187Z-.0281

N6Y-4.162Z-.031

N7Y-4.1454Z-.0346

N8Y-3.625Z-.0352

N9 G0Z10.

#PRINT"IS THE PRGRAM DONE ? "

#INPUT V1

#IF V1=Y THEN GOTO:END

#IF V1=N THEN GOTO:CONTINUE

:CONTINUE

N12Y-4.2449Z-.0136

N13Y-4.2247Z-.0182

N14Y-4.2195Z-.0202

N15Y-4.187Z-.0281

N16Y-4.162Z-.031

N17Y-4.1454Z-.0346

N18Y-3.625Z-.0352N12Y-4.2449Z-.0136

N13Y-4.2247Z-.0182

N14Y-4.2195Z-.0202

N15Y-4.187Z-.0281

[sNIPPED]

:END

N837Z10.

N27M5M9

N28G90H0Z0.

N29E0X0Y0

N30M30

I haven't done any of this stuff since the late 90s, so I might be a little off. Check the macro section of the Fadal manual for more examples.

 

Thad

Link to comment
Share on other sites
Guest CNC Apps Guy 1

In FANUC Language

code:

IF[#510EQ1]GOTO123 (IF VARIABLE 510 IS EQUAL TO 1 GOTO LINE NUMBER 123)

IF[#510NEQ1]GOTO123 (IF VARIABLE 510 IS NOT EQUAL TO 1 GOTO LINE NUMBER 123)

IF[#512LT1]GOTO123 (IF VARIABLE 510 IS LESS THAN TO 1 GOTO LINE NUMBER 123)

IF[#512LE1]GOTO123 (IF VARIABLE 510 IS LESS THAN OR EQUAL TO 1 GOTO LINE NUMBER 123)

IF[#512GT1]GOTO123 (IF VARIABLE 510 IS GREATER THAN TO 1 GOTO LINE NUMBER 123)

IF[#512GE1]GOTO123 (IF VARIABLE 510 IS GREATER THAN OR EQUAL TO 1 GOTO LINE NUMBER 123)

 

 

N123 #3001=1 (SOMETING IS AMISS)

 

M99

HTH

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

  • 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

×
×
  • Create New...