You are on page 1of 21

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. 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.

Introduction to ESPRIT Post Processor


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:
## ESPRIT Version: 2012
## Author:
## Company:
## Date:
## Comments:
## Modified Date:
##############################

******* System Variables *******

PostName : Lathe.asc

dptechnology.com  2
Introduction to ESPRIT Post Processor
MachineTolerance : 0.00001
MaxCircleRadius : 9999
MaxNCode : 9999
NCodeDefault : 100
NCodeIncrement : 10

******* Machine Modes *******

CoordinateMode : Absolute
CircleMode : By180
CenterMode : IncrementFromStart
MeasurementMode : Metric
RadialValueMode : Diametral

******* Formatable Codes *******

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

******* Symbolic Codes *******

MotionRapid : G00
MotionLinear : G01
MotionCW : G02
MotionCCW : G03
Dwell : G04
Inch : G20
Metric : G21

******* Examples *******

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_ToolCancel : N G00* G28* G40* G49* G80* M05* M09*

ex_CycleStart : Comment
: N SpindleUnit S S_ SpindleDirection SpindleRange CoolantCode

Tex t editors for post processor files


Posts can be edited in the ESPRIT NC Editor or any other text editor, even Notepad.
An inexpensive editor that works well for post processors is UltraEdit, a multi-purpose text, HTML and XML
editor, and an advanced PHP, Perl, Java and JavaScript editor for programmers. UltraEdit is useful for editing
posts because the syntax highlighting lets you visually sort your code by highlighting related parts of the source
code as different colors.
Information about UltraEdit is available here: http://www.ultraedit.com
A free trial version of UltraEdit is available here: http://www.ultraedit.com/downloads/ultraedit_download.html
A configuration file is provided with this lesson, called ESPRIT.uew, to make it easier for you to visualize your
code. UltraEdit reads .uew files from the directory you specify to configure the syntax highlighting.
Set up UltraEdit to read the ESPRIT.uew file each time the editor starts up.
1. Download the configuration file ESPRIT.uew to a directory on your computer (ESPRITWeb login required).
2. Run UltraEdit.
3. Click Advanced > Configuration.
4. In the dialog, expand Editor Display and select Syntax Highlighting.
5. Click the browse button next to the directory path and navigate to the directory where the file ESPRIT.uew is
located.
6. Click Apply.
7. Click OK to close the dialog.
8. Every time you open a file with UltraEdit, the syntax highlighting from the ESPRIT.uew file will be used.

dptechnology.com  4
System Variables

Introduction to ESPRIT Post Processor


System variables serve two purposes:
• They allow certain default values to be set
• Other variables can be used to call special features
The structure used in the system variables section is:

****** SYSTEM VARIABLES ******


Keyword : Value

Commonly used variables


Two system variables that are commonly used are NCodeDefault and NCodeIncrement. NCodeDefault is the
sequence number to start the program and NCodeIncrement is how much the sequence number increases on
each line.
Other system variables allow the user to call up special functions or conditions. For example, some machines
cannot have spaces in the NC code. The system variable called RemoveSpaces provides this function.
Perhaps the most important system variable is MachineTolerance. It should be set to the resolution of the
NC machine. If the NC machine can make moves out to the fifth decimal place, then set MachineTolerance to
0.00001 in the post. Any move that is less than the MachineTolerance value will be eliminated from the NC code
output.
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.

Example: Change N-code increment


If the system variable NCodeIncrement is set to 1 in your post processor, whenever SequenceNumber N will be
called, the current sequence number will incremented by 1.
Note that with the settings below, N will start at N1 (First N value output in the code will be: NCodeDefault 0 plus
NCodeIncrement 1) and will reach at the most N9999.

****** SYSTEM VARIABLES ******

NCodeIncrement : 1
NCodeDefault : 0
MaxNCode : 9999

****** FORMATABLE CODES ******

SequenceNumber : N N 4 N N 0 N 4 N N 0 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  5
Introduction to ESPRIT Post Processor
N6 G00 T1515

Now, if you change NCodeIncrement to 5, your NC code will be:

N5 (SPINDLE-1 GROOVING FACE - CANNED CYCLE)


N10 (T1515 GROOVING INSERT FACE 3V)
N15 G28 U0
N20 G28 V0 W0
N25 G54
N30 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:

