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:

Fanuc Macro Question


Karl@CP PISTONS
 Share

Recommended Posts

Yes, I just learned to use this the other day. I had to write a macro that changed a range of tool offsets but skipped ones ending in 1 or 7. smile.gif

 

Since you already know about the MOD function without knowing if it's in Macro be, I'm assuming you know how it works. Here's the format.

 

#101= 17

#102= #101 MOD 10 (result is 7)

 

Here's how I'd try to use it.

 

#100= (PASSED VALUE)

IF [[[#100 / 2] MOD 10] EQ .5] GOTO 1

GOTO 2 (if not, go to N2)

N1 (#100 IS ODD)

N2 (#100 IS EVEN)

 

This has no provision for a zero result, but you could add that later if you need it.

 

Hope that helps, let us know what works! cheers.gif

Link to comment
Share on other sites

Matt, The book I have ( FANUC custom macros ) does not even mention MOD division. I did not want to have a confusing program as it's bad enough already.That is why I did not want to test for every value 1-8

 

kunfuzed, Yes I do know how the MOD function works and thanks for the format example.

 

Here is what I ended up with:

 

IF [#101 MOD 2] = 0 GOTO15

( ODD OFFSET NUMBERS )

#[6982+[[#101 + #137]*20]] = #144

( P1,P3,P5,P7,P9,P11,P13,P15 - Y )

#[6981+[[#101 + #137]*20]] = #129

( P1,P3,P5,P7,P9,P11,P13,P15 - X )

 

GOTO16

 

N15

( EVEN OFFSET NUMBERS )

#[6982+[[#101 + #137]*20]] = #143

( P2,P4,P6,P8.P10,P12,P14,P16 - Y )

#[6981+[[#101 + #137]*20]] = #129

( P2,P4,P6,P8.P10,P12,P14,P16 - X )

 

N16

 

I have not had any open time on the machine to test it but it looks good on paper

 

Thanks to both of you for the info.

Karl

Link to comment
Share on other sites

Lol, I sure was taking the long route by doing MOD 10 and then dividing by two, when you could just cut to the chase and do MOD 2. biggrin.gif

 

What book do you have? I've got "Fanuc CNC Custom Macros" by Peter Smid. Pretty good topic coverage, also covers MOD.

 

Glad you got it! cheers.gif

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...