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 question


powerfulp
 Share

Recommended Posts

Hello -

 

I know this is a Mastercam forum (& I use mastercam) but I know there are some smart folks here so I pose this question:

 

I am trying to figure out how to write some macros in my g-code program that does the following regarding cycle times:

 

1 - Stores cycle time for each tool every time they are ran. But only keeps one record, the last one.

2 - Stores entire program cycle time.

3 - Stores the last ten program cycle times so they can be easily reviewed.

 

Here is what I have figured-out thus far:

 

The program has five tools and my machine has permanent common variables up to #699 so I thought it could go like this:

 

#601 is for T1's cycle time

#602 is for T2's cycle time

#603 is for T3's cycle time

#604 is for T4's cycle time

#605 is for T5's cycle time

#606 is for accumulative cycle time

#607 thru #616 would store the last 10 cycle times.

 

(This is on a Mazak Horizontal Machining Center with M-32 control)

 

 

So to get and store cycle times for each tool and to get and record the entire cycle time, I would just do this:

 

(First tool runs...)

M6 (Dont' know if I should put the following before or after the tool change)

#602=#3001 (using millisecond counter for getting the cycle time for this tool)

#606=#606+#3001(Accumulated time)

#3001=0

(Next tool runs)

#603=#3001

#606=#606+#3001

#3001=0

(Last tool runs)

<< Same thing with the macro but #3001= happens before the shuttle, not after an M6>>

(Part shuttles out, is changed, and cycle start is hit)

M6

(beginning of program)

#600=#3001 (tells you how long it took to switch parts and start up machine"

#607=#606+#3001 (Stores entire cycle time in #607)

#606=0

#3001=0

 

So I'm thinking I will have to do a conditional statement somewhere in the macro, with a counter, etc in order to get and store the next nine cycle times in variables #608-#616, but I can't figure out exactly how to write that. Can someone help me out with this? I'm pretty green when it comes to macro programming but I think it's awesome and want to learn more and more ways to do stuff with it. I'll continue working on it as I wait for a reply.

 

Also had another quick question: Does the millisecond timer start over after like 60 seconds? I've hear that but then I heard that it goes on till power off or for 77.7 years...

 

Any help is appreciated ... thanks.

Link to comment
Share on other sites

Hello -

I know this is a Mastercam forum (& I use mastercam) but I know there are some smart folks here so I pose this question:

I am trying to figure out how to write some macros in my g-code program that does the following regarding cycle times:

1 - Stores cycle time for each tool every time they are ran. But only keeps one record, the last one.

2 - Stores entire program cycle time.

3 - Stores the last ten program cycle times so they can be easily reviewed.

Here is what I have figured-out thus far:

The program has five tools and my machine has permanent common variables up to #699 so I thought it could go like this:

#601 is for T1's cycle time

#602 is for T2's cycle time

#603 is for T3's cycle time

#604 is for T4's cycle time

#605 is for T5's cycle time

#606 is for accumulative cycle time

#607 thru #616 would store the last 10 cycle times.

(This is on a Mazak Horizontal Machining Center with M-32 control)

 

So to get and store cycle times for each tool and to get and record the entire cycle time, I would just do this:

(First tool runs...)

M6 (Dont' know if I should put the following before or after the tool change)

#602=#3001 (using millisecond counter for getting the cycle time for this tool)

#606=#606+#3001(Accumulated time)

#3001=0

(Next tool runs)

#603=#3001

#606=#606+#3001

#3001=0

(Last tool runs)

<< Same thing with the macro but #3001= happens before the shuttle, not after an M6>>

(Part shuttles out, is changed, and cycle start is hit)

M6

(beginning of program)

#600=#3001 (tells you how long it took to switch parts and start up machine"

#607=#606+#3001 (Stores entire cycle time in #607)

#606=0

#3001=0

So I'm thinking I will have to do a conditional statement somewhere in the macro, with a counter, etc in order to get and store the next nine cycle times in variables #608-#616, but I can't figure out exactly how to write that. Can someone help me out with this? I'm pretty green when it comes to macro programming but I think it's awesome and want to learn more and more ways to do stuff with it. I'll continue working on it as I wait for a reply.

Also had another quick question: Does the millisecond timer start over after like 60 seconds? I've hear that but then I heard that it goes on till power off or for 77.7 years...

Any help is appreciated ... thanks.

  • Like 1
Link to comment
Share on other sites

Sounds like you can just add some type of counter.

 

Initialize #620 = 607

 

Then as you run though your routine and store your time, have something like this

 

IF #620 GT 616 THEN #620=607

#[#620] = #606 (STORES FIRST TIME IN #607)

#620 = #620 + 1 (THIS WILL INCREMENT UP BY ONE EACH TIME)

 

I hope I understood the question.

Link to comment
Share on other sites

...awesome quote for readability...

 

Thanks Millman.

 

Powerfulp, this is a pretty cool question. If you are trying to have #608 always store the most recent time and #616 always store the oldest time, you could simply assign like so:

 

#616=#615

#615=#614

#614=#613

#613=#612

#612=#611

#611=#610

#610=#609

#609=#608

#608=#607

Link to comment
Share on other sites

Hello and thanks for the replies.

 

So what I ended up with for this (with some help), was:

 

 

Oxxxx

(Start of program)

T1M6

#3001=0 (Initialize continuous millisecond timer)

xxx

(Runs the tool)

xxx

T2M6

#601=#3001 (Stores total time from M6 to M6, essentially, for T1)

#606=#606+#3001 (Starts accumulated total time)

#3001=0(resets timer)

xxx

(Runs tool)

xxx

T3M6

#602=#3001 (Stores total time from M6 to M6, this time T2)

#606=#606+#3001(Accumulated total)

#3001=0

etc. till the end of the program, then:

#605=#3001 (Stores time for T5)

#606=#606+#3001 (Accumulated)

(Now, execute a DO Loop to move all the cycle times up one non-volatile variable at a time , then putting the most recent cycle time at the bottom)

#1=1

WHILE [#1 LT 10] DO1

#[#607 + #1] = #[#607 + [#1+1]]

#1 = #1+1

END1

#617=#606(Enters entire cycle time in #617

#606=0

#3001=0

M99

 

(Note: I wanted to skip a couple places for separation on the screen)

If you wanted to, you could put the time it takes to load, unload a part by doing a #3001=#619 before the first tool change.

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