****** MACHINE MODES ******


Keyword : Value

Review of common modes


Below is an example of typical machine modes:

****** MACHINE MODES ******

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.

Example: Change CircleMode


If the machine mode CircleMode is set to By360 in your post processor, any arc up to a full circle can be output
as one line of NC code.

****** MACHINE MODES ******

CircleMode : By360

dptechnology.com  6
Sample NC code:

Introduction to ESPRIT Post Processor


G03 X58.371 Y15.998 Z-75.921 R16.0

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:

G03 X56.87 Y-15.998 Z-76.479 R16.0


X58.371 Y15.998 Z-75.921 R16.0

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:

************************** FORMATABLE CODES **************************


* Inch Output Metric Output +/- Zero Value*
* L # . T # L # . T # L . # +/-*
************************************************************************

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_Circle : N G17 CircleDirection* X Y I* J* F

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

Introduction to ESPRIT Post Processor


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 0 - - - -

O: Symbol that will be output in NC code.


Y 4 N N 0: The first Y will fill the leading digits with zeros; 4 sets which digits will be filled (4 first digits); N to
make sure to not output a decimal point; N to not fill trailing digits with zeros; 0 trailing digits would be filled.
The same settings are applied for inch and metric output.
0: Sign output is set to 0 so that the program number will always output with no sign.

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.

Padding: Use of underscores


In the NC code, a symbol can be used for multiple different cycles. For example, Q can be used to define the end
sequence number for a turning canned cycle, to specify the depth of cut or the step over for a grooving canned
cycle, to specify the peck increment for drilling canned cycles, 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 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

Introduction to ESPRIT Post Processor


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 0 - - - -

Sample NC code (with above format properties):

N1 (SPINDLE-1 GROOVING FACE - CANNED CYCLE)


N2 (T1515 GROOVING INSERT FACE 3V)
N3 G28 U0
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 - - - -

Sample NC code (with above format properties):

(SPINDLE-1 GROOVING FACE - CANNED CYCLE)


(T1515 GROOVING INSERT FACE 3V)
G28 U0
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 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

A post may have the following in its symbolic codes section:

****** SYMBOLIC CODES ******

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:

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#

Introduction to ESPRIT Post Processor


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 0 1 N 0 0

****** SYMBOLIC CODES ******

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:

Variable : VariableName1 VariableName2 VariableName3

Multiple variables can be defined on one line.


Nearly any name can be used for a variable provided that there isn’t already a system variable defined with the
same name. For instance ProgNumber cannot be used as a variable because it is already defined as a system
variable in the post processor language. Also, variable names cannot start with a number, so Milling5Axis is
valid, but 5AxisMilling is not.
The variable can be assigned a value in any ex_ example by using the following format:

: 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_SetOrigin : G92 X_*(xstart) Y_*(ystart) Z_*(zstart)


: seto=(1)

ex_CycleStart : If (seto=0)
: G92 X_*(xnext) Y_*(ynext) Z_*(znext)
: seto=(1)
: EndIf

An array variable can be declared with the format array_name(lower_index..upper_index).


Suppose there was a 4-axis lathe post where, for sync purposes, all of the spindle speeds and feed rates had
to be known prior to changing to the tool used for those operations. The example ex_CycleDefinition is called
for each operation at the beginning of the NC code. In this example all of the feed and speed values could be
recorded into an array for later use. The following would do just that:

Variable : css(1..999) fpr(1..999) opcount

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:

Define subroutine_name [code] EndDefine

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:

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
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)

This could be rewritten with a subroutine as:

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.

E xamples sect ion


The Examples section is the heart of the post because it gives examples of what the output NC code is
supposed to look like. The example keywords all start with ex_. Everything that is programmed in ESPRIT has a
corresponding ex_ keyword in the post.
The structure used in the Examples section is:

ex_Keyword : 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
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

Review of example flow order


To work on a post processor, it is necessary to know the ex_ examples workflow. This way, the proper logic can
be implemented in each example of your post processor.
The best way to review this flow order is to post the long NC code: in ESPRIT, go to File > Advanced NC code …
or push on Ctrl + F9 on your keyboard:

The Advanced NC Code Output window will be displayed.


Select “Long”to display the long NC code when you post.

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

