Вы находитесь на странице: 1из 10

Volume 1 Chapter 4 Post Debugging Techniques

4 Post Debugging Techniques

Pre-defined post debugging switches


The post processor contains several pre-defined switch variables that can be used to display a listing of the
NC code and/or append useful information to the NC output file. The variable bug1 provides the option of
listing the NC file after post processing. The variables bug2, bug3 and bug4 will help you debug the post
processor by adding extra information into the NC output file. This output is essential for tracing the code
execution if debugging the post becomes necessary.
bug1 : 2 # 0=No display, 1=Generic list box, 2=Editor
bug2 : 30 # Append postline labels (column position)
bug3 : 0 # Append whatline no. to each NC line?
bug4 : 1 # Append NCI line no. to each NC line?

Note: You must set the fastmode variable to no or 0 to enable these debug switches. Also note that
when fastmode is set to 1, the post processor displays no progress-indicator dots on the monitor to let
you know the program is still running. Make sure to give the post sufficient time to complete processing
before assuming there is a fault in the post.
fastmode : 0 # Posting speed optimization (set to 0 for debug)

You can leave bug1, bug2, bug3, bug4 set according to your preferences and toggle all debugging off or
on by setting the fastmode switch to 0 or 1, respectively.

The bug1 variable


The variable bug1 can be used to control the option to display the NC program after posting. If bug1 is set
to 1, a program listing will be displayed in a generic scrollable window. A setting of 2 lists the program in
the default text editor as specified in Mastercam’s configuration. Setting bug1 to 0 turns this function off.
Note: When posting through the Operations Manager in Mastercam, the edit checkbox in the post
processor dialog (shown below) will override this variable.

June 2002 Mastercam Version 9 MP Post Processor Reference Guide 4-1


Chapter 4 Post Debugging Techniques Volume 1

The following shows an example of bug1 set to 1, displayed in a Mastercam File List window:

The bug2 variable


The bug2 variable is one of the most useful tools for debugging a post. When this variable is set to a
positive value, it can be used to append postblock labels to the NC file. When set to a positive value,
this variable appends the label of the first postblock called and, if additional postblocks are called,
displays the last postblock called to each NC output line. The appended information starts in the
column after the value specified.

If bug2 is set to a negative value, it will display all the postblock labels that have been called in the post
even if output did not occur as a result of executing the instructions in that postblock. Setting this
variable to 0 will omit the postblock label.

4-2 Mastercam Version 9 MP Post Processor Reference Guide June 2002


Volume 1 Chapter 4 Post Debugging Techniques

The following shows output for bug2 set to 30, which displays, starting after column 30, the first and
last postblocks called:

The following shows the expanded output with bug2 set to –30, which displays all postblocks called,
also starting after column 30:

June 2002 Mastercam Version 9 MP Post Processor Reference Guide 4-3


Chapter 4 Post Debugging Techniques Volume 1

Bracketed postblocks are identified in debugging by the post line number of the occurrence of the open
bracket (starting at zero).

In the following example, notice the postline label appended to the output line is p__1:250.
N10 G01 X1.0 Y2.0 Z3.0 p__1:250

In this example, p__1 indicates the second occurrence of the open bracket ( [ ) and that the bracket was
located on post line number 250.

The bug3 variable


The bug3 variable is rarely used. Setting bug3 to 1 adds the value of the variable whatline to the end of
each line of NC code displayed on the screen. The use of the variable whatline is no longer
recommended. The pre-defined variable whatno can be set to yes to ignore the whatline branching
structure in the post.
Note: It is strongly recommended that the variable whatno be set to 1 to ignore the whatline branching
feature.
See Volume 3, Numeric Variables for more information

The bug4 variable


Like bug2, the bug4 variable is extremely useful for debugging a post. Setting this variable to 1 adds
the current NCI file line number to the end of each line of NC code displayed on the screen (0 = no, 1 =
yes). You can then open the NCI file to verify the NCI line responsible for the output.
Note: The NCI line number is the actual physical row number that the NCI line is located on in the
editor.
When set to a negative value, bug4 alters the forced output of variables prefixed with the tilde character
(~). The variable is output with the variable name and unformatted. This allows the post writer to see
the value as it is stored in memory (the precision is not altered).

Error messages in MP
When an error is detected in the .PST file, a warning is posted on the screen in the form of:

Message 1 Error message...


Message 2 Postline number...and/or postblock label...
Press Enter

Message 3 Program execution halted due to error(s) in .pst


Press Enter

The first message indicates what kind of error has been encountered. The second message tells you
where to look in order to fix it and describes this location by providing:

4-4 Mastercam Version 9 MP Post Processor Reference Guide June 2002


Volume 1 Chapter 4 Post Debugging Techniques

♦ the exact line number where the error occurred


♦ the postline label
♦ line number and the postline label
Note: The “line number” referenced by the error message is the number of the line in the post file
where the error occurred. Some text editors display the line number, or can be configured to display
these numbers.
The third message tells you that post execution has been halted if a fatal error has occurred.

Common error messages


This section lists common error messages, describes their causes, and suggests a response.

Two arguments (comma) expected.


postline number...

This error most commonly occurs when a function requiring two arguments is passed a single
argument.
Open the post file for editing and go to the postline number listed in the error message. See
Post Functions for more information on the correct syntax for the function in question.

Close parenthesis expected for single argument function.


postline number...

This error can occur when you provide more than one argument to a single argument function

Open the post file for editing and go to the postline number listed in the error message. See
Post Functions for more information on the correct syntax for the function in question.

Cannot write record 0. in buffer..., records start at number 1.


Postblock label...

This error usually occurs when you initialize a "write counter" variable to zero.

To correct this problem, locate the write counter in the initialization list and change it from
an initial value of zero to one.

wc1 : 1

Cannot read record... in buffer...buffer is too small.


Postblock label...

June 2002 Mastercam Version 9 MP Post Processor Reference Guide 4-5


Chapter 4 Post Debugging Techniques Volume 1

This error typically occurs when you attempt to read beyond the last record in a buffer file.

To correct this problem, consider checking the size of the buffer by reading record 0, and
testing the value of your "read counter" before attempting to read from the buffer. For
example:

size1 = rbuf(1, 0)
if rc1 <= size1, preadbuf1

Variable not defined: ...


Postline number...

This message indicates that the variable has not been declared in the post. This error can also occur if a
variable name is misspelled.

To declare a user defined variable in the post, it must be formatted or initialized.

Divide by zero error: -1.0E-8 < divisor < 1.0E-8"


Postblock label...

This message indicates that a division by zero was attempted and a math error generated, probably by a
postblock formula. It is not legal to divide by zero.

Check whether the formula contains a variable that is used in the divisor. If so, make sure
that the variable has been read in and is not 0.

The following example shows a while loop with a user-defined question inserted to ensure that the user
enters a non-zero number.
fq 1 tpi Enter Number of Threads Per Inch...

ptap # Rigid Tap Cycle


while tpi = 0, q1
frplunge = ss / tpi
...

Unknown g code: ...


Postblock label...

This error message indicates that the Gcode read from the NCI file is not recognized by the post
executable.

The NCI file may be corrupt or the wrong MP executable may have been specified in
question 91.

4-6 Mastercam Version 9 MP Post Processor Reference Guide June 2002


Volume 1 Chapter 4 Post Debugging Techniques

Variable prv_ ... not defined.


Postline number...

Typically this error occurs when you attempt to force out the previous value of a variable using the ‘*’
or ‘~’ symbols.
*prv_ccomp

Postblock cannot be forced with '*' or '!'.


postline number…

Postblock calls can be controlled with Boolean tests, but are not considered to be modal or non-modal.
The symbols ‘*’ or ‘!’ are only to be used on variables and strings

Go to the line number indicated. Look for a postblock call prefixed with ‘*’ or ‘!’ and
remove that symbol.

Selector variable gcode = ...


out of range for string select.
postblock label…

This error message is given when the post attempts to access a string select table that contains less
elements than the value of the selector variable.
First try to find out what string select table(s) use the variable gcode as the selector variable.
Next, try to locate the target string in the postblock label listed. Finally, use one of the
three methods below to fix the problem:
1. Change the value of the selector variable prior to accessing the table.
gcode = 0
*sgcode

2. Consider using one of the strings defined in the table directly.


*sg00

3. Use a literal string.


"G00"

Subprogram cannot be merged with itself.


Postblock Label...

This error can occur when using the mergesub, mergeaux, and mergeext commands.

June 2002 Mastercam Version 9 MP Post Processor Reference Guide 4-7


Chapter 4 Post Debugging Techniques Volume 1

When using mergesub, the variable subout must be set to a value other than 1. When using
mergeaux, the variable subout must be set to a value other than 2, and subout must be set to a
value other than 3 when using mergeext.
♦ subout = 1 output is directed to the sub file, therefore mergesub is not legal
♦ subout = 2 output is directed to the aux file, therefore mergeaux is not legal
♦ subout = 3 output is directed to the ext file, therefore mergeext is not legal
♦ subout = 0 output is directed to the NC file

Variable [Variable Name] is the result of global formula and


cannot be used as a result of a postline formula.
Postline Number...

This error only occurs when newglobal is set to 1, and a global variable is the result of a postline
formula, on left side of the equation.

Either eliminate the global formula and initialize the variable, placing the formula in
postlines.
speed = abs(ss) #global formula

Note: Use ss as your postline formula result, not speed.

Using the tilde (~) modifier to force variable output


When debugging a post processor, it is often necessary to output a variable to test its value in a
postblock. When outputting a variable in the normal manner or forcing it to be output using the
asterisk character (*), several things happen:
♦ If the variable you are outputting is associated with a global formula, the variable will be
automatically updated prior to output.
♦ The variable will be rounded.
♦ The previous value will be updated.
The tilde character (~) can be used to force output without solving global formulas, rounding, or
updating previous value. This allows the post writer to force output of a variable without disturbing
modality

Bug4, when set to a negative value, alters the forced output of variables prefixed with the tilde character
(~). The variable is output with the variable name and is unformatted. This allows the post writer to
see the value as it is stored in memory. (The precision is not altered.)

4-8 Mastercam Version 9 MP Post Processor Reference Guide June 2002


Volume 1 Chapter 4 Post Debugging Techniques

Subprograms and Lathe canned cycle output


With the addition of subprograms and Lathe canned turning cycles in Mastercam Version 8, it became
necessary to stop the NC output to produce the correct machine code. Mastercam continues to produce
the tool motion in the NCI for backplot and verify, and the post executable stops the NC output when
the data is redundant. Using the debugging switches overrides the default behavior of the post
executable and forces the output of all NCI data to the NC output file.
See Volume 2, How Subprograms Work for more information on subprograms.

Debugging posts with buffer files


When working with more complex posts, it is often necessary to use buffers to store and retrieve data.
Buffers can be saved as text for debugging by activating the second parameter in the fbuf function.
fbuf 1 1 9 0 # Declare buffer one (9 Reals, Save text)

In the code example above, the second parameter in the fbuf function is set to 1. This tells the post
executable to write the buffer to disk as an ASCII text file using the file name specified by the pre-
defined string sbufname1. The resulting file can be opened in a text editor to examine the records.
See Volume 2, How Buffer Files Work for detailed information on using buffers.

Notes on no_updprv and nc_lout


The variables no_updprv and nc_lout allow control on the updating of the previous (prv_) variable by
testing a prv_ value while the output line is being generated and preventing MP from writing over the
value until after the line is output. 25 variables can be collected internally for the update. These
include:
♦ grave accent (`) variables
♦ variables associated with string selects
♦ undressed variables (variables without a prefix)
♦ forced (*) output variables

no_updprv set to 1 automatically updates the previous variables when the line is output.

no_updprv set to 2 does not perform any previous update on the variables and the post must update the
variables with the exclamation update (!).

To help determine if output occurred, the variable nc_lout is set to the current internal call level
immediately after the output postline. If no output was generated, nc_lout is set to -1.
Note: The post must test the postline immediately after the output postline.
nc_lout is reset to -1 after the postline is output and the output string is empty. no_updprv also prevents
MP from updating x, xr, xh with themselves.
Note: Bug statements (bug2, bug3 and bug4) disrupt this function.

June 2002 Mastercam Version 9 MP Post Processor Reference Guide 4-9


Chapter 4 Post Debugging Techniques Volume 1

4-10 Mastercam Version 9 MP Post Processor Reference Guide June 2002

Вам также может понравиться