Introduction to the ESPRIT post processor

21
dptechnology.com 1 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.

description

Introduction to the ESPRIT post processor

Transcript of Introduction to the ESPRIT post processor

Page 1: Introduction to the ESPRIT post processor

dptechnology.com 1

Introduction to ESPRIT Post ProcessorThis 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 generatesCLFile(cutterlocationfile)datathatdescribesthemachiningoperationinabsoluteterms.TheCLfilerepresentsthecutterpathformachiningyourpart.ItdoesnotreflectthespecificCNCmachinetoolandcontrolcapabilities of the machine you will actually use to cut the part.

Apostprocessor(*.asc)fileconvertsCLFiledatatothespecificformatoftheNCprogramforaparticularmachine. A post processor can do many things besides simply translating CL File data to NC machine codes. A postprocessorcanalsoberesponsibleforoutputtingthemostefficientandproductiveNCcodepossible.

In cases where the author of a post processor does not want anyone to modify the source code, they will provideacompiled.pstfileinsteadofaneditable.ascfile.Thecontentofa.pstfilescannotbeviewedoredited.

Page 2: Introduction to the ESPRIT post processor

dptechnology.com 2

Int

ro

du

ct

Ion

to

ES

Pr

It P

oS

t P

ro

cE

SS

or

BelowisanillustrationofthepostprocessorworkflowinESPRIT.

Theinformationcontainedina.ascfileisdividedintosections.Eachsectiondefinesaspecifictypeofinformation for the post.

•Header:Informationaboutthepost,suchasthenameofthemachine,themachineconfiguration,theauthor,thedatethefilewaswritten,andsoon.ThisinformationisnotoutputintheNCcode.

•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.ascfileforillustrationpurposesonly:

##############################

## Machine: 2-Axis Lathe

## Controller:

## ESPRIT Version: 2012

## Author:

## Company:

## Date:

## Comments:

## Modified Date:

##############################

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

PostName : Lathe.asc

Page 3: Introduction to the ESPRIT post processor

dptechnology.com 3

Int

ro

du

ct

Ion

to

ES

Pr

It P

oS

t P

ro

cE

SS

or

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)

Page 4: Introduction to the ESPRIT post processor

dptechnology.com 4

Int

ro

du

ct

Ion

to

ES

Pr

It P

oS

t P

ro

cE

SS

or

text editors for post processor fi les

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

Aconfigurationfileisprovidedwiththislesson,calledESPRIT.uew,tomakeiteasierforyoutovisualizeyourcode.UltraEditreads.uewfilesfromthedirectoryyouspecifytoconfigurethesyntaxhighlighting.

SetupUltraEdittoreadtheESPRIT.uewfileeachtimetheeditorstartsup.1. DownloadtheconfigurationfileESPRIT.uew to a directory on your computer (ESPRITWeb login required).2. Run UltraEdit.3. ClickAdvanced>Configuration.4. In the dialog, expand Editor Display and select Syntax Highlighting.5. ClickthebrowsebuttonnexttothedirectorypathandnavigatetothedirectorywherethefileESPRIT.uewis

located.6. Click Apply.7. Click OK to close the dialog.8. EverytimeyouopenafilewithUltraEdit,thesyntaxhighlightingfromtheESPRIT.uewfilewillbeused.

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

Page 5: Introduction to the ESPRIT post processor

dptechnology.com 5

Int

ro

du

ct

Ion

to

ES

Pr

It P

oS

t P

ro

cE

SS

or

System Variables

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 variablesTwo 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 NCmachine.IftheNCmachinecanmakemovesouttothefifthdecimalplace,thensetMachineToleranceto0.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 MoreWith system variables, the rule is: do not add variables unless you need to set a value other than default.

Example: Change N-code incrementIf 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

Page 6: Introduction to the ESPRIT post processor

dptechnology.com 6

Int

ro

du

ct

Ion

to

ES

Pr

It P

oS

t P

ro

cE

SS

or

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

Tospecifythecapabilitiesofthemachine,CircleModespecifieshowmuchofacircletheNCmachinecancutinone 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 CircleModeIf 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

