Some Things You Should Know If You Plan to Edit a Postprocessor.
By: Mike Mattera

Writing A Post
If you find the right starting post, there should be very few things that need to be changed. You also need to deceide if your changing the post because your machine wont run vs. changing the post to "look" a certain way. I can tell you from experience that most people ask for changes that have no effect on the machines operation. Figure out what's important for running your machine and make those changes. If the program outputs a spindle stop, when the spindle is'nt running , Who Cares!!  Stopped is stopped.  It works!

There are several thing you should plan for when attempting to write a postprocessor.

Create a test part that will give predictible results (i.e. circles and drill points with known centers, etc...).  Use toolpath features that will output the NC code for linear, circular (cw/ccw) and any cycles that will be important. Post your sample program using all of the posts that might be close to your machine/control combination.

There are many posts provided with your Mastercam system. However, they may not have been copied into your system. If all you see in the list of available posts is  Mpfan.pst, you can insert your Mastercam CD and install the rest of them. A large number of posts are available thru your dealer. Just call and ask him if he has a post for your machine. Be sure to have your Machine Make & Model - Control Make/Model - Basic machine description (vertical, horizontal mill, 2x lathe, 3x lathe, etc..) when you call him. He needs to know what your looking for.

If you rename a post, be sure to rename the .TXT file that goes with it.  All .PST files have a .TXT file.  The .TXT file controls the display of any special menu functions and features of the post.

The Mastercam NC Code Postprocessor is very flexable.  Many of the existing posts can be "switched" to turn on/off different features.  As an example: Some people use block numbers (N100), some people don't.  In almost every post is a variable called  "omitseq", that might be set to 0(no) or 1(yes). "omitseq" will omit the output of sequence numbers if set to yes(1).

Other features can be switched by accessed the "misc. values"  button from within Mastercam.

Check the box and press the button to see what's available.


Misc Integers control whats on or off. Misc Reals are for real numbers.


When you open the post in your favorite editor, the first thing you'll notice are comments. Anything after # sign is a comment. This front section of the post lists features and may explain how they are used. Skim thru this section and you'll see what variables are available and how they can be activated.

DeBugging Your Post
If you've set the variables for the output you need, there may still be some things in the NC code that need changing. To find the section of the post that outputs the bad code, you can use the "bug" variables.  Set "fastmode" to 0 (zero) and all of the "bug" features will become active.  In the example link, "bug2" is set to 30. This value represents the column on the page to display the debugging code.  Now your NC program will display the post function that output the code.


Controlling The Format Of The NC Code
Block numbers typically have no decimal point. XYZ positions almost always have a decimal point.  Some block numbers  need to be a fixed 4 digits (N1234 or N0010). Some block numbers only require the single number (N10).  These are all descriptions of the "Format" for the "Address".

You need to know how the numbers will be formatted for each address of the control.  Somewhere in the NC controls programming manual, you'll find a page that will show the addresses formatted like this.......
X 2.4
Y 2.4
Z 2.4
N 6
S 4
F 3.1

This is showing you that X can have 2 places before the decimal point and 4 places after the decimal point.  Y and Z are the same.  The address N (typicaly used for block numbers) can use up to 6 digits with nothing after the decimal point.  The address F (typicaly used for Feedrates) uses 3 digits before the decimal point and 1 digit after the decimal point.  Some of these addresses use no decimal point at all.

In the Mastercam postprocessor we set up these addresses, using the format statement. This gives you the control to define how each number should look.  These are some of the basics that can be controlled.

These things are controlled with the use of Format Statements.

 



 
Setting the Format of an Axis Address

So if you looked at the Format Statements shown above, the next
thing we need to do is tell the post which number format, goes with
which axis address.  For this we use the Format function (fmt).
Every motion command, M-function & G-code needs to be
formatted for the proper display of it's values.  It's how you tell
the post that the X axiz move should start with the letter "X"  and
the block numbers should start with the letter "N".


Looking for more information Mastercam?  Click Here

Return to the Mastercam Tutorials Page  Click Here