Você está na página 1de 22

Post Perfect: An Introduction to ESPRIT Post Processor

1. Introduction
This class is an introduction to ESPRIT post processor. You will be given tips that will help you write your own post processor or to modify an existing one. This class is also a prerequisite for the more advanced post processor classes: Post Perfect: 4- and 5-Axis Output and Post Perfect: Mill-Turn Output. Important note: Please always refer to ESPRIT Post Help (in ESPRIT go to Help > Post Help). Most of the points below are covered, explained and detailed there.

2.

What's new in ESPRIT post processor: new park cycle and tool change location

A new Park cycle is introduced in ESPRIT 2012. It is now possible to park a head without selecting a tool. Park positioning has also been improved and optimized. You can even position your head in the machine work coordinate system (G53). Finally, new return modes have been implemented to precisely control how to park your tool. On every tool pages, there is also a new tool change movement option: it is possible to select machine work coordinate system (G53). Please see the class Get Your Move On: Strategies for Multitasking and Pinch Machining for more details. Park and tool change do now share the same positioning options. These improvements will require some changes in your post processor. These will be explained and documented in the class Post Perfect: Mill-Turn Output.

3.

System variables
a. Introduction

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

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

c. Less is More
With system variables, the rule is: do not add variables unless you need to set a value other than default.

d. Example: Change N-code increment


If the system variable NCodeIncrement is set 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 NCodeDefault MaxNCode : 1 : 0 : 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 N6 G00 T1515

Now, if you change NCodeIncrement to 5, you 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

4.

Machine modes
a. Introduction

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:
Keyword : Value

b. Review of common items


Below is an example of typical machine modes:
****** MACHINE MODES ****** CoordinateMode MeasurementMode CircleMode CenterMode WorkPlaneMode : Absolute : Metric : By360 : IncrementFromStart : XYPlane

For example, the default for MeasurementMode can be Inch or Metric. CoordinateMode can be Incremental but is almost always set to Absolute. If these values have already been programmed in ESPRIT, these two machine modes are ignored. To specify the capabilities of the machine, CircleMode specifies how much of a circle the NC machine can cut in one block of NC code. If the machine can cut a 360degree 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.

c. Example: Change CircleMode If the machine mode CircleMode is set By360 in your post processor, any arc up to a full circle can be output as one line of NC code.
****** MACHINE MODES ****** CircleMode : 1

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), you NC code will be:
G03 X56.87 Y-15.998 Z-76.479 R16.0 X58.371 Y15.998 Z-75.921 R16.0

5.

Formatable codes
a. Introduction

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 L # . T #

************************** +/Zero Value* L . # +/-*

Metric Output L # . T #

************************************************************************ XAbsolute ToolNumber : X : T N 4 Y N 4 Y 2 N N 0 Y 2 N N 0 N 5 Y N 3 Y 2 N N 0 Y 2 N N 0 1 0 0 1 N 0 0 - - - 1 N 0 0

DiameterCompensation : D

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 ex_OtherToolChange : N G17 CircleDirection* X Y I* J* F : ToolChangeComment : N T M06 ex_Rapid ex_Linear : N G00 X Y Z : N G01 X Y Z F

b. Examples of common formats