Page 7: Introduction to the ESPRIT post processor

dptechnology.com 7

Int

ro

du

ct

Ion

to

ES

Pr

It P

oS

t P

ro

cE

SS

or

Sample NC code:

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

ThecolumnstotherightoftheSymboldefinethenumericfieldforthevaluethatisoutput.Numericvaluescanbe output with or without leading digits, trailing digits, a decimal point, or a positive or negative sign. The last set ofcolumns(Z1-Z4)givetheformatforwhenthevalueiszero.

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.

Formatablecodesmustbedefinedintheformatablecodessectionbeforetheycanbeusedinothersectionsofthepostfile.

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

Page 8: Introduction to the ESPRIT post processor

dptechnology.com 8

Int

ro

du

ct

Ion

to

ES

Pr

It P

oS

t P

ro

cE

SS

or

Examples of common formatsWhenoutputtingprogramnumbers(O0001(SAMPLE1)),thefirstfourdigitsneedtobefilledwithavalue.Toachieve 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:ThefirstYwillfilltheleadingdigitswithzeros;4setswhichdigitswillbefilled(4firstdigits);Ntomakesuretonotoutputadecimalpoint;Ntonotfilltrailingdigitswithzeros;0trailingdigitswouldbefilled.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, MiscGCodeOnlytwentycustomsymboliccodescanbedefinedusingMiscSymbolicCode#(seethenextsectiononSymbolicCodes). 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 MiscGCodedonotcorrespondtoanyvalueinESPRIT.Itsonlyuseisasauser-definedformatablethatisalwaysoverwritten, similar to MiscFormat1, etc.

Padding: Use of underscoresIntheNCcode,asymbolcanbeusedformultipledifferentcycles.Forexample,Qcanbeusedtodefinetheendsequence 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.

Allthesevaluesuseadifferentformatandsoneedtobedefinedwithdifferentformatablepropertiesinyourpost. 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. Thisishowyoucandefinemultipleformatablecodesthatneedtobeoutputusingthesamesymbolbutwithdifferent 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 codesUsing 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].

Page 9: Introduction to the ESPRIT post processor

dptechnology.com 9

Int

ro

du

ct

Ion

to

ES

Pr

It P

oS

t P

ro

cE

SS

or

Sign output set to (-1) to omit code, remove N numbersIf 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 formatSome 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 zerovalues,settheZeroFormatto----.Hereisanexampleforthedwelltime:

DwellTime : G04_U 1 3 Y 1 4 1 3 Y 1 4 0 - - - -

Symbolic codes

AsymboliccodeisgeneratedintheNCfileexactlyasitisshowninthepost.ascfile.Thestructureusedinthesymbolic codes section is:

Keyword : Symbol

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

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

Page 10: Introduction to the ESPRIT post processor

dptechnology.com 10

Int

ro

du

ct

Ion

to

ES

Pr

It P

oS

t P

ro

cE

SS

or

MotionRapid : G00

MotionLinear : G01

XYPlane : G17

EndProgram : M02

SpindleOff : M05

ToolChange : M06

CoolantOff : M09

Symboliccodesmustbedefinedinthesymboliccodessectionbeforetheycanbeusedinothersectionsofthe.ascfile.

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

ThesymboliccodesforG00,G01,M05,M09,andM02havealreadybeendefinedinthesymboliccodessection.

Symbolic switchesA symbolic switch is a keyword that switches output to one of several symbolic codes depending upon certain conditions.

Aswithothersymboliccodes,thesymboliccodesoutputusingasymbolicswitchmustbedefinedinthesymboliccodes section.

ThesymbolicswitchCircleDirectionspecificallyswitchesbetweenthesymbolsassignedtothekeywordsMotionCW 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,thesymboliccodedefinedforMotionCWorMotionCCWwillbeoutputdependingonthearcdirection.

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.

Page 11: Introduction to the ESPRIT post processor

dptechnology.com 11

Int

ro

du

ct

Ion

to

ES

Pr

It P

oS

t P

ro

cE

SS

or

MiscSymbolicCode#MiscSymbolicCode#(with#equaltoanindexnumberfrom1to20)correspondstoauserdefinedmiscellaneouscode.

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

