User`s manual
Local Logic Language Syntax
GFK-1742A Chapter 12 Local Logic Language Syntax 12-17
12
Local Logic Runtime Errors
Overflow Status
Some arithmetic operations may have results that cannot be correctly represented as a signed 32-bit
value. An example is shown in the following code segment.
P001 := 16#7FFF_FFFF; // (1) P001 2,147,483,647 (maximum positive 32 bit value)
P003 := P001 + 1; // (2) ! Overflow !
In the first line, P001 is loaded with 2,147,483,647, the largest value that can be represented as a 32
bit signed two’s-complement value. In the second line, one is added to that value. The total,
represented in hexadecimal, is 16#8000_0000. This value, interpreted as a 32-bit signed two’s
complement number represents the negative value –2,147,483,648, not the positive value
2,147,483,648! In many situations, this result would be unexpected and have undesirable effects in
subsequent program statements.
Three variables are available to the Local Logic program to detect overflows. The Overflow
variable is a read-write Boolean variable available only to the local logic program (refer to Chapter
13, Section on “Local Logic System Variables”). When an overflow error occurs, and the
Overflow variable is not cleared before the end of the Local Logic sweep, the DSM’s Module
Status Code %AI word (local logic variable Module_Status_Code) is set. The error code indicates
the type of overflow and the Module Error Present %I bit (local logic variable
Module_Error_Present) is set. The Module Status Code %AI word and the Module Error Present
%I bit are not set until the current Local Logic sweep has finished executing. In contrast, the
Overflow variable is set immediately following an instruction which causes an overflow. The Local
Logic program may clear the Overflow variable by assigning it a value of zero. The Module Status
Code must be cleared by the PLC by setting the module’s Clear Error %Q bit.
Overflow and computation errors are Status Only errors with two exceptions. A divide by zero or
divide overflow (the quotient cannot be represented in 32 bits) are Stop Fast errors. In the case of
status only errors, Local Logic processing and path generation continue normally. A stop fast error
will cause Local Logic processing to be aborted before proceeding to the next instruction, and any
motion will be aborted by setting the servo velocity command to zero. Note: Clearing the
Overflow variable will have no effect on Stop Fast errors.
Refer to Table 12-10 for a listing of all Runtime Local Logic error codes.
Divide By Zero
The Logic Engine flags Divide By Zero operations as a Fast Stop Error, since the result of the
operation is undefined. Local Logic execution and servo motion is halted. An error code 16#2093
is reported in the module status code and 16#2x9A in the Per-Axis error codes if the drives were
enabled.