Professional Documents
Culture Documents
Introduction To The ESPRIT Post Processor PDF
Introduction To The ESPRIT Post Processor PDF
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. That’s 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 1
Below is an illustration of the post processor work flow in ESPRIT.
##############################
## Machine: 2-Axis Lathe
## Controller:
## ESPRIT Version: 2012
## Author:
## Company:
## Date:
## Comments:
## Modified Date:
##############################
PostName : Lathe.asc
dptechnology.com 2
Introduction to ESPRIT Post Processor
MachineTolerance : 0.00001
MaxCircleRadius : 9999
MaxNCode : 9999
NCodeDefault : 100
NCodeIncrement : 10
CoordinateMode : Absolute
CircleMode : By180
CenterMode : IncrementFromStart
MeasurementMode : Metric
RadialValueMode : Diametral
ProgramNumber : O Y 4 N N 0 Y 4 N N 0 0 - - - -
XAbsolute : X N 2 Y N 5 N 3 Y N 4 1 1 N 0 0
ZAbsolute : Z N 2 Y N 5 N 3 Y N 4 1 1 N 0 0
XCenterAbsolute : I N 4 Y N 4 N 5 Y N 3 1 1 N 0 0
ZCenterAbsolute : K N 4 Y N 4 N 5 Y N 3 1 1 N 0 0
SequenceNumber : N Y 4 N N 0 Y 4 N N 0 0 - - - -
StartSequenceNumber : P N 3 N N 0 N 3 N N 0 0 1 N 0 0
EndSequenceNumber : Q N 3 N N 0 N 3 N N 0 0 1 N 0 0
MotionRapid : G00
MotionLinear : G01
MotionCW : G02
MotionCCW : G03
Dwell : G04
Inch : G20
Metric : G21
ex_MainStart : O*
: TimeStamp
ex_MachineSetup : MachineSetupComment
: N CoordinateCode* MeasurementCode*
ex_FirstToolChange : ToolChangeComment
: N G00* X*(XTC) Z*(ZTC)
: N T*(101 * PresentTool)
dptechnology.com 3
Introduction to ESPRIT Post Processor
ex_OtherToolChange : ToolChangeComment
: N G00* X*(XTC) Z*(ZTC)
: N T*(101 * PresentTool)
ex_LastToolChange : ToolChangeComment
: N G00* X*(XTC) Z*(ZTC)
: N T*(101 * PresentTool)
ex_CycleStart : Comment
: N SpindleUnit S S_ SpindleDirection SpindleRange CoolantCode
dptechnology.com 4
System Variables
Less is More
With system variables, the rule is: do not add variables unless you need to set a value other than default.
NCodeIncrement : 1
NCodeDefault : 0
MaxNCode : 9999
SequenceNumber : N N 4 N N 0 N 4 N N 0 0 - - - -
Sample NC code:
dptechnology.com 5
Introduction to ESPRIT Post Processor
N6 G00 T1515
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:
CoordinateMode : Absolute
MeasurementMode : Metric
CircleMode : By360
CenterMode : IncrementFromStart
WorkPlaneMode : 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.
CircleMode : By360
dptechnology.com 6
Sample NC code:
Now, if you change CircleMode to By180 (arcs which are greater than 180 degrees will be broken up into multiple
lines of NC code), your NC code will be:
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 S 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.
A post may have the following in its formatable codes section:
XAbsolute : X N 4 Y N 4 N 5 Y N 3 1 1 N 0 0
ToolNumber : T Y 2 N N 0 Y 2 N N 0 0 - - - -
DiameterCompensation : D Y 2 N N 0 Y 2 N N 0 0 1 N 0 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_OtherToolChange : ToolChangeComment
: N T M06
ex_Rapid : N G00 X Y Z
ex_Linear : N G01 X Y Z F
dptechnology.com 7
Examples of common formats
ProgramNumber : O Y 4 N N 0 Y 4 N N 0 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.
EndSequenceNumber : Q N 4 N N 0 N 4 N N 0 0 - - - -
MiscFormat5 : Q_ N 3 N Y 4 N 5 N Y 3 0 - - - -
Peck : Q__ N 3 N Y 4 N 3 N Y 3 0 1 N 0 0
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 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 8
Sign output set to (-1) to omit code, remove N numbers
SequenceNumber : N N 4 N N 0 N 4 N N 0 0 - - - -
Now, if you change the format properties as follow, the N-codes will not be output anymore:
SequenceNumber : N N 4 N N 0 N 4 N N 0 -1 - - - -
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 0 - - - -
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 9
Introduction to ESPRIT Post Processor
MotionRapid : G00
MotionLinear : G01
XYPlane : G17
EndProgram : 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_Linear : N G01 X Y Z F
ex_ToolCancel : N M05 M09
ex_MainEnd : N M02
The symbolic codes for G00, G01, M05, M09, and M02 have already been defined in the symbolic codes section.
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:
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#
ProgramNumber : O Y 4 N N 0 Y 4 N N 0 0 1 N 0 0
MiscSymbolicCode1 : 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.
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:
: VariableName=(expression)
Once the variable is declared, it can be used like any other variable, such as the built-in system variables and
functions. It can be used as part of a mathematical expression to overwrite formatable values, or it can be used
as part of logical condition testing.
Suppose that if a Set Origin operation is created in EDM, the output is to be G92 with the X, Y, and Z Start
Positions from the Set Origin page. But if a Set Origin is not created, then a G92 with X, Y, and Z of the approach
(entry) point of the first operation needs to be output.
Here a variable can be used to determine whether a Set Origin has been created. The variable acts like a flag.
Initially the flag variable is cleared, but as soon as the G92 is output, the variable will be set so as to prevent any
additional G92 output:
MiscFormat1 : X_ N 4 Y N 4 N 5 Y N 3 1 1 N 0 0
MiscFormat2 : Y_ N 4 Y N 4 N 5 Y N 3 1 1 N 0 0
dptechnology.com 11
Introduction to ESPRIT Post Processor
MiscFormat3 : Z_ N 4 Y N 4 N 5 Y N 3 1 1 N 0 0
SetOrigin : G92
Variable : seto
ex_StartCode : seto=(0)
ex_CycleStart : If (seto=0)
: G92 X_*(xnext) Y_*(ynext) Z_*(znext)
: seto=(1)
: EndIf
ex_StartCode : opcount=(0)
ex_CycleDefinition : opcount=(opcount+1)
: 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:
dptechnology.com 12
Introduction to ESPRIT Post Processor
The keywords Define and EndDefine are used to create the subroutine.
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:
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
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)
Define tc
: T M06
: ToolChangeComment
dptechnology.com 13
Introduction to ESPRIT Post Processor
EndDefine
ex_FirstToolChange $tc
: T(secondtool)
ex_OtherToolChange $tc
: T(nexttool)
ex_LastToolChange $tc
: 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.
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:
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
Introduction to ESPRIT Post Processor
ex_CycleStart : Comment
: SpindleUnit If (spindlespeed<500) S(1) Else \\
If ((spindlespeed>=500) && (spindlespeed<1250)) \\
S(2) Else S(3) EndIf EndIf SpindleDirection
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
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
Introduction to ESPRIT Post Processor
575 Hard ex_OtherToolChange
N45 (SPINDLE-1 WRAP DRILLING OD Y0 - BORE)
(T1414 EM 05.0 L)
G30 U0
G30 V0 W0
G54
G00 T1414
576 Hard ex_ConstantSurface
577 Hard ex_SetWorkCoor
578 Hard ex_CycleStart(DrillWrap) M69
G98 G19 M45
G97 S3000 M13
579 Hard ex_ChangeWorkSystem(DrillWrap)
580 Soft ex_Rapid(DrillWrap)
581 Soft ex_Rapid(DrillWrap)
582 Hard ex_StartPoint(DrillWrap) G00 C-180.0
G00 Z-19.644
X42.1 Y0.0 M08
583 Soft ex_BoreStart(DrillWrap) G89 X34.4 R0.0 F150.0
584 Soft ex_BoreBody(DrillWrap) C-90.0
585 Soft ex_BoreBody(DrillWrap) C0.0
586 Soft ex_BoreBody(DrillWrap) C90.0
587 Soft ex_BoreCancel(DrillWrap) G80
588 Hard ex_CycleEnd(DrillWrap)
589 Hard ex_ToolCancel M09
G30 U0
G30 V0 W0
M05
M69
M46
dptechnology.com 16
ex_CycleStart is a Hard example, and it always appears at the start of an operation, unless it is a drilling type
XAbsolute : X N 4 Y N 4 N 5 Y N 3 1 1 N 0 0
YAbsolute : Y N 4 Y N 4 N 5 Y N 3 1 1 N 0 0
MiscFormat1 : X_ N 4 Y N 4 N 5 Y N 3 1 1 N 0 0
MiscFormat2 : Y_ N 4 Y N 4 N 5 Y N 3 1 1 N 0 0
MotionRapid : G00
dptechnology.com 17
Introduction to ESPRIT Post Processor
Define XOut X_(overwrite expression) NCOutputOff X NCOutputOn EndDefine
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 7 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
dptechnology.com 18
Logical operators
() 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
/ Division (same precedence as multiplication)
% Modulus, which returns the remainder after division
+ Addition
- Subtraction (same precedence as addition)
ABS 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
Introduction to ESPRIT Post Processor
SIN 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 SQRT is a function that returns the square root of a given value.
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)).
Define PreCallTool
If (NextTool=0) \\
If (PresentTool<>FirstTool) T*(FirstTool) EndIf \\
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)
: SpindleUnit S(1) SpindleDirection
: ElseIf (SpindleSpeed<1250)
: SpindleUnit S(2) SpindleDirection
dptechnology.com 20
Introduction to ESPRIT Post Processor
: ElseIf (SpindleSpeed<2500)
: SpindleUnit S(3) SpindleDirection
: Else
: SpindleUnit S(4) SpindleDirection
: 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 : =~ N 4 N N 0 N 4 N N 0 0 1 N 0 0
ex_EndCode : LoopCounter=(1)
: “To fully demonstrate this example, do a Set Origin”
: “or Machine Setup and change the Program Number.”
: While (LoopCounter<=prognumber)
: “Loop Counter” =~*(LoopCounter)
: LoopCounter=(LoopCounter+1)
: EndWhile
dptechnology.com 21