InsteadofassigningcodestoMiscSymbolicCode#keywords,stringscanbehardcodedintoex_examplesby enclosing them in double quotes. See StringCharacter in ESPRIT Post Help for more details.

Variables

Variablesletyoustoresinglevalues,arraysofvalues,orcreateswitches.Inthepost.ascfileitispossibletodeclare variables for your own use. The format for doing this is:

Variable : VariableName1 VariableName2 VariableName3

Multiplevariablescanbedefinedononeline.

Nearlyanynamecanbeusedforavariableprovidedthatthereisn’talreadyasystemvariabledefinedwiththesamename.ForinstanceProgNumbercannotbeusedasavariablebecauseitisalreadydefinedasasystemvariable 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)pointofthefirstoperationneedstobeoutput.

HereavariablecanbeusedtodeterminewhetheraSetOriginhasbeencreated.Thevariableactslikeaflag.Initiallytheflagvariableiscleared,butassoonastheG92isoutput,thevariablewillbesetsoastopreventanyadditional 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

Page 12: Introduction to the ESPRIT post processor

dptechnology.com 12

Int

ro

du

ct

Ion

to

ES

Pr

It P

oS

t P

ro

cE

SS

or

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

Theexamplesabovedemonstratenumericvariables.User-definedvariablesmayalsocontainstrings,andthereis 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. YoucanalsomanuallyfindCLcodesinESPRITbyright-clickingonaparameterinatechnologypageandselecting Edit Properties. The CL code is displayed in parentheses at the top of the dialog.

Subroutines

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 definedasasubroutine.Thenifachangeneedstobemade,itonlyhastobedoneinonelocation.

Single-line subroutinesSome subroutines may be just part of a single line. The format for these subroutines is:

Define subroutine_name [code] EndDefine

Page 13: Introduction to the ESPRIT post processor

dptechnology.com 13

Int

ro

du

ct

Ion

to

ES

Pr

It P

oS

t P

ro

cE

SS

or

ThekeywordsDefineandEndDefineareusedtocreatethesubroutine.

To call the subroutine, a $subroutine_name is inserted into the appropriate examples. The $ is only used before thenamewhencallingitintheexamples,notwhendefiningit.

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 subroutinesOther subroutines may encompass several lines of NC code. The format for them is:

Define subroutine_name

: [code]

: ...

: [code]

EndDefine

Where,betweentheDefineandEndDefine,therecanbeasmanylinesofcodeasnecessary.

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

Page 14: Introduction to the ESPRIT post processor

dptechnology.com 14

Int

ro

du

ct

Ion

to

ES

Pr

It P

oS

t P

ro

cE

SS

or

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 DefineandEndDefine.Ifyouincludetheminbothplaces,youwillgetacompilationerror.

Notes:

•MakesuretoalwaysendasubroutinewithEndDefine

•Subroutinesmustalwaysbedefinedaboveallcalllocations

•In the samples above, the subroutine calls were all made within the Examples section. It is possible to make subroutinecallsinothersectionsofthepost.ascfile.Forexample,asubroutinecanbecalledfromanothersubroutine or as the argument for an If statement.

Examples section

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

Eachlineafterex_keywordthatstartswithacolonmakesalineintheNCfile.

Any line in an ex_ example can be broken up into multiple lines in the .asc but still only produce one line of code intheNCfile.Thisisdonebyusing\\linecontinuationinthe.asc:

Page 15: Introduction to the ESPRIT post processor

dptechnology.com 15

Int

ro

du

ct

Ion

to

ES

Pr

It P

oS

t P

ro

cE

SS

or

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:

•Eachex_exampleinyourpostprocessorfilemusthaveacolon(:)onitsfirstline

•Eachexamplecanonlybedefinedonce:eachexamplecanonlyhaveoneinstanceinthepostprocessor

Review of example flow orderToworkonapostprocessor,itisnecessarytoknowtheex_examplesworkflow.Thisway,theproperlogiccanbe implemented in each example of your post processor.