Hard vs. Soft


As you can see in the sample above, there are Soft and Hard examples.
• A Hard example is always called, regardless of any technology or other settings
• Soft examples are only called based on certain conditions
ex_StartCode is a hard example because it always comes at the start of the NC Code output. ex_MainStart is a
hard example because it always comes at the start of the main program. Likewise ex_MainEnd and ex_EndCode
are hard examples.
ex_Tap2Start and ex_Tap2Body are soft examples, because they are only used if Canned Cycle is Yes and the
Cycle Type is set to Tap 2 on the drilling technology dialog. If Canned Cycle was Yes and Cycle Type was just
Tap, then the soft examples ex_TapStart and ex_TapBody would be called instead. If Canned Cycle was No, then
instead of those examples, the motion would be broken down into all of the ex_Rapid and ex_Linear moves
necessary to perform the tapping on each hole. ex_Rapid and ex_Linear are themselves Soft examples.
In both cases, however, the example that is called can depend on what other examples are defined (or not
defined) in the post .asc file.

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

Introduction to ESPRIT Post Processor


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.
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.

Over writ ing Dimensions


In overwriting formatable values, the distinction between formatable dimensions and formatable miscellaneous is
very important. It can be summed up like so:
• Formatable Miscellaneous values can always be overwritten
• Overwriting Formatable Dimension values can give unpredictable output in the NC code and is strongly
recommended against
Values that come from the graphics are called Dimensions, while the name Miscellaneous is used for values that
typically come from the technology pages. For example, XAbsolute is considered a formatable dimension while
ToolNumber is considered a formatable miscellaneous.
Probably the best example of this is in posts for multi-axis mills. When rotating table axes, it is usually desired
to send the tool to a safe home position. This is often accomplished with G91 G28 X0 Y0 Z0 in the NC code.
One way you could try to get this output may be with G91* G28* X(0) Y(0) Z(0). The (0) says to overwrite the
formatable value with zero, but the G91* forces the code into incremental mode. So instead of getting a move
of zero, you get the incremental move necessary to take you back to the zero position. If the tool was at X5 to
begin with, instead of X0 output in the NC code, the output would be X-5.
Another example of this is trying to apply a scale factor. Maybe you have a user-defined variable called scale that
is set via one of the custom page settings. Suppose your I and J values on arcs or U and V values on 4 axis are
measured incrementally from X and Y. Well, if you overwrite the X and Y values directly, then you also change
the reference for these incremental calculations. So if you just try to apply the same scale to the I and J or U and
V values, then the numbers will come out wrong.
The solution in all cases is to define a MiscFormat# keyword, such as MiscFormat1, and overwrite the symbol for
that MiscFormat#.
While you do not overwrite the formatable dimension, you still need to update it as if it had been output. This is
done with NCOutputOff and NCOutputOn. So in general, take the approach shown in the example below:

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

Define YOut Y_(overwrite expression) NCOutputOff Y NCOutputOn EndDefine

ex_Rapid : G00 $XOut $YOut

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

ex_Rapid : OutputString(“Test=” + Test)

dptechnology.com   18
Logical operators

Introduction to ESPRIT Post Processor


The following logical operators can be used in the post processor:

> Greater than


< Less than
= Equal to
<> Not equal
>= Greater than or equal to
<= Less than or equal to
|| Or
&& And

Mathematical operators and functions


The following mathematical operators can be used in the post processor (given in order of precedence):

() 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)

Besides mathematical operators there are also mathematical functions:

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)).

Special key words to add loops in t he program


Special keywords let you add more functionality to your post.
The keywords If and Else will add a loop to the program to test for a specified condition.
• ‘If’ is a special keyword that branches the NC code output depending upon a test condition
• ‘Else’ is a special keyword that separates the true and false branches of an If condition
• ‘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 (OutputStartPoint=1) ExitExample EndIf


: G00 X Y Z CoolantCode

If/Else Example (multiple lines):

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

DP Technology Corp. Phone: 1 800 627-8479


1150 Avenida Acaso Outside the US: + 1 805 388-6000
Camarillo, CA 93012 USA Email: esprit@dptechnology.com

ESPRIT is a registered trademark of DP Technology Corp.


©2011 DP Technology Corp. All rights reserved.

dptechnology.com   21

You might also like