Professional Documents
Culture Documents
Introduction To ESPRIT Post Processor
Introduction To ESPRIT Post Processor
This guide is an introduction to the ESPRIT Post Processor. You will be given tips that will help you write your own
post processor or modify an existing one.
Please always refer to the ESPRIT Post Help (in ESPRIT go to Help > Post Help). Most of the points mentioned in
this guide are explained in detail there.
You Will Learn...
Basic facts about post processors
How to download and set up the UltraEdit text editor
System Variables
Machine Modes
Formatable Codes
Symbolic Codes
Variables
Subroutines
Examples section
Overwriting dimensions
Debugging
Logical operators
Mathematical operators and functions
Special keywords to add loops in the program
A few basics
Every CAM user should know a few basic facts about post processors. Programming a part in a CAM system is
one thing. Getting programs out of the CAM system and into a format the CNC machine can use to cut parts is
another. Thats the job of the post processor.
ESPRIT provides the fundamental architecture to support the capabilities of the machine. This architecture
generates CL File (cutter location file) data that describes the machining operation in absolute terms. The CL file
represents the cutter path for machining your part. It does not reflect the specific CNC machine tool and control
capabilities of the machine you will actually use to cut the part.
A post processor (*.asc) file converts CL File data to the specific format of the NC program for a particular
machine. A post processor can do many things besides simply translating CL File data to NC machine codes. A
post processor can also be responsible for outputting the most efficient and productive NC code possible.
In cases where the author of a post processor does not want anyone to modify the source code, they will
provide a compiled .pst file instead of an editable .asc file. The content of a .pst files cannot be viewed or
edited.
dptechnology.com
The information contained in a .asc file is divided into sections. Each section defines a specific type of
information for the post.
Header: Information about the post, such as the name of the machine, the machine configuration, the
author, the date the file was written, and so on. This information is not output in the NC code.
System Variables: Default values for the post, such as the output of sequence numbers or the type of
machining operation being performed
Machine Modes: Default values for the machine, such as the default angle output range and format for a
rotary axis
Formatable Codes: Codes that get values from the operation technology in ESPRIT, such as the tool number
or spindle speed
Symbolic Codes: Codes that are output as is in the NC output, such as G00 and G01
Examples: Examples of the NC code that is output, such as the code for a tool change or the code for a rapid
move
Sample .asc file for illustration purposes only:
##############################
## Machine: 2-Axis Lathe
## Controller:
## Company:
## Date:
## Comments:
## Modified Date:
##############################
******* System Variables *******
PostName
: Lathe.asc
dptechnology.com
: 0.00001
MaxNCode
: 9999
MaxCircleRadius
NCodeDefault
NCodeIncrement
MachineTolerance
: 9999
: 100
: 10
: Absolute
CenterMode
: IncrementFromStart
CircleMode
MeasurementMode
RadialValueMode
: By180
: Metric
: Diametral
: O
Y 4 N N 0
Y 4 N N 0
- - - -
ZAbsolute
: Z
N 2 Y N 5
N 3 Y N 4
1 N 0 0
XAbsolute
XCenterAbsolute
ZCenterAbsolute
SequenceNumber
StartSequenceNumber
EndSequenceNumber
: X
: I
N 2 Y N 5
: K
N 4 Y N 4
N 4 Y N 4
: N
: P
Y 4 N N 0
N 3 N N 0
: Q
N 3 N N 0
N 3 Y N 4
N 5 Y N 3
N 5 Y N 3
Y 4 N N 0
N 3 N N 0
N 3 N N 0
1
1
1
0
0
0
1 N 0 0
1 N 0 0
1 N 0 0
- - - 1 N 0 0
1 N 0 0
: G00
MotionCW
: G02
MotionLinear
MotionCCW
Dwell
Inch
Metric
: G01
: G03
: G04
: G20
: G21
: O*
ex_MachineSetup
: MachineSetupComment
ex_FirstToolChange
: ToolChangeComment
: TimeStamp
: N CoordinateCode* MeasurementCode*
: N T*(101 * PresentTool)
dptechnology.com
: ToolChangeComment
: N T*(101 * PresentTool)
ex_LastToolChange
: ToolChangeComment
: N T*(101 * PresentTool)
ex_ToolCancel
ex_CycleStart
: Comment
: N SpindleUnit
S_
SpindleDirection
SpindleRange
CoolantCode
ex_OtherToolChange
dptechnology.com
: Value
System Variables
Some system variables have a more advanced use in the Examples section of the post. In that case, system
variables and functions can be used to determine certain values from ESPRIT.
Less is More
With system variables, the rule is: do not add variables unless you need to set a value other than default.
: 1
MaxNCode
: 9999
NCodeDefault
: 0
: N
N 4 N N 0
N 4 N N 0
- - - -
Sample NC code:
N1 (SPINDLE-1 GROOVING FACE - CANNED CYCLE)
N2 (T1515 GROOVING INSERT FACE 3V)
N3 G28 U0
N4 G28 V0 W0
N5 G54
dptechnology.com
N20 G28 V0 W0
N25 G54
Machine Modes
Machine modes serve two purposes:
To set certain default machine values in case they are not set in the ESPRIT program
To give important machine requirements that are not found within any of the technology in ESPRIT
The structure used in the machine modes section is:
****** MACHINE MODES ******
Keyword
: Value
N6 G00 T1515
: Absolute
CircleMode
: By360
MeasurementMode
CenterMode
WorkPlaneMode
: Metric
: IncrementFromStart
: XYPlane
For example, the default for MeasurementMode can be Inch or Metric. CoordinateMode can be Incremental but
is almost always set to Absolute. If these values have already been programmed in ESPRIT, these two machine
modes are ignored.
To specify the capabilities of the machine, CircleMode specifies how much of a circle the NC machine can cut in
one block of NC code. If the machine can cut a 360-degree arc in one block of code, then By360 can be set for
CircleMode. If the machine can cut up to 90 degrees in one block and must break down circles larger than 90,
then use ByQuadrant.
: By360
dptechnology.com
Formatable Codes
Formatable codes are used to return values from the operation technology in ESPRIT, such as the tool number
and X, Y, and Z coordinates.
The structure of the formatable codes section is unique in that it has several columns of information.
Keyword
: Symbol
I1 I2 I3 I4 I5
M1 M2 M3 M4 M5
Z1 Z2 Z3 Z4
The columns to the right of the Symbol define the numeric field for the value that is output. Numeric values can
be output with or without leading digits, trailing digits, a decimal point, or a positive or negative sign. The last set
of columns (Z1-Z4) give the format for when the value is zero.
Sample NC code:
FORMATABLE CODES
Inch Output
**************************
L # . T #
Metric Output
L # . T #
+/-
Zero Value*
L . # +/-*
************************************************************************
XAbsolute
: X
N 4 Y N 4
N 5 Y N 3
1 N 0 0
DiameterCompensation : D
Y 2 N N 0
Y 2 N N 0
1 N 0 0
ToolNumber
: T
Y 2 N N 0
Y 2 N N 0
- - - -
The keyword returns a value from ESPRIT. For example, XAbsolute returns the value of the X coordinate in
ESPRIT. The symbol for XAbsolute is usually X.
Formatable codes must be defined in the formatable codes section before they can be used in other sections of
the post file.
Below is an example of formatable codes being used in the Examples section. The X, Y, and Z coordinates,
the I and J circle center coordinates, the T for the tool number, S for spindle speed, and F for feedrate are all
formatable codes.
ex_Circle
: N G17 CircleDirection* X Y I* J* F
ex_OtherToolChange
: ToolChangeComment
ex_Rapid
: N G00 X Y Z
ex_Linear
: N G01 X Y Z F
: N T M06
dptechnology.com
When outputting program numbers (O0001(SAMPLE 1)), the first four digits need to be filled with a value. To
achieve this, ProgramNumber can be set this way:
ProgramNumber
: O
Y 4 N N 0
Y 4 N N 0
- - - -
MiscMCode, MiscGCode
Only twenty custom symbolic codes can be defined using MiscSymbolicCode# (see the next section on Symbolic
Codes). A good alternative to avoid using up all of them is to use MiscMCode and MiscGCode.
MiscMCode and MiscGCode formatable codes can be used for miscellaneous M and G codes. MiscMCode and
MiscGCode do not correspond to any value in ESPRIT. Its only use is as a user-defined formatable that is always
overwritten, similar to MiscFormat1, etc.
All these values use a different format and so need to be defined with different formatable properties in your
post. To be able to do that, you can use the padding technique (use of _ symbol):
EndSequenceNumber
: Q
N 4 N N 0
N 4 N N 0
- - - -
Peck
: Q__
N 3 N Y 4
N 3 N Y 3
1 N 0 0
MiscFormat5
: Q_
N 3 N Y 4
N 5 N Y 3
- - - -
When using the above formatable codes in your post, only Q and its value will be output. The _ will be ignored.
This is how you can define multiple formatable codes that need to be output using the same symbol but with
different formatting.
Notes:
The amount of padding is not limited. You can add as many underscores as you need since all of the
underscores will be stripped.
You can also pad symbolic codes (discussed in the next section). For example, CoolantFlood: M8_M28 will
output both M codes on one line with a space between them.
Double dot format for inserting symbols and numbers in the middle of formatable codes
Using the double dot format, you can insert symbols and numbers in the middle of formatable codes. This can be
very useful when working with variables on your machine.
Here is an example:
MiscFormat1
: Z[#500+..]
1 3 Y 1 4
1 5 Y 1 3
1 Y 1 0
You can then use in the post examples Z[#500+..]*(Value that needs to be output).
For example, Z[#500+..]*(2) will be output like this (with above format): Z[#500+2.0].
dptechnology.com
If Sign Output (fourth column) of a formatable code is set to (-1), the output of the symbol and value will be
suppressed. This is, for example, a very useful way to turn off the output of N-codes in the NC code.
In this example, the sign output is set to 0 so that the N-codes will output with no sign.
****** FORMATABLE CODES ******
SequenceNumber
: N
N 4 N N 0
N 4 N N 0
- - - -
N4 G28 V0 W0
N5 G54
N6 G00 T1515
Now, if you change the format properties as follow, the N-codes will not be output anymore:
****** FORMATABLE CODES ******
SequenceNumber
: N
N 4 N N 0
N 4 N N 0
-1
- - - -
G28 V0 W0
G54
G00 T1515
Zero format
Some values (like the dwell time) should not be output in the NC code if their value is set to 0 in ESPRIT.
This can be achieved using the Zero Format properties of the formatable codes section. To omit the output of
zero values, set the Zero Format to - - - -. Here is an example for the dwell time:
DwellTime
: G04_U
1 3 Y 1 4
1 3 Y 1 4
- - - -
Symbolic Codes
A symbolic code is generated in the NC file exactly as it is shown in the post .asc file. The structure used in the
symbolic codes section is:
Keyword
: Symbol
dptechnology.com
: G00
XYPlane
: G17
MotionLinear
EndProgram
: G01
: M02
SpindleOff
: M05
ToolChange
: M06
CoolantOff
: M09
Symbolic codes must be defined in the symbolic codes section before they can be used in other sections of the
.asc file.
Below is an example of symbolic codes being used in the Examples section.
ex_Rapid
: N G00 X Y Z
ex_ToolCancel
: N M05 M09
ex_Linear
ex_MainEnd
: N G01 X Y Z F
: N M02
The symbolic codes for G00, G01, M05, M09, and M02 have already been defined in the symbolic codes section.
MotionRapid
Symbolic switches
A symbolic switch is a keyword that switches output to one of several symbolic codes depending upon certain
conditions.
As with other symbolic codes, the symbolic codes output using a symbolic switch must be defined in the symbolic
codes section.
The symbolic switch CircleDirection specifically switches between the symbols assigned to the keywords
MotionCW and MotionCCW. CircleDirection typically would have the following:
MotionCW
: G02
MotionCCW : G03
Here is an example:
ex_Circle
: N G17 CircleDirection* X Y I* J* F
If G02 or G03 were used directly in ex_Circle instead of the switch, the post would not work because all arcs
would be output with the same direction code, either G02 or G03. By using the CircleDirection symbolic switch
instead, the symbolic code defined for MotionCW or MotionCCW will be output depending on the arc direction.
This symbolic switch switches between just two symbolic codes, but there are many other symbolic switches that
switch between three or more symbolic codes.
CompensationSide, often found in ex_Compensation, will switch between CompensationOff, CompensationLeft,
and CompensationRight which are typically G40, G41 and G42. CoolantCode will switch between CoolantOff,
CoolantOn, CoolantMist, CoolantFlood, CoolantFlood2 etc. depending on the coolant setting chosen for a
particular tool.
dptechnology.com
10
MiscSymbolicCode# (with # equal to an index number from 1 to 20) corresponds to a user defined miscellaneous
code.
Here is an example:
****** FORMATABLE CODES ******
ProgramNumber
: O
Y 4 N N 0
Y 4 N N 0
1 N 0 0
: G10
ex_MachineSetup
: O*
: G10
: MachineSetupComment
Instead of assigning codes to MiscSymbolicCode# keywords, strings can be hardcoded into ex_ examples
by enclosing them in double quotes. See StringCharacter in ESPRIT Post Help for more details.
MiscSymbolicCode#
Variables
Variables let you store single values, arrays of values, or create switches. In the post .asc file it is possible to
declare variables for your own use. The format for doing this is:
Variable
: X_
: Y_
N 4 Y N 4
N 4 Y N 4
N 5 Y N 3
N 5 Y N 3
1
1
1 N 0 0
1 N 0 0
dptechnology.com
11
: Z_
N 4 Y N 4
N 5 Y N 3
SetOrigin
: G92
Variable
: seto
ex_StartCode
: seto=(0)
ex_SetOrigin
ex_CycleStart
: If (seto=0)
1 N 0 0
: seto=(1)
:
:
: EndIf
ex_StartCode
: opcount=(0)
ex_CycleDefinition
: opcount=(opcount+1)
MiscFormat3
: css(opcount)=(nextclfile(418))
: fpr(opcount)=(nextclfile(416))
The examples above demonstrate numeric variables. User-defined variables may also contain strings, and there
is a set of string functions for dealing with strings and string variables.
The index numbers for CL codes can be found in the Appendix of the ESPRIT Post Help. For example, CL
code 418 returns the spindle speed and CL code 416 returns the feed rate from the ESPRIT operation.
You can also manually find CL codes in ESPRIT by right-clicking on a parameter in a technology page and
selecting Edit Properties. The CL code is displayed in parentheses at the top of the dialog.
Subrout ines
There are a lot of examples where certain portions of the code may be repeated over and over again. If a change
has to be made to this code, one of the locations could easily be missed. Repeated code like this can instead be
defined as a subroutine. Then if a change needs to be made, it only has to be done in one location.
Single-line subroutines
Some subroutines may be just part of a single line. The format for these subroutines is:
Define subroutine_name [code] EndDefine
dptechnology.com
12
To call the subroutine, a $subroutine_name is inserted into the appropriate examples. The $ is only used before
the name when calling it in the examples, not when defining it.
As one example, maybe all of the drilling canned cycles in a post are canceled with N G00 G80 M09. Instead
of putting this into all of the cancel examples and risking having to change it several places later, a single line
subroutine could be made like so:
Define cannedcancel N G00 G80 M09 EndDefine
The cancel examples would then call this subroutine like this:
ex_DrillCancel
: $cannedcancel
ex_PeckCancel
: $cannedcancel
ex_TapCancel
: $cannedcancel
ex_BoreCancel
: $cannedcancel
Multi-line subroutines
The keywords Define and EndDefine are used to create the subroutine.
Other subroutines may encompass several lines of NC code. The format for them is:
Define subroutine_name
: [code]
: ...
: [code]
EndDefine
Where, between the Define and EndDefine, there can be as many lines of code as necessary.
A typical mill post may contain the following:
ex_FirstToolChange
: T M06
: ToolChangeComment
: T(secondtool)
ex_OtherToolChange
: T M06
: ToolChangeComment
: T(nexttool)
ex_LastToolChange
: T M06
: ToolChangeComment
: T*(firsttool)
: T M06
: ToolChangeComment
dptechnology.com
13
ex_FirstToolChange
$tc
ex_OtherToolChange
$tc
ex_LastToolChange
$tc
: T(secondtool)
: T(nexttool)
: T*(firsttool)
Notice how there is no colon (:) between the ex_ keyword and the $ for the subroutine call.
This is because, with a multiple line subroutine, the colons are embedded between the subroutine keywords
Define and EndDefine. If you include them in both places, you will get a compilation error.
Notes:
Make sure to always end a subroutine with EndDefine
Subroutines must always be defined above all call locations
In the samples above, the subroutine calls were all made within the Examples section. It is possible to make
subroutine calls in other sections of the post .asc file. For example, a subroutine can be called from another
subroutine or as the argument for an If statement.
EndDefine
: NC Code Format
The format of the NC code is given to the right of the colon(s). There are several different types of codes used to
give the NC format. Three of the most important types seen in the Examples section are, as seen above:
Symbolic codes
Symbolic switches
Formatable codes
Some examples produce a single line of NC code. A typical arc move may look like this:
ex_Circle
: N G17 CircleDirection* X Y I* J* F
Other examples may generate several lines of NC code like this tool change example:
ex_OtherToolChange
: ToolChangeComment
: N T M06
Each line after ex_ keyword that starts with a colon makes a line in the NC file.
Any line in an ex_ example can be broken up into multiple lines in the .asc but still only produce one line of code
in the NC file. This is done by using \\ line continuation in the .asc:
dptechnology.com
14
: Comment
Important notes:
Each ex_ example in your post processor file must have a colon (:) on its first line
Each example can only be defined once: each example can only have one instance in the post processor
ex_CycleStart
Long NC code shows the ex_... keywords from the .asc file before the line(s) of NC code that keyword
produced. This way, you can see the posting flow order.
Sample:
dptechnology.com
15
G30 V0 W0
G54
576 Hard ex_ConstantSurface
577 Hard ex_SetWorkCoor
G00 T1414
M69
G00 C-180.0
G00 Z-19.644
C-90.0
C0.0
C90.0
G80
M09
G30 U0
G30 V0 W0
M05
M69
M46
dptechnology.com
16
If Canned Cycle was Yes and Cycle Type was Tap 2 on a drilling technology dialog, but the post .asc file did not
contain the ex_Tap2Start and ex_Tap2Body examples, then ex_TapStart and ex_TapBody would be used instead.
If those examples were not defined in the post .asc file either, then it would resort to breaking the motion up into
ex_Rapid and ex_Linear moves.
Knowing this difference and what the terms Hard and Soft mean can be somewhat useful when Debugging.
If you see a Hard example in the Long (or Extended) NC Code listings that is coming out at a certain location
where you need NC code output, then you can add that Example to your post .asc file and be confident that it will
always be called in that same relative location.
If you see some Soft examples in the Long (or Extended) NC Code listings that you did not expect to see, then
you know that certain technology settings are causing those examples to be output. You can then try changing
those settings or even removing those example keywords from your post .asc file altogether to see what
examples are called and what NC code output they produce instead.
ex_CycleStart is a Hard example, and it always appears at the start of an operation, unless it is a drilling type
operation and ex_PTOPCycleStart is defined in the post .asc file. If ex_PTOPCycleStart is defined in the post .asc
file, then it will be used for the start of drilling type operations instead of ex_CycleStart.
: X
N 4 Y N 4
N 5 Y N 3
1 N 0 0
MiscFormat1
: X_
N 4 Y N 4
N 5 Y N 3
1 N 0 0
YAbsolute
MiscFormat2
MotionRapid
: Y
: Y_
N 4 Y N 4
N 4 Y N 4
N 5 Y N 3
N 5 Y N 3
1
1
1 N 0 0
1 N 0 0
: G00
dptechnology.com
17
If you always make it a rule to only overwrite formatable miscellaneous codes and never overwrite formatable
dimensions, you will save yourself a lot of headaches.
Debugging
When writing your post processor, you will often have to debug the value of your defined variables to make sure
that your logic or your mathematical expression is correct.
Before ESPRIT 2010, you probably used a formatable code to do that:
MiscFormat1
: Debug
N 4 Y N 4
N 5 Y N 3
1 N 0 6
Variable : Test
ex_Rapid
: Debug*(Test)
This way is not the best way to do it because the output of the value of your variable is subject to the formatting
of the DEBUG formatable. For instance, if you are working in metric, only three digits will be output and so your
variable will be rounded.
To debug in ESPRIT, you should use OutputString(). It was added as part of the string variable support in ESPRIT
2010.
With this function, you can easily output a variable to the standard listing (without overwriting a formatable and
thus limiting the number of places after the decimal shown). The example above would become:
Variable : Test
ex_Rapid
: OutputString(Test= + Test)
dptechnology.com
18
Greater than
<
Less than
Equal to
<>
Not equal
>=
<=
||
Or
&&
And
Parenthesis (by default), or whatever is defined as the StartExp and EndExp, are used to group parts of
an expression. Whatever is inside has the highest precedence, and is evaluated first.
Negation. Numbers which are to be negated should be enclosed in parenthesis, as in (-2). Variables and
expressions which are to be negated should be multiplied by (-1), as in (-1)*(expression).
Multiplication
Addition
Logical operators
ABS is a function that returns the absolute value of an argument. If the value is positive, the absolute
value is the same. If the value is negative, it is negated so as to be a positive value of the same
magnitude.
ACS
ACS is a function that returns the arccosine value. ACS is the angle (in degrees) that has a cosine value
equal to the given argument.
ASN
ASN is a function that returns the arcsine value. ASN is the angle (in degrees) that has a sine value
equal to the given argument.
ATN
ATN is a function that returns the arctangent value. ATN is the angle (in degrees) that has a tangent
value equal to the given argument.
COS
COS is a function that returns the cosine of a given angle. The angle value is given in degrees.
EXP
EXP is a function that raises the natural logarithm (e) to the power of the argument. In other words,
EXP(x) equals e^x. e is a transcendental constant (like pi) and has a value off approximately 2.71828.
INT
INT is a function that returns the next lowest integer value for a given argument.
For positive numbers, this is the number with the decimal portion removed. For Negative numbers
with a decimal portion, it is one less than the number with that decimal portion removed. For example,
INT(3.14) = 3 while INT(-3.14) = (-4).
LN
LN is a function that returns the natural logarithm value. The natural logarithm is the power to which
the constant e must be raised to equal the given value. e^LN(x) = x. e is a transcendental constant
(like pi) and has a value off approximately 2.71828.
dptechnology.com
19
SIN is a function that returns the sine of a given angle. The angle value is given in degrees.
SQR
SQR is a function that returns the square of a value (that value to the power of 2). SQR(x) equals x^2.
SQRT
TAN
TAN is a function that returns the tangent of a given angle. The angle value is given in degrees.
Notes:
The + operator is also used to concatenate strings. If either of the operands in an expression is a string, then
the + is treated as concatenation. The + operator only works as addition of both operands are numbers or
numeric variables.
The exponent operator ^ is not supported, but it is easily worked around using the EXP and LN functions
since: x^y=exp(y*ln(x)).
SIN
ElseIf is a special keyword that is useful for testing several ranges of values
EndIf is a special keyword that closes an If conditional branch
If Example (single line):
ex_Rapid
If (NextTool=0) \\
Else \\
T*(NextTool) \\
EndIf
EndDefine
What comes before the Else is executed when the condition is true. What appears after the Else and before the
EndIf is executed when the condition is false.
Instead of writing a separate line of code for each Else and If condition, the ElseIf keyword lets you shorten the
code to make it easier to read.
ElseIf Example:
ex_CycleStart
: Comment
: If (SpindleSpeed<500)
:
: ElseIf (SpindleSpeed<1250)
dptechnology.com
20
: Else
: EndIf
The keywords While and EndWhile will add a continuous loop to the program that will execute as long as a given
test condition is true. As soon as the condition is false, the loop will terminate.
While is a special keyword that starts a loop that will continue while the condition is true and terminate as
soon as the condition is false
EndWhile is a special keyword that closes a While loop
While example:
Variable
: LoopCounter
MiscFormat1
: =~
ex_EndCode
: LoopCounter=(1)
N 4 N N 0
N 4 N N 0
1 N 0 0
: ElseIf (SpindleSpeed<2500)
: EndWhile
DP Technology Corp.
1150 Avenida Acaso
Camarillo, CA 93012 USA
21