ThebestwaytoreviewthisfloworderistopostthelongNCcode:inESPRIT,gotoFile>AdvancedNCcode…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.

LongNCcodeshowsthe“ex_...”keywordsfromthe.ascfilebeforetheline(s)ofNCcodethatkeywordproduced.Thisway,youcanseethepostingfloworder.

Sample:

Page 16: Introduction to the ESPRIT post processor

dptechnology.com 16

Int

ro

du

ct

Ion

to

ES

Pr

It P

oS

t P

ro

cE

SS

or

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

Inbothcases,however,theexamplethatiscalledcandependonwhatotherexamplesaredefined(ornotdefined)inthepost.ascfile.

Page 17: Introduction to the ESPRIT post processor

dptechnology.com 17

Int

ro

du

ct

Ion

to

ES

Pr

It P

oS

t P

ro

cE

SS

or

ex_CycleStart is a Hard example, and it always appears at the start of an operation, unless it is a drilling type operationandex_PTOPCycleStartisdefinedinthepost.ascfile.Ifex_PTOPCycleStartisdefinedinthepost.ascfile,thenitwillbeusedforthestartofdrillingtypeoperationsinsteadofex_CycleStart.

IfCannedCyclewasYesandCycleTypewasTap2onadrillingtechnologydialog,butthepost.ascfiledidnotcontain the ex_Tap2Start and ex_Tap2Body examples, then ex_TapStart and ex_TapBody would be used instead. Ifthoseexampleswerenotdefinedinthepost.ascfileeither,thenitwouldresorttobreakingthemotionupintoex_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 whereyouneedNCcodeoutput,thenyoucanaddthatExampletoyourpost.ascfileandbeconfidentthatitwillalways 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 thosesettingsorevenremovingthoseexamplekeywordsfromyourpost.ascfilealtogethertoseewhatexamples are called and what NC code output they produce instead.

overwrit 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 formatablevaluewithzero,buttheG91*forcesthecodeintoincrementalmode.Soinsteadofgettingamoveofzero,yougettheincrementalmovenecessarytotakeyoubacktothezeroposition.IfthetoolwasatX5tobegin with, instead of X0 output in the NC code, the output would be X-5.

Anotherexampleofthisistryingtoapplyascalefactor.Maybeyouhaveauser-definedvariablecalledscalethatis 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.

ThesolutioninallcasesistodefineaMiscFormat#keyword,suchasMiscFormat1,andoverwritethesymbolforthatMiscFormat#.

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

Page 18: Introduction to the ESPRIT post processor

dptechnology.com 18

Int

ro

du

ct

Ion

to

ES

Pr

It P

oS

t P

ro

cE

SS

or

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

Whenwritingyourpostprocessor,youwilloftenhavetodebugthevalueofyourdefinedvariablestomakesurethat 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)

Page 19: Introduction to the ESPRIT post processor

dptechnology.com 19

Int

ro

du

ct

Ion

to

ES

Pr

It P

oS

t P

ro

cE

SS

or

Logical operators

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 functionsThe following mathematical operators can be used in the post processor (given in order of precedence):

( ) Parenthesis(bydefault),orwhateverisdefinedastheStartExpandEndExp,areusedtogrouppartsofanexpression.Whateverisinsidehasthehighestprecedence,andisevaluatedfirst.

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

Page 20: Introduction to the ESPRIT post processor

dptechnology.com 20

Int

ro

du

ct

Ion

to

ES

Pr

It P

oS

t P

ro

cE

SS

or

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 keywords to add loops in the program

Special keywords let you add more functionality to your post.

ThekeywordsIfandElsewilladdalooptotheprogramtotestforaspecifiedcondition.

• ‘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

Page 21: Introduction to the ESPRIT post processor

dptechnology.com 21

DP Technology Corp. Phone: 1 800 627-84791150 Avenida Acaso Outside the US: + 1 805 388-6000Camarillo, CA 93012 USA Email: [email protected]

ESPRIT is a registered trademark of DP Technology Corp.©2011 DP Technology Corp. All rights reserved.

Int

ro

du

ct

Ion

to

ES

Pr

It P

oS

t P

ro

cE

SS

or

: 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