When outputting program numbers (O0001(SAMPLE 1)), the first four digits need to be filled with zeros. 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 digits with zeros; 4 sets which digits will be filed (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 program number always output with no sign.

c. MiscMCode, MiscGCode Only twenty custom symbolic codes can be defined using (MiscSymbolicCode#; see next part). A good alternative to avoid using them all 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.

d. Padding: Use of underscores In the NC code, a symbol can be used for multiple different cycle. 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 All these values use different format and so needs to be defined with different formatable properties in your post. To be able to that, you can use the padding technique (use of _ symbol):
EndSequenceNumber MiscFormat5 Peck : Q : Q_ : Q__ N 4 N N 0 N 3 N Y 4 N 3 N Y 4 N 4 N N 0 N 5 N Y 3 N 3 N Y 3 0 0 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 needs 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 use the padding on symbolic codes (even if it is not necessary).

e. Double dot format for inserting symbols and numbers in

middle of formatable codes


Using the double dot format, you can insert symbols and numbers in the middle of formatable codes. This can be very useful when working with variables on your machine. Here is an example:

MiscFormat1

: Z[#500+..]

1 3 Y 1 4

1 5 Y 1 3

1 Y 1 0

You can then use in the post examples Z[#500+..]*(Value that needs to be output). Z[#500+..]*(2) for example will be output like this (with above format): Z[#500+2.0].

f. Sign output set to (-1) to omit code, remove N numbers If Sign Output (fourth column) of a formatable code is set to (-1), the output of 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.
****** 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

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

6.

Symbolic codes
a. Introduction

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 ****** : G00 : G01 : G17 : M02 : M05 : M06 : M09

MotionRapid MotionLinear XYPlane EndProgram SpindleOff ToolChange CoolantOff

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 ex_Linear ex_ToolCancel ex_MainEnd : N G00 X Y Z : N G01 X Y Z F : N M05 M09 : N M02

The symbolic codes for G00, G01, M05, M09, and M02 have already been defined in the symbolic codes section.

b. Symbolic switches A symbolic switch is a keyword that switches output to one symbolic code out of several possible symbolic codes based on certain conditions. As with other symbolic codes, the symbolic codes output as part of a symbolic switch must be defined in the symbolic codes section. Here is an example:
ex_Circle : N G17 CircleDirection* X Y I* J* F

The symbolic switch that can be seen above is CircleDirection. From CircleDirection in ex_Circle, the NC code output will be a G02 or G03 depending on the direction of the arc move. As with other symbolic codes, the symbolic codes output as part of a symbolic switch must be defined in the symbolic codes Section. CircleDirection typically would have the following:
MotionCW MotionCCW : G02 : G03

Note that if G02 or G03 would directly be used in ex_Circle instead of the switch, it would not matter what keyword would be used. In the case of the symbolic switch, however, the keyword is very critical. CircleDirection specifically switches between the symbols assigned to the keywords MotionCW and MotionCCW. 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. SpindleDirection, often found in the tool change examples, will switch between SpindleOff, SpindleCW, and SpindleCCW, which are typically M03, M04, and M05.

c. MiscSymbolicCode# MiscSymbolicCode# (with #, 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 ex_MachineSetup : G10 : O* : G10 : MachineSetupComment

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

7.

Variables: store values, switches (flags) and arrays

In the post .ASC file it is possible to declare variables for your own use. The format for doing this is:
Variable : list of variables

The variable can be assigned a value in any ex_ example by using the following format:
: variable_name=(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 Overwriting Formatable Values, or it can be used as part of a 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 MiscFormat2 MiscFormat3 SetOrigin Variable : X_ : Y_ : Z_ : G92 : seto N 4 Y N 4 N 4 Y N 4 N 4 Y N 4 N 5 Y N 3 N 5 Y N 3 N 5 Y N 3 1 1 1 1 N 0 0 1 N 0 0 1 N 0 0

ex_StartCode ex_SetOrigin

: seto=(0) : 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 feedrates 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 ex_StartCode ex_CycleDefinition : css(1..999) fpr(1..999) opcount : opcount=(0) : 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.

8. Subroutines
a. Introduction
There are a lot of examples where certain parts of 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.

b. Single line, multi-line


Single line subroutines:

Some subroutines may be just part of a single line. The format for these subroutines is:
Define subroutine_name [code] EndDefine

The keywords Define and EndDefine are used to create the subroutine. To call the subroutine then, 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 ex_PeckCancel ex_TapCancel ex_BoreCancel : $cannedcancel : $cannedcancel : $cannedcancel : $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 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 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.

9.

Examples section
a. Introduction

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, and 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 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 NC file. This is done by using \\ line continuation in .asc:
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.

b. 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. Check Long; this way, when you post, the long NC code will be displayed.

Long NC code shows the "ex_..." keywords from the .ASC File before the line(s) of NC code that keyword produced. You can this way see the posting flow order. Sample:
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) 584 Soft EX_BOREBODY(DrillWrap) 585 Soft EX_BOREBODY(DrillWrap) 586 Soft EX_BOREBODY(DrillWrap) 587 Soft EX_BORECANCEL(DrillWrap) 588 Hard EX_CYCLEEND(DrillWrap) 589 Hard EX_TOOLCANCEL

G89 X34.4 R0.0 F150.0 C-90.0 C0.0 C90.0 G80 M09 G30 U0 G30 V0 W0 M05 M69 M46

c. 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. ex_CycleStart is a Hard example, and it always appears at the start of an operation, unless it is a drilling type operation and ex_PTOPCycleStart is defined in the post .ASC file. If ex_PTOPCycleStart is defined in the post .ASC file, then it will be used for the start of drilling type operations instead of ex_CycleStart. 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.

10.

General topics
a. Overwriting 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 userdefined 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 YAbsolute MiscFormat1 MiscFormat2 : X : Y : X_ : Y_ N 4 Y N 4 N 4 Y N 4 N 4 Y N 4 N 4 Y N 4 N 5 Y N 3 N 5 Y N 3 N 5 Y N 3 N 5 Y N 3 1 1 1 1 1 N 0 0 1 N 0 0 1 N 0 0 1 N 0 0

MotionRapid

: G00

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.

b. 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 Variable : Test ex_Rapid : Debug*(Test) : Debug N 4 Y N 4 N 5 Y N 3 7 1 N 0 6

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

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

d. Mathematical operators and functions The following mathematical operators can be used in the post processor (These are 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 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 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 is a function that returns the arcsine value. ASN is the angle (in degrees) that has a sine value equal to the given argument.

ABS

ACS

ASN

ATN COS

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 is a function that returns the cosine of a given angle. The angle value is given in degrees. 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 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 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. SIN is a function that returns the sine of a given angle. The angle value is given in degrees. SQR is a function that returns the square of a value (that value to the power of 2). SQR(x) equals x^2. SQRT is a function that returns the square root of a given value. TAN is a function that returns the tangent of a given angle. The angle value is given in degrees.

EXP

INT

LN

SIN SQR SQR T TAN 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)).

e. Some of the special keywords If Else Endif / If ElseIf Endif: 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 separates and branches the NC code output depending on a test condition. EndIf is a special keyword that closes an If conditional branch. While EndWhile: While is a special keyword that starts a loop. The loop will continue to execute as long as a given test condition is true. EndWhile is a special keyword that closes a While loop.

Você também pode gostar