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:

Macro B (Haas) question


YoDoug®
 Share

Recommended Posts

Would this work? Not sure where you want to go after N9999 is done. I think this could get you close, though it's a little messy.

 

 

O0001 (MAIN)

IF [ #698 LT #699 ] GOTO 2;

;

;

;

N2 #100=9999;(SET 100 TO SEQUENCE NUMBER)

M98 P1000;(CALL SUB)

M30;

 

O1000 (SUB);

GOTO #100;(JUMP TO SET SEQUENCE NUMBER)

;

;

;

N9999;

M99;(RETURN TO P1000 CALL)

Link to comment
Share on other sites

code:

 IF [ #698 LT #699 ] GOTO 9999

..

..

..

N9999 M98 P1000


If you only put what you want in P1000 then you won't need to jump to a specific line number. Just another way of getting there. I don't believe you can use GOTO to jump to another program, it's only used to move around within a program.

Link to comment
Share on other sites

Mazak will do this with H as the block number to go to in the sub.

 

M98 P1000 H9999

 

Fanuc will not do it. My solution was to use G65 instead of M98 and pass the line number as H.

 

O0001 (MAIN)

G65 P1000 H9999

;

M30

 

O1000 (SUB)

GOTO #11

;

N9999

;

M99

 

You can do multiple sub calls to run different portions of the sub this way.

 

O0001 (MAIN)

G65 P1000 H10

;

G65 P1000 H20

;

G65 P1000 H30

;

G65 P1000 H40

;

M30

 

O1000 (SUB)

GOTO #11

;

N10

;

GOTO9999

;

N20

;

GOTO9999

;

N30

;

GOTO9999

;

N40

;

GOTO9999

;

N9999

M99

Link to comment
Share on other sites

Thanks guys, I think I have found a solution. However if you have a better solution to what I am trying to accomplish please share.

 

Here's what I'm doing. I have created a single part counting macro that can be used in all of our lathes and mills for both single cycle (m30) and multiple cycle (bar feed, m99) programs.

 

The programmer add a manual entry toolpath at the end of his program - G65 P9111 A100. B32.

 

A= total parts required, B= parts per bar if needed. The macro looks for a B value to count parts per bar as well as total parts. When parts per bar is reached one alarm is generated, when total parts is reached another alarm is generated.

 

The problem I was having was after the macro returns to the main program how to switch between M99 or M30 based on the B value in the macro. I just modified my master posts to out put a conditional check of a variable set in the macro if B value is present.

 

This is what the main program looks like.

 

code:

 G65 P9111 A100. B33.

IF [ #696 GT 0 ] GOTO9999

M30

N9999

#696 = 0

M99

Macro program=

 

code:

 O9111

(PART COUNTER)

(#1-A = TOTAL PARTS)

(#2-B = PARTS PER BAR FOR LATHE)

(#695 = TOTAL PART COUNTER)

(#696 = M99-M30 RESET IN MAIN PROGRAM)

(#697 = TOTAL PARTS DESIRED)

(#698 = PARTS PER BAR)

(#699 = BAR PARTS COUNTER)

 

G103 P1

 

G04 P500

#697=#1

 

G04 P500

#698=#2

 

G04 P500

(ADD 1 TO TOTAL COUNT)

#695= [ #695 + 1 ]

 

G04 P500

IF [#698 EQ 0 ] GOTO100

 

G04 P500

(ADD 1 TO BAR PART COUNT)

#699= [ #699 + 1 ]

IF [ #699 EQ #698 ] GOTO101

 

N100

G04 P500

IF [ #695 EQ #697 ] GOTO102

 

IF [ #698 GT 0 ] THEN #696 = 1

 

M99

 

N101

#696= 0

#698= 0

#699= 0

#3000 = 500 (END OF BAR)

 

N102

#695= 0

#696= 0

#697= 0

#698= 0

#699= 0

#3000 = 501 (TOTAL PARTS REACHED)

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