Post Processor Lessons - Lesson 5
POST MODIFICATION LESSON 5: CHANGING VARIABLE FORMAT ON THE FLY
In this lesson we will be using some special syntax to allow us to modify the output format of a variable only for a specific location in the NC output code.
What we will do to illustrate using this command is to change the feedrate for Z axis feed moves to output as an integer with no decimal places, but the feedrate for XY cutting will have decimal places output.
Example of Normal Output:
(TOOL #1 0.25 1/4 FLAT ENDMILL - STANDARD)
N02 T1 M6
N03 G00 G90 G54 X1.7823 Y-1.25 S1191 M03
N04 G43 H1 D1 Z1. M08
N05 Z0.2
N06 Z0.1
N07 G01 Z-0.375 F6.6738
N08 G41 D1 X1.9149 Y-1.3826 F13.3476
N09 G17 G03 X2.235 Y-1.25 I0.1326 J0.1326
N10 X1.265 Y-1.25 I-0.485 J0.
N11 X2.235 Y-1.25 I0.485 J0.
N12 X1.9149 Y-1.1174 I-0.1875 J0.
N13 G40 G01 X1.7823 Y-1.25
N14 G00 Z0.2
N15 Z1.
N16 M09
N17 M05
N18 G90
N19 M01
The highlighted feedrate above is the feedrate we wish to change to not have decimal places. Normally the decimal places output are defined using the Post Question: 216, however changing the post question will affect all feedrates output in the NC output code. We wish to only alter the feedrate that is output on the Z axis feed moves as shown below.
Variable Formatting
The output format of posting variables can be controlled using a special formatting string (or format specifier). The format specifier controls the number of leading and/or trailing digits to use and whether or not a decimal point is used. The format specifier is placed before the variable in the post processor. The output of the variable in the posted NC program is shown in the following example.
Example Usage
'[5.4L]'post_variable_name
The following examples show the output of a variable with a value of 9.15 Formatting String |
Output |
'[5.4L]' |
00009.1500 |
'[5.1L]' |
00009.1 |
'[4.L]' |
0009.15 |
'[3L]' |
009 |
'[.4T]' |
9.1500 |
'[5T]' |
915000 |
'[.1T]' |
9.1 |
'[1T]' |
91 |
- The single quotes must be used as a part of the formatting string.
- Notice the first example, '[5.4L]', outputs the value with five digits before the decimal place (leading) and four digits after the decimal place (trailing).
- The capital letter, L, must be used to specify the first value as the leading digits used (or if using only a single number in the string). The letter is always placed at the end of the formatting string.
- The capital letter, T, is used to when specifying (only) the trailing digits used.
- If no decimal point is used in the formatting string, the decimal is not used in the resulting output. (Notice the output of the examples that don't use the decimal point.)
We are going to use the following files for this lesson:
Machine File: BC_3x_Mill
|
|
Lesson 5 – Step 1:
With debugging turned on in the post processor and looking at the NC output code we can see that Post Block: 51 is outputting the Z axis move at feed. It is important to look in the rest of the program to determine if any additional locations are using Post Block: 51 for output that we may not want to modify. In this lesson this is not an issue and we can continue.
Lesson 5 – Step 2:
Modify the output post line in Post Block: 51 to the following:
51. Line feed move Z
n,feed_move,z_f, ‘[1L]’feed_rate
Lesson 5 – Step 3:
Save the post processor and generate the NC output code.
(TOOL #1 0.25 1/4 FLAT ENDMILL - STANDARD)
N02 T1 M06
N03 G00 G90 G54 X1.7823 Y-1.25 S1191 M03
N04 G43 H1 D1 Z1. M08
N05 Z0.2
N06 Z0.1
N07 G01 Z-0.375 F7
N08 G41 D1 X1.9149 Y-1.3826 F13.3476
N09 G17 G03 X2.235 Y-1.25 I0.1326 J0.1326
N10 X1.265 Y-1.25 I-0.485 J0.
N11 X2.235 Y-1.25 I0.485 J0.
N12 X1.9149 Y-1.1174 I-0.1875 J0.
N13 G40 G01 X1.7823 Y-1.25
N14 G00 Z0.2
N15 Z1.
N16 M09
N17 M05
N18 G90
N19 M01
Notice the output on N07 is now showing “F7”. This is because we used the syntax ‘[1L]’. This syntax is giving us only 1 place leading with no decimal point. It is important to realize that removing decimal place output will result in the output value being rounded.
Lesson 5 – Step 4:
We will now alter the output so the output does have a decimal point but does not output any trailing zeros. Modify the output post line in Post Block: 51 to the following:
51. Line feed move Z
n,feed_move,z_f, ‘[1.l]’feed_rate
Lesson 5 – Step 5:
Save the post processor and generate the NC output code.
(TOOL #1 0.25 1/4 FLAT ENDMILL - STANDARD)
N02 T1 M06
N03 G00 G90 G54 X1.7823 Y-1.25 S1191 M03
N04 G43 H1 D1 Z1. M08
N05 Z0.2
N06 Z0.1
N07 G01 Z-0.375 F7.
N08 G41 D1 X1.9149 Y-1.3826 F13.3476
N09 G17 G03 X2.235 Y-1.25 I0.1326 J0.1326
N10 X1.265 Y-1.25 I-0.485 J0.
N11 X2.235 Y-1.25 I0.485 J0.
N12 X1.9149 Y-1.1174 I-0.1875 J0.
N13 G40 G01 X1.7823 Y-1.25
N14 G00 Z0.2
N15 Z1.
N16 M09
N17 M05
N18 G90
N19 M01
Notice that now the output has the decimal place after the value on N07.