This is an old revision of the document!
We begin by looking at the different types of definitions accessible in the post processor file. All definitions begin with a letter and then a number, the letter deciding what type of definition it is and the number being an address to distinguish between the definitions.
These definitions are used to give the Cam program certain values to be used. They could be scale factors, block numbers etc. Below you will find the entries which are defined today but it could very well happen that there will be more of them in future up-dates.
I1 Block number start :10
I2 Block number step :10
I3 Scale factor X :1
I4 Scale factor Y :1
I5 Scale factor Z :1
I6 Scale factor angles :1
I101 Last name of file :nc
I102 Search path to file:c:\ncprog
I201 Dividing arcs into quadrants: No
F-definitions or flags are a kind of variable used to control different positions. A flag could be either on or off (1/0) and could be used for instance to check if the coolant has been added or not. After the flag comments a colon should be entered and then the numbers of other flags. This implies that these flags are zeroed when this flag is entered. Below we can see that if flag F7 (Radius comp left) is entered flags F6 and F8 will be zeroed preventing radius compensating left and right from being active at the same time. We get the function of an ancient car stereo - when P1 is pressed down the knob of the selected radio station pops up. We can also create flags that do not zero any other flag by not writing any numbers after the colon. Note that all flags are zero or not entered from the start.
F1 Rapid move : 2,3,4,5
F2 Feed move : 1,3,4,5
F3 Clockwise move : 1,2,4,5
F4 C.Clockwise move : 1,2,3,5
F5 Drillcycle : 1,2,3,4
F6 Cutter comp off : 7,8
F7 Cutter comp left : 6,8
F8 Cutter comp right : 6,7
F09 Coolant water on : 10
F10 Coolant water off : 9
F11 Spindle clockwise : 12,13
F12 Spindle c.clockwise : 11,13
F13 Spindle stop : 11,12\\
V-definitions or variables as they are called are used to store (remember) numbers. They can be integers or decimal numbers and both positive and negative. For instance, in a variable current spindle revolutions or current z-position can be stored. We often use variables to check if a position has been changed to avoid outputting it on each line (modal codes).
M-definitions or macros are used to “bundle together” several instructions. A function which is to be used many times is normally written in a macro which can then be used by other macros. There are a number of mandatory macros used by the CamModule for instance to introduce a program (M1) or to create an arc clockwise (M6). In addition to these the user could create his own macros, so-called “User macros” (M101-M255). Such a macro could for instance contain the sequence for creating a block number or a change of tools.
:<$file> "(Filname:#$)#b" <$date> "(Date:#$" <$time>
"\ Time:#$)#b" <$progtxt> "(#$)#b" <xlength>\
"(Partsize X:#x" <ylength>" Y:#x" <zlength>\
" Z:#x)#b"<$prognr> "%#$" $F6
A parameter is a type of variable that cannot be fixed or changed by the user. A parameter is set by the CAM program depending on the data available in the processing file (BEA). A parameter is framed by < and > characters or by [ and ] symbols. Examples of parameters could be <xstopa> containing the next trailing point for the tool with absolute coordinates or <xstopi> which is the same thing although with incremental coordinates.
The parameters are:
<xstarta> Startpoint in X absolute
<ystarta> Startpoint in Y absolute
<zstarta> Startpoint in Z absolute
<xstopa> Endpoint in X absolute
<ystopa> Endpoint in Y absolute
<zstopa> Endpoint in Z absolute
<xstopi> Endpoint in X incremental
<ystopi> Endpoint in Y incremental
<zstopi> Endpoint in Z incremental
<xcenta> Centerpoint in X absolute
<ycenta> Centerpoint in Y absolute
<xcenti> Centerpoint in X incremental
<ycenti> Centerpoint in Y incremental
<zsnabbh> Rapid travel height
<radie> Arc radius
<diamet> Arc diameter
<xradie> Arc radius with X-scale
<xdiamet> Arc diameter with X-scale
<yradie> Arc radius with Y-scale
<ydiamet> Arc diameter with Y-scale
<astartp> Arc startangle (0° - 360°)
<astopp> Arc endangle (0° - 360°)
<astartm> Arc startangle (-180° till +180°)
<astopm> Arc endangle (-180° till +180°)
<abow> Arc total angle (-360° till +360°)
<bnum> Block number
<speed> Rotation speed of spindle
<spirot> Rotation direction 0=Clockw. 1=Counter Clockw.
<toolnr> Tool number
<tooldi> Tool diameter
<toolra> Tool radius
<toolle> Tool length
<toolreg> Tool register number
<$tooltxt> Tool name
<tooxnr> Next tool number
<tooxdi> Next tool diameter
<tooxra> Next tool radius
<tooxle> Next tool length
<tooxreg> Next tool register number
<$tooxtxt> Next tool name
<rkomp> Cutter comp.
0=Off 1=Left 2=Right
<water> Cool.water 0=Off 1=On
<xlength> Part X-length
<ylength> Part Y-length
<zlength> Part Z-length
<cyclnum> Number of point in cycle
<cyclend> 1 if last point in cycle
<opval1> Option value 1 (from option-window)
<opval2> Option value 2
<opval3> Option value 3
<opval4> Option value 4
<opval5> Option value 5
<opval6> Option value 6
<$optxt1> Option text 1 (from option-window)
<$optxt2> Option text 2
<$optxt3> Option text 3
<$date> Date of today (from computer date)
<$time> Time of day (from computer time)
<$prognr> Program number
<$progtxt> Program comments
NB. It is possible to write the name of the parameter in capitals as well as small letters but we use small letters as our standard.
The performance of the Cam program implies reading in the BEA file what to do next, setting the necessary parameters and calling the macro corresponding to the task to be done. If the BEA file says that it should move the tool up to transport height, the program sets the parameter <zstopa> etc. and calls macro M2 (i.e. the macro for moving the milling machine to transport height).
In M2 there may then be calls to other macros added to make the post processor perform different tasks. Then the program will read the next instruction from the BEA file, sets the parameters needed and calls to the macro matching the function.
It is important to understand the way the Cam program thinks when post processing a BEA file to enable you to produce a functioning post processor. Notice that the program does NOT read the macros in numerical order (M1,M2,M3 etc.) but jumps between these depending on which type of machining is involved.
In our macro a special language is used which we have chosen to call “The Macro Language”. In this language we can output parameters, perform calculations, set conditions, etc. We use different signs to do different things. It may look confusing to begin with but it will become clearer quite soon once you have begun working with the post processors. We will begin by describing how to output a simple text in a macro. Text strings such as these are always initiated and concluded by a quotation mark (“). If we want to output the word Kalle in our nc-program by means of a macro called M125 we simply write:
M125 My own macro : ”KALLE”
We will try to write some macros of our own a little further on in this booklet. Remember that even the spaces are counted as long as they are found inside the quotation marks so if we want a space character after Kalle we will have to write it like this:
M125 My own macro : ”KALLE ”
Inside the ”“ signs we can besides ordinary texts also insert special control codes to determine the appearance of the output. Control codes are always preceded by a # sign followed by a letter and sometimes digits, too. As an example of a control code can be adduced #b which implies row pitch or block end. If we want to output the text Kalle Andersson but we want these two words to end up each on its own line in the nc-program we simply write
M125 My own macro : ”KALLE#bANDERSSON”
Another control code is used to output the contents of a parameter and is called #x. This control code prints out the contents of the last-mentioned parameter. Mentioning a parameter implies printing it outside the ”“ signs. If, for instance, we want to print out an S followed by the number of spindle revolutions, we print the following macro:
M125 Print spindle rotation speed : <spirot> ”S#x”
Other control codes can be used to decide the appearance of a number at the output. An example could be #d indicating the minimum of decimals to be printed. If for instance, we want a macro that outputs the absolute x-value with at least two decimals added, the macro will look like this:
M125 Print out X : <xstopa> ”X#d2#x”
Below you will find a lists of control codes:
#b end-of-block #nnn prints the asciisign nnn (e.g. #003) ## prints # #” prints “ #x prints active parameter #$ prints active text parameter #Dn max. n number of decimals (3) #dn min. n number of decimals
(-1 =no decimal point)
#Rt fills in concluding zeros by t
(ä = none)
#Hn max. n-number of integers (9) #hn min. number of integers (1 #Lt fills in introductory zeros by t #Pt sign for decimal point
(ä= no decimal point (.))
#Tt sign at positive number (ä=none) #Nt sign at negative number (-) #Fn fills in to the right to the number of positions with the sign indicated by #R (0).
You can read more about control codes in the section called “Formatted output” further on in this booklet.
In addition to control codes we can set conditions etc. If, for instance, we want to check if a flag is not set (0) before calling a macro we can use a function which looks like this:
This means: IF FLAG 10 IS NOT SET CARRY OUT WHAT IT SAYS WITHIN THE BRACKETS.
When we use % the condition is carried out without the flag being influenced but we could also use the & sign which implies that the flag is set (becomes 1) after carrying out the instruction and then it will look like this:
This means: IF FLAG 10 IS NOT SET CARRY OUT WHAT IT SAYS WITHIN THE BRACKETS AND SET THE FLAG AFTERWARDS
- WHAT IS THE USE?
Suppose that we want a thing done only once in an NC-program. For instance, we want code M66 to be output in connection with the first change of tools but not in connection with the subsequent ones. Then we will have to start by creating a flag for this, choosing for instance flag 25.
F25 Flag for M66 :
Between the flag and the colon (must be included) we can print a commenting text which is there only to make it easier for us to remember what the flag is used for. This is not necessary but it simplifies matters when later on we set about editing the post processor. After the colon we print the numbers of the flags we want this flag to zero (see the section on flags) but this is not necessary for this flag.
It now remains to create the condition which will output code M66 the first time:
This means: IF FLAG 25 IS NOT SET OUTPUT M66 AND SET FLAG 25.
The flag being zero (not set) when we start the post processor the condition will be met the first time and since we use the &character the flag will be set which will entail that the condition will not be met the next time. It now remains to insert the condition in the desired position in the macro for the change of tools.
M111 Makro for toolchange: M103 <toolnr> ” T#x M6” \
Notice that we use the \-sign (backslash) to tell the post processor to go on reading the macro on the next line.
We can also indicate what we want to happen if the condition is not met (OR ELSE). If we want to change the macro for the change of tools so that M66 is output at the first change of tools and M67 (notice that this example is not necessarily logical but only used to explain the functions of the language) is output at all subsequent changes of tools we must add a pair of brackets to be executed if the condition is not met. This is done like this:
&F25(” M66”),(” M67”)
This means: IF FLAG 25 IS NOT SET OUTPUT M66 OTHERWISE OUTPUT M67 AND SET THE FLAG.
After all types of conditions we can print an alternative pair of brackets separately with a comma sign to be executed if the first pair of brackets was not executed. Those who know some BASIC would picture the above line like this:
IF F25=0 THEN
PRINT ” M66”
PRINT ” M67”
The $-sign is used to set unconditionally a variable at a value or to set a flag. If for instance we want to set variable 10 with the contents of <xstope> we write:
We can also make calculations when setting a variable:
which means that we set V10 with the contents of <xstope> +10 divided by 2. Notice that no priority is given but the calculations are made in the order they are input. We will return to calculations later on in this booklet.
If we want to set a flag (e.g. no 15 we write:
meaning that we set flag 15 at 1. If we want to zero a flag we will have to set another flag which in turn zeroes this flag. See section on flags.
By means of the *-character we can perform repetitions or loops as they are also called. Either we can let a flag control our loop or we can allow the loop to be controlled by the contents of a parameter or a variable.
If we want a pair of brackets to be repeated controlled by a parameter we write:
which means that the contents of the brackets will be repeated as many times as the contents of the parameter.
Instead of the name of a parameter we can write a calculation, a variable or an integer between the < and > signs. These will be created in the same way as a parameter of the post processor. See example below!
Edit the macro for program start (M1) and write as follows:
First write this on the line of M1 and then test-run. If you did it right, the result should be like this:
Test is written 10 times at the beginning of the program.
- Now what is the use of that?
Well, we can use loops in many contexts e.g. if we want to create a macro in order to determine an ellipse or something similar we will need to be able to loop in the macro. We will come back to this later.
The other variant of a loop controlled by a flag is used when we cannot tell in advance how many revolutions the loop should run. The loop will be executed until the flag is set.
meaning: REPEAT THE CONTENTS OF THE BRACKETS UNTIL F10 IS SET.
Since there is a risk that you happen to make an incorrect macro so that the flag is never set (you will then get an endless loop) the number of max. revolutions has been set at 1000. This means that the loop is unconditionally interrupted when the brackets have been repeated a thousand revs. If you want to change the number of max. revs there is a position for this called 17. Add this to the positions at the beginning of the post processor and write how many revolutions there should be at the maximum:
I7 Max no. of revolutions in a loop : 2000
It is also possible to press the ESC-key if you find that the post processor has got stuck in a loop.
We will also try a variant with a flag controlling the loop. Begin by adding another flag in the post processor:
F20 My own loop flag :
Also create a new variable that we may use:
V10 My variabel
Then exchange the first loop you wrote in M1 for the following:
$V10<0> *F20($V10<V10+1>”TEST NR:#x#b” <V10> =15($F20))
Test-run and check that it counts 15. The above line may need explaining?
We begin by setting variable 10 at zero. Then we indicate that we want a loop that is repeated until flag 20 is set. In the brackets of the loop we begin by adjusting V10 by 1 which is done by saying SV10<V10 >. Afterwards we write a text string (“TEST NO:#x#b”) containing two control codes, the first (#x) writes the last mentioned parameter which in this case happens to be a variable pretending to be a parameter because we wrote < and > signs around it. The next control code is #b which creates a row pitch. Finally we check if V10 is 15 and then we set flag 20.
-Complicated? We will try to give so many examples that things will become clearer by and by.
Besides checking if a parameter and a variable are equal we can also check if they are greater or smaller and then we write it like this:
which means: IF THE PARAMETER IS GREATER/SMALLER THAN VARIABLE 5 CARRY OUT THE BRACKETS.
We can also use an integer and then we write it like this:
meaning: IF THE PARAMETER IS GREATER THAN 10 CARRY OUT BRACKETS.
IF THE PARAMETER IS LESS THAN 10 CARRY OUT THE BRACKETS
In addition to the four rules of arithmetic we can also use sine, cosine, and tangents in our macros. This in combination with loops enables us to perform quite advanced macros calculating different things. See “Examples of options” at the end of the booklet.
If for instance we want to calculate the coordinate of a circle we use the formula:
X = RADIUS X COS (ANGLE IN DEGREES)
To write this in the post processor we need two variables containing X and Y and a variable for the radius and one for the angle:
Y = RADIUS X SIN (ANGLE IN DEGREES)
V10 X coordinate
Then we can write a new macro calculating the X,Y coordinates according to the values input in V12 and V13:
V11 Y coordinate
M120 Calculate X, Y coordinates
When calling macro 120 our coordinate will be found stored in V10 and V11.
As we have seen earlier there are a number of control codes to format the text output in the NC-program. In this section we will enter more deeply into how they function. The control codes are piled up one on top of the other in a text string telling the software how a number should be output. For instance we can look at macro 103 used for creating a new block number in our exemplifying post processor:
M103 Create new block no. : <bnum>”#bN#D0#x“
Here we see that some control codes are used to format the print-out. They are:
#b that changes the line
#D0 telling us there are no decimals
#x outputting the last-mentioned parameter (<bnum>)
By means of #D that defines the maximum number of decimals and #d defining the minimum number of decimals we can control the number of decimals. Study the table for different variants of these:
Example of the number = 5.123456
|Control codes||Results||Number = 5|
As you can see from the second line of the table we have defined the maximum number to 0 and the minimum number to 3 which is illogical. From the result you can see that the maximum number “wins” over the minimum number in these cases.
If you want to use 3 decimals as the maximum you do not have to write this as 3 goes for pre-positioned value (default) and if you do not want any decimals and no decimal point (-1) you do not have to write this either.
We can define the number of integers exactly in the same way as the number of decimals although in this case using the codes #H and #h.
#H max. number of integers (pre-positioned 9)
#h min. number of integers (pre-positioned 1)
By the code #P we define the kind of decimal point we want to use. It is pre-positioned to point but by writing #P we change it into a comma character instead.
Normally no character is displayed with positive numbers but you can change this by means of #T. If you write #T+ a +-sign will begin all positive numbers.
If for some reason you would like to change the minus character it can be done using #N.
#x will write the last-mentioned numeric parameter with the formatting decided by the control codes.
#$ will write the last mentioned text parameter. Text parameters are those parameters containing texts and numerals mixed and which cannot be counted. A text parameter always begins with an $-character. For instance, <$file> which contains the file name of the NC-program.
In addition to these control codes there are a number of codes used to fill up introductory and closing characters but we will not deal with those here as they are used fairly seldom.
- How do I change my lathe post processor to make it feed out the programs with diameter programming instead of radius programming?
- Find the macro feeding out the X-coordinate usually M104 and enter *2 into the parameter <ystopa> . Make sure that the x-value is not entered into any more places in the post processor (make changes there too in such cases).
M104 Set new X-pos : &V1<ystopa>(” X#x“)
M104 Set new X-pos : &V1<ystopa*2>(” X#x“)
- How do I get a decimal point after all numbers, even integers? My machine requires this otherwise the numbers will be interpreted as thousandths.
Find the macros writing out the X,Y,Z-coordinates. Ordinarily these are called M104, M105 and M106. Enter the code #d0 in front of #x into these.
M104 Set new X-pos : &V1<xstopa>(” X#x“)
M105 Set new Y-pos : &V2<ystopa>(” Y#x“)
M106 Set new Z-pos : &V3<zstopa>(” Z#x“)
M104 Set new X-pos : &V1<xstopa>(” X#d0#x“)
M105 Set new Y-pos : &V2<ystopa>(” Y#d0#x“)
M106 Set new Z-pos : &V3<zstopa>(” Z#d0#x“)
It could be that coordinate values are written out in several places in the post processor and then you will have to find these and enter the code #d0 there too.
- How do I get R-values instead of I and J on arcs less that 180 degrees
Change the macros M6-M9 from looking like this:
M6 Clockwise arc < than 180°
: M108 M103 ” G02“ M104 M105 <xcenti>” I#x“ <ycenti>\ ” J#x“ M101 M109
M7 Clockwise arc > than 180°: M6
M8 C.Clockwise arc < than 180°
: M108 M103 ” G03“ M104 M105 <xcenti>” I#x“ <ycenti>\ ” J#x“ M101 M109
M9 C.Clockwise arc > than 180°: M8
To look like this:
M6 Clockwise arc < than 180°
: M108 M103 ” G02“ M104 M105 <radie> ” R#x” M101 M109
M7 Clockwise arc > than 180°
: M108 M103 ” G02“ M104 M105 <xcenti>” I#x“ <ycenti>\ ” J#x“ M101 M109
M8 C.Clockwise arc < than 180°
: M108 M103 ” G03“ M104 M105 <radie> ” R#x” M101 M109
M9 C.Clockwise arc > than 180°
: M108 M103 ” G03“ M104 M105 <xcenti>” I#x“ <ycenti>\ ” J#x“ M101 M109
Notice that your macros may not look exactly like the above and then of course you will have to consider this when changing your macros.
- How do I make changes to have my NC-programs stored in a different folder?
There is a position at the beginning of the post processor indicating where the nc-programs will be stored. This position is called I102. Enter the search way into the catalogue where you want to store your programs after the colon of I102.
I102 File path : c:\ncprog
-My machine writes all values in thousandths and without decimals. How do I fix this?
Change the positions I3-I5 at the beginning of the post processor so that it says 1000 instead of 1 on these:
I3 X scale : 1000
I4 Y scale : 1000
I5 Z scale : 1000
Then change the macros that write out the X,Y, Z values (usually M104-M106) so that it says #D0 in front of # in them. Then check if X, Y, Z-values are entered into any more positions of the post processor and change those too, if necessary.
M104 Set new X-pos : &V1<xstopa>(” X#D0#x“)
M105 Set new Y-pos : &V2<ystopa>(” Y#D0#x“)
M106 Set new Z-pos : &V3<zstopa>(” Z#D0#x“)
-I want my first change of tools to look different from the subsequent ones in my nc-program. Can I change this?
Yes, look up the section on conditions at the beginning of this booklet. A similar case is described there.
- I have problems when I want to test-run my post processor. A red square appears where it says “Wrong character” or “Macro M99 missing” or suchlike. What is to be done?
It could be somewhat tricky to find out where the error is but begin by checking all macros and see to it that no colon is missing after their commentaries. Then make sure that all lines broken in the middle have a backslash ( \ ) afterwards. Also make sure that \ has not been entered on lines where it should not be. Also see to it that all text strings begin and end with a quotation mark (”). Above all, concentrate on the macros you entered last. Hopefully this will help you find the error.
- I have entered that I want the number of the tool output at the start of the program but I get the wrong number. What am I doing wrong?
The softwaresearches the bea-file step by step and sets the parameters needed at each operation. At the start of the program the tool number has not yet been set. This is done only in connection with “Fast transport to new X, Y position with one tool”. In order to get the number of the tool output at the start of the program you will have to use a parameter called <tooxno> which will give you the next tool number to be used.