100BBasic instructions
7.4 Compare
S7-1200 Programmable controller
System Manual, 11/2011, A5E02486680-05
185
7.4.3
OK and Not OK instructions
Table 7- 32 OK and Not OK instructions
LAD
FBD
SCL
Description
Not available
Not available
Tests whether an input data reference is a valid real
number according to IEEE specification 754.
For SCL, OK allows you to check the errors in the
execution of a statement. OK is a predefined local tag that
stores a Bool value. You can use the NOT keyword in
conjunction with OK to evaluate the operation.
1
For LAD and FBD: When the LAD contact is TRUE, the contact is activated and passes power flow. When the FBD box
is TRUE, then the box output is TRUE.
Table 7- 33 Data types for the parameter
Parameter
Data type
Description
IN
Real, LReal
Input data
Table 7- 34 Operation
Instruction
The Real number test is TRUE if:
OK
The input value is a valid real number
1
NOT_OK
The input value is not a valid real number
1
1
A Real or LReal value is invalid if it is +/- INF (infinity), NaN (Not a Number), or if it is a denormalized value. A
denormalized value is a number very close to zero. The CPU substitutes a zero for a denormalized value in calculations.
When the CPU starts to execute an SCL code block, the CPU sets OK to TRUE. An error
that occurs during the execution of an operation (for example, division by zero) sets OK to
FALSE. During the execution of the SCL code, statements can query the OK parameter or
can set OK to either TRUE or FALSE.
Table 7- 35 Using OK for checking the operation of an operation
SCL Comment
OK := TRUE;
// Set OK to TRUE
Division:= 1 / "IN";
// Division operation
IF OK THEN
// Check for valid operation (such
as IN <>0).
...
// Statements for valid operation.
ELSE
// Invalid operation (such as IN =
0).
...
// Statements handling invalid
operation
END_IF;