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 in m-codes


Tim Johnson
 Share

Recommended Posts

I'm trying to change m-codes to macro numbers

-----------------------------------------------

# Generate string for spindle

sm04 M04 #Spindle reverse

sm05 M05 #Spindle off

sm03 M03 #Spindle forward

spindle #Target for string

 

fstrsel sm04 spdir2 spindle

 

-----------------------------------------------

 

I want to change M03 to M[#933], M04 to M[#934] and others.

 

I've done a search and tried to figure this off the post cd, but apparently I'm missing something.

 

thanks for any help.

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

Actually though it's not going ot be that easy. The M codes are seen as literal strings in the post. It'a slmost as if you'll need to rewrite how speed gets called, like making your own postblock to check the condition of the spindle, if it's forward then output this;

 

"M", 091, 035, "933", 093 #Spindle forward

 

yadda yadda, yadda.

 

HTH

Link to comment
Share on other sites

Well I am thinking you need to apporach it different than that. Something like pmacrospind control section needs to be added to your post then in the post you need to define this varaible every where the spindle was.

 

Here:

code:

pmacrospind #Macro Spindle Direction callout

spaces=0

if Mi3 = 0 & Mi3 < 2,

[

Mi3 = 1,

]

if Mi3 = 1,

[

pbld, n, "M[",35,"933]", e

]

if Mi3 = 2,

[

pbld, n, "M[",35,"934]", e

]

spaces=1

Change would be like this for the spinlde varaible being used in your post:

code:

Before

pbld, n, *speed, *spindle, e

After

pbld, n, *speed, pmacrospind, e

Now if you want to get fancy you can define the TXT section for this post and Put give the person doing the progamming a (Spinlde Direction [CW=1,CCW=2]) and then you have it looking and doing very sharp. This setup will default M[#933] so you do not have to use the MISC vaule all the time if you want to change it then when you put the 2 in there it will do the M[#934].

 

In case you are wondering the 35 is the ASCII for the the pound sign. The reason is if you have the pound sign in the post it will not read any information after that in the pst file. [edit see James beat me to the punch here]

 

To all that want to do Macro programming via Mastercam this is how you do it and Drilling cycles once you have all of your varaibles defined and all of your formuals and such they way you want then it just a few clicks and fill in the blanks and you are rocking and rolling.

 

I hope that helps you and others. Have a nice day.

 

This information it given as is and I only give it to help not hinder.

Link to comment
Share on other sites

Change the string selector to :

 

code:

 

# Generate string for spindle

sm04 934 #Spindle reverse

sm05 935 #Spindle off

sm03 933 #Spindle forward

spindle #Target for string

 

fstrsel sm04 spdir2 spindle

Change *spindle to pspindle2 (3 places is MPFAN) and add a new postblock:

code:

pspindle2

"M", no_spc, 91, no_spc, 35, no_spc, *spindle, no_spc, 93

Note: no_spc is available in MPDLL v9.11 and later (I believe that was released in 9,1 SP1, but you can always grab the latest MP.DLL from the downloads area of the Mastercam website). Earlier than that and you will need save the spaces setting and recall it afterwards (that is if you have spaces set > 0):

code:

pspindle2

sav_spc = spaces

spaces = 0

"M", 91, 35, *spindle, 93

spaces = sav_spc

Link to comment
Share on other sites

Paul,

 

The #933 and #934 worked great, but #935 is sending out "935".

 

--------------------------------------------

N106G43H02Z2.875S13000M[#934]

 

N734G43H11Z2.875S9168M[#933]

 

N720G00Z2.875

N722935

N724G91G28Z0.M09

---------------------------------------------

 

But the main part is fixed! biggrin.gif

 

Ron, I'm printing this thread. I have other uses for your Mi code.

 

Thanks to all!

Link to comment
Share on other sites

I changed the 935 back to M05 and posted M05

 

------------------------------------------------

# Generate string for spindle

sm04 934 #Spindle reverse

sm05 M05 #Spindle off

sm03 933 #Spindle forward spindle

#Target for string

fstrsel sm04 spdir2 spindle

------------------------------------------------

 

N720G00Z2.875

N722M05

N724G91G28Z0.M09

------------------------------------------------

 

Does this mean the spindle stop is called out somewhere else? Just a question, works just fine the way it is.

 

This is my first attemp at writing a post

(mpmaster version 9.1.03296). This post will be heavily loaded with macro and subprograms. I probably should have started with an easier one, but where's the fun in that. cheers.gif

 

thanks again.

Link to comment
Share on other sites

Sorry Tim, I threw that together off the top of my head, wasn't really thinking of the M05 side of things... If you are using MPFAN, the 935 is most likely being output in pretract:

 

code:

      pbld, n, sccomp, *sm05, psub_end_mny, e

What we want to do here is to replace the *sm05 which is forcing out the 935 to pspindle2 as we did in the other post blocks. But, we also need to make sure that we are going to get the correct value. In order to do that, we will need to set spdir2 to 1. The problem is that if we simply set it to 1 and have an operation after this, the value will still be 1 in the next operation (ptlchg) which of course is not what we are looking for. So, we need to store the current value, set it to 1, output what we need, then set the value back to the stored amount. I would generally initialize a new variable for this (i.e. - sav_spdir2 : 0) but you could also use an existing variable like "result" (be careful here if you do, make sure the variable you choose is not currently being used for something...). So, for sake of ease, change that line in pretract to:

 

code:

      result = spdir2

spdir2 = 1 #Force M05 Output

pbld, n, sccomp, pspindle2, psub_end_mny, e

spdir2 = result

If you are using MPFAN, you are going to need to change one more location (you'll have to do a little searching if you're using another post to make sure you hit all of the *sm05's). Find and change the following postblock:

code:

pspindchng      #Spindle speed change 

if prv_spdir2 <> spdir2 & prv_speed <> zero, pbld, n, *sm05, e

Change it to:

code:

pspindchng      #Spindle speed change 

 

if prv_spdir2 <> spdir2 & prv_speed <> zero,

[

result = spdir2

spdir2 = 1 #Force M05 Output

pbld, n, pspindle2, e

spdir2 = result

]

Link to comment
Share on other sites

Alright, disregard what I put above (unless you decide to output a 935 which of course I guessed at when I first posted).

 

quote:

Does this mean the spindle stop is called out somewhere else? Just a question, works just fine the way it is.


Do a search for sm05 and M05, if they are in a postblock then they could be output. MPMaster is a good post that includes a lot of extra switches and options. I think it is a good choice if you want to make use of a lot of the options but is overkill in a lot of situations. The good thing is that many of the end users on this forum use it and modify it on a daily basis so you should be able to get a lot of help in whatever you try to do. I would suggest getting a copy of the Post Processor Reference CD if you haven't already done so, it is kind of the post guy's bible and is a great reference for post related information. And of course, your local reseller should also be able to assist you should you get stuck.

Link to comment
Share on other sites

Sorry to Just Get Back To This Guys Crazy Afternoon.

 

Paul Great Way to Approach that and I thank you for Sharing That. cheers.gifcheers.gif

 

I was just looking at his original as 2 things not others and what I put can be adpapted to as many Macro Inputs and as Many Places in A Post as you can think of. I think someone said 32000 or some number like that but problay wrong on that number.

 

Tim I am thinking Paul's way is the best for spindle direction and to be honest you could adapt Tool number and Spindle Speed and Height offset and a bunch of other things more common to be output this way he has showed and Yes this whole THread has been added to my Grwoing notebook. My exmaple is great for as you said other thing and would work here just not the best way. Cool thing about this place we come up with so much and learn so much from such great people. I found you problem to be a fun thing to play with I really have no need for it but cool to have a use if I ever need that.

 

James it took me from the time he posted it up to my response to get that typed up so was totally not knowing what you had done till I put up my response. idea.gifheadscratch.gif Was going on I was thinking of what to type and would it work.

 

Tim I am Glad as in the Past my different apporach got you a correct apporach I learned something new and cool also Thanks.

Link to comment
Share on other sites

Paul,

 

I'm sorry to keep you going on this thread. I don't need a macro for M05. I was just curious, that's all. I do have the post cd. Is the cd in book format? If not it will be by the time I done with it. wink.gif I'm using the M03/M04 macro so the operators can dry run with the door open to look for interference between the tools and fixturing. The dry run macro also shuts off coolants, turns tapping, peck drill, boring to "G81" mode.

 

Ron,

I think I will still be able to use your Mi codes

for the tool routing macros. The routing macro I use most for my clustervises uses up to six subs per tool on our horizontal. At our shop we may get an order for 50 parts one time and the next time the order may be for 5. The routing macros allow the operators to decide how many (in this case) vise jaw sets and either one or two pallets to set up and still be able to run the same program. I'm thinking that I can use the Mi postblock to tell the post which routing macro to use. I have seven macros for the clustervises and five for the tombstones so far, more get written as different processes are needed. If you have a better way I'm ready to learn. biggrin.gif

Link to comment
Share on other sites

The post cd is a collection of .pdf files which are best used with the search feature. I recommend Adobe Acrobat 6 which has better search features than 5. Refer to "00 How to search.pdf" for information on setting the reader to use the correct index when searching. You'll also want to set it to always use advanced search options (Edit-Preferences-Search, check the box and save the preferences).

You can print it out but you will need several reams of paper (something like 1,600 pages).

Link to comment
Share on other sites

I wouldn't hold my breath waiting for a book. It may happen someday but there are changes coming (which I obviously cannot discuss) so it wont be any time soon. The biggest problem with a book is that once it is printed, it is static (meaning it doesn't change). Having an electronic file means that when changes are made to MP, the reference files are easily updated to accomodate.

Most likely you will do what most of us do, print out pages you refer to most often and use the search feature other times.

 

Ron, how did I know you would have printed it out?? lol

Link to comment
Share on other sites

Simple answer, Yes. X will be able to update V9 posts. You do need to understand that I cannot guarantee that every post will simply plug in, there are just too many changes that you could potentially make to your custom post that will make the process a bit more time consuming (requiring a bit of work on your end) but the majority of posts currently in use in 9 should update with minimal issues.

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