6-115
6 Programming
NJ-series CPU Unit Software User’s Manual (W501)
6-6 Instructions
6
6-6-3 Instruction Errors
Instruction errors refer to the errors that occur when an instruction is executed. This section describes
when an instruction error occurs, which error is detected as an instruction error, and what operation fol-
low an instruction error, etc.
The timing when instruction errors occur can be divided into the following three cases. Detectable
errors and operations following to the errors differ by the timing when instruction errors occur.
• When the values of input parameters or in-out parameters are checked before instruction execution.
• When internal processing is performed during instruction execution.
• When the values of output parameters are checked after instruction execution.
The followings are the errors detected as instruction errors. Different errors are detected depending on
the timing when instruction errors occur.
Errors detected before or after instruction execution
The followings are the errors detected before or after instruction execution.
• Reading or writing an array variable from or to an element beyond the array range.
• Assigning a string that is longer than the defined byte length to a STRING variable.
• Assigning a string that does not end with a NULL character to a STRING variable.
• Dividing an integer variable by 0.
Errors detected during instruction execution
Errors detected during instruction execution differ by instruction. For details on errors detected in
each instruction, refer to the NJ-series Instructions Reference Manual (Cat. No. W502).
The operation for the following elements differ depending on whether an instruction error occurs or not:
output variable ENO, output variable Error, output variable ErrorID, system-defined variable P_PRGER,
and events. The details on the operations are described below.
Output variable ENO, output variable Error, and output variable ErrorID
ENO (enable out), Error, and ErrorID (error code) are the output variables that indicate whether an
error exists or not. Each instruction has different output variables. The meaning of each variable and
its value on an instruction error are shown below. The values vary by the timing when an instruction
error occurs.
6-6-3 Instruction Errors
Timing When Instruction Errors Occur
Errors Detected As Instruction Errors
Operation for Instruction Errors
Output
variable
Data
type
Meaning
Value when an instruction error occurs
Before
instruction
execution
*1
During
instruction
execution
After
instruction
execution
*2
ENO BOOL TRUE : Normal end FALSE FALSE TRUE
FALSE : Error end, Execution in prog-
ress, or Not executed
Error BOOL TRUE : Error End FALSE TRUE FALSE
FALSE : Normal end, Execution in
progress, or Not executed