Sebol Training Manual PDF
Sebol Training Manual PDF
Manual
SEBOL
Function Manual
Release : R2
IM 33G3C20-11E
IM 33G3C20-11E
6th Edition
Yokogawa Electric Corporation
◆ Preface
This manual describes the operation and syntax of the sequence programming language
SEBOL (SEquence and Batch Oriented Language).
SEBOL is used for the process control at the field control station (FCS) of the
CENTUM CS system. It has functions specially designed for the purpose in addition to
those available with high-level programming languages, such as FORTRAN, C, and
BASIC.
■ Manual Configuration
This manual is composed of 16 chapters and four appenddixes as follows:
Chapter 1 is an introduction.
Chapters 2 to 6 describe the syntax and other protocols the language requires, such as
program units, data types, operands, variables, and functions.
Chapter 7 describes details of function block data, or process data that SEBOL can
manage.
Chapters 8 and 9 describe the use of program control and message statements.
Chapter 10 describes error processing.
Chapter 11 describes the use of variables and expressions.
Chapter 12 and 13 describe the management of the CPU and shared resources.
Chapter 14 describes the functions of subsystem communication supported by SEBOL.
Chapter 15 describes the manipulation of signals.
Appendixes list error codes, variable declarations, maximum values, and reserved words.
■ Applicable Readers
This manual has been written for those who have general knowledge of instrumentation,
process control systems, ICS, FCS, SEBOL and SFC block functions for use in the
engineering of the CENTUM CS system.
NOTE
The SEBOL explained in this manual is not the same as the SEBOL used with the
CENTUM XL Batch and their programs are not interchangeable.
■ Trademarks
• “UNIX” is a registered trademark in the United States and other countries and
licensed exclusively through X/Open Company Limited.
• “Motif” and “OSF/Motif” are trademarks of Open Software Foundation, Inc.
• “X-Window” and “X Window System” are trademarks of the Massachusetts
Institute of Technology.
• “Ethernet” is a registered trademark of XEROX Corporation.
• “HP” and “HP9000” are registered trademark of Hewlett Packard Company.
• “IBM” is a registered trademark of International Business Machine Corporation.
• “SUN” is a registered trademark of Sun Microsystems, Inc.
• Other brand and product names are registered trademarks of their respective holders.
FD No. IM 33G3C20-11E-CS
6th Edition: Apr. 2000 (YG)
All Rights Reserved, Copyright © 1995, Yokogawa Electric Corporation
IM 33G3C20-11E i
◆ Document Map
■ System Concept and Design Manuals
System
Overview (TI)
Builder Operation
ICS Builder FCS Builder
Manuals of Other
Operation Manual Operation Manual
Units and Functions
Graphic Builder
Operation Manual
Self
Test Function Documentation
Manual Manual
■ Installation and
Installation
Maintenance Manuals Guidance (TI)
■ Operation Manuals
Communication and
ICS Operation ICS Hardware FCS Hardware Network Device
Manual Manual Manual Hardware Manual
■ Recommended Readings
• IM 33G2C20-11E SIH1100 ICS Operation and Monitoring Function Manual
• IM 33G3C10-11E FCS Control Station Function Manual
• IM 33G3C21-11E CS Batch SEBOL-Block Function Manual
• IM 33G3C31-11E CS Batch SFC-Block Function Manual
ii IM 33G3C20-11E
◆ Notice
■ Regarding This Manual
1. This manual should be passed on to the end user.
2. Read this manual carefully and fully understand how to operate this product before
you start operation.
3. Yokogawa makes no warranty of any kind with regard to this manual, including,
but not limited to, implied warranties of merchantability and fitness for a particu-
lar purpose.
4. All rights reserved. No part of this manual may be reproduced in any form
without Yokogawa’s written permission.
5. The contents of this manual are subject to change without prior notice.
6. If any question arises or errors are found, or if there is any information missing
from this manual, please inform Yokogawa’s documentation department respon-
sible for this manual or the nearest Yokogawa sales office, or use the form in the
back of this manual to inform us accordingly.
■ Regarding Protection, Safety, and Prohibition Against Unauthorized Modification
1. For the protection and safe use of the product and the system controlled by it, be
sure to follow the instructions on safety described in this manual when handling
the product. In addition, if you handle the product in contradiction to these
instructions, our company does not guarantee safety.
2. The following safety symbol marks are used on the product concerned and in this
Manual :
Les symboles suivants touchant à la sécurité sont utilisés sur le produit concerné et
dans ce manuel.
CAUTION
This marking on the product indicates that the operator must refer to an
explanation in the instruction manual in order to avoid injury or death of
personnel or damage to the instrument. The manual describes that the operator
should exercise special care to avoid electric shock or other dangers that may
result in injury or the loss of life.
ATTENTION
Ce symbole marqué sur le produit indique que l’opérateur doit se reporter au
manuel d’instruction pour éviter tout accident corporel ou tout dégât matériel.
Le manuel d’instruction indique que l’opérateur doit faire particulièrement
attention pour éviter tout choc électrique ou autre accident pouvant entrainer un
accident ou la mort.
IM 33G3C20-11E iii
CAUTION
A CAUTION sign denotes a hazard. It calls attention to a procedure, practice,
condition or the like, which, if not correctly performed or adhered to, could
result in damage to or destruction of part or all of the product.
CAUTION
Le symbole CAUTION annonce un risque Il désigne une procédure, une
marche à suivre ou autre qui, n’étant pas correctement observée, peut entainer
un dommage ou une destruction partielle ou totale du produit.
iv IM 33G3C20-11E
The symbolic conventions below are used only in the manual.
Les conventions suivantes sont utilisées uniquement dans le manuel d’instruction.
IMPORTANT
Indicates that operating the hardware or software in this manner may damage it
or lead to system failure.
IMPORTANT
Indique que manipuler le matériel ou le logiciel de cette manière peut
l’endommager ou provoquer l’arrêt du système.
NOTE
Draws attention to information essential for understanding the operation and
features.
NOTE
Attire l’attention sur une information essentielle pour la comprehension des
opérations à effectuer ou des caractéristiques.
3. If protection / safety circuits are to be used for the product or the system con-
trolled by it, they should be installed outside of the product.
4. When you replace parts or consumables of the product, use those specified by our
company.
5. Do not modify the product.
IM 33G3C20-11E v
◆ Note
■ Appearance and Accessories
After you received this product, check the following:
• Appearance
• Standard accessories
If coating falls off, a product is broken, or accessories are missing, contact our
representative from which you purchased this product or our sales department.
If the label on the power distribution board is filthy or falls off, order a label (part
number: T9029BX).
vi IM 33G3C20-11E
◆ Documentation Conventions
Throughout this manual, the following conventions of notation clarify the input device
(keyboard, touch panel, or mouse) used.
• Characters or symbols enclosed in denote keys on the ICS operation key-
board.
Example:To change to the next page, press the key.
• An underline boldface font denotes the format of the data you enter on a panel.
Example:The cursor appears, prompting input.
FIC100.SV=50.0
TIP
Gives information that complements the present topic.
See Also
Gives the reference locations for further information on the topic.
■ Figures of Simulated
• The figures that appear in this manual of simulated may sometimes be emphasized
or simplified, or may fail to show the entire image for reasons of convenience in
explaining them.
• The display position or character (large/small letter, etc.) of the CRT chart shown in
this manual might be different from that of actual CRT display within the range not
to give obstacles of the function understanding and operation monitoring.
IM 33G3C20-11E vii
Blank Page
Contents
◆ Preface ...................................................................................................................... i
◆ Document Map ........................................................................................................ ii
◆ Notice ........................................................................................................................ iii
◆ Note ........................................................................................................................... vi
◆ Documentation Conventions .................................................................................. vii
1. Overview
1.1 Introduction .............................................................................................. 1-1
2. Program Units
2.1 Types of Program Units ........................................................................... 2-1
2.2 Defining the SFC Block ........................................................................... 2-2
2.3 Defining the SEBOL Block ..................................................................... 2-2
2.3.1 Ending the SEBOL Block Program ................................................. 2-2
2.4 Defining the Function Subprogram ......................................................... 2-3
2.4.1 Ending the Function Program .......................................................... 2-3
IM 33G3C20-11E ix
5. Variables
5.1 Local Variables ........................................................................................ 5-1
5.2 Function-Block Data ................................................................................ 5-3
5.2.1 Declaring Tag Names ....................................................................... 5-4
5.2.2 Assigning Tag Names ...................................................................... 5-5
5.2.3 Block Type Names and Model Designations .................................. 5-7
6. Functions
6.1 Defining Functions ................................................................................... 6-1
6.2 Calling Functions ..................................................................................... 6-3
6.3 Function Arguments ................................................................................. 6-4
6.3.1 Verifying Argument Types .............................................................. 6-6
6.3.2 Function Types ................................................................................. 6-7
6.4 Declaring Function Block Formal Arguments ........................................ 6-8
6.4.1 Referencing Function Block Data .................................................... 6-10
6.4.2 “assign” Statement ............................................................................ 6-11
6.5 Variables Used with Functions ................................................................ 6-12
6.5.1 Local Variables ................................................................................. 6-12
6.5.2 Tag Names ........................................................................................ 6-12
6.5.3 Local Generic Names ....................................................................... 6-12
6.5.4 Unit Generic Names ......................................................................... 6-13
6.6 Built-in Functions ..................................................................................... 6-14
6.6.1 Arithmetic Functions ........................................................................ 6-16
6.6.2 Bit Operation Functions ................................................................... 6-17
6.6.3 High-Low Limit Functions ............................................................... 6-18
6.6.4 Trigonometric Functions .................................................................. 6-19
6.6.5 Square-Root Function ....................................................................... 6-19
6.6.6 Exponentiation Function .................................................................. 6-19
6.6.7 Natural Logarithm Function ............................................................. 6-19
6.6.8 Character-String Functions ............................................................... 6-20
6.6.9 Date and Time Functions ................................................................. 6-21
6.6.10 Function Block Data Function ......................................................... 6-21
6.6.11 Error Functions ................................................................................. 6-22
6.6.12 Signal Function ................................................................................. 6-23
6.6.13 Process Management ........................................................................ 6-23
6.6.14 Other Functions ................................................................................ 6-24
x IM 33G3C20-11E
7.4 Data Status ............................................................................................... 7-27
7.4.1 Checking Data Status ....................................................................... 7-28
7.4.2 Changing Data Status ....................................................................... 7-31
7.5 Alarm Status ............................................................................................. 7-32
7.5.1 Referencing Alarm Status ................................................................ 7-32
7.5.2 Data Items AF, AOFS, AFLS .......................................................... 7-33
7.5.3 Referencing Alarm Statuses Individually ........................................ 7-37
7.6 Sequence-Table Block ............................................................................. 7-40
7.6.1 One-Shot Execution and Check ....................................................... 7-41
7.6.2 Periodic Start with One-Shot Execution .......................................... 7-42
7.6.3 Periodic Start without One-Shot Execution ..................................... 7-44
7.7 Logic-Chart Block .................................................................................... 7-45
7.7.1 One-Shot Execution .......................................................................... 7-45
7.7.2 Periodic Start with One-Shot Execution .......................................... 7-46
7.7.3 Periodic Start without One-short Execution .................................... 7-47
7.8 Process I/O and Software I/O .................................................................. 7-48
7.8.1 Process I/O Terminal Numbers ........................................................ 7-48
7.8.2 Software I/O Element Numbers ....................................................... 7-50
7.8.3 CP213 Communication Element Numbers ..................................... 7-51
7.8.4 Declaration ........................................................................................ 7-52
7.8.5 Group 16-Bit I/O .............................................................................. 7-53
7.9 Timer Block ............................................................................................. 7-56
7.10 “oneshot” Statement ................................................................................. 7-57
9. Message Statements
9.1 “opeguide” Statement ............................................................................... 9-3
9.2 “dialogue” Statement ............................................................................... 9-4
9.3 “message” Statement ................................................................................ 9-7
9.4 “history” Statement .................................................................................. 9-8
9.5 “request” Statement .................................................................................. 9-9
9.6 “sysalarm” Statement ............................................................................... 9-10
9.7 “prcsalarm” Statement ............................................................................. 9-11
9.8 Formatting String ..................................................................................... 9-16
9.8.1 “format” Statement ........................................................................... 9-18
9.9 Message Restrictions ................................................................................ 9-19
IM 33G3C20-11E xi
10. Error Processing
10.1 Individual Statement Error-Processing Description ................................ 10-1
10.1.1 Error Variable ................................................................................... 10-2
10.1.2 Branching Destination ...................................................................... 10-4
10.1.3 Group Statements and Error Processing .......................................... 10-5
10.2 Common Error-Processing Definition ..................................................... 10-6
10.3 Classified Error Codes ............................................................................. 10-9
10.4 Substitution of Values .............................................................................. 10-10
10.5 Conditional Expression Errors ................................................................. 10-12
10.6 Sequence Table/Logic Chart Errors ......................................................... 10-13
10.7 Transition-Condition Errors ..................................................................... 10-13
xii IM 33G3C20-11E
Appendixes
Appendix 1 Error Codes ................................................................................... A1-1
App. 1.1 Classified Error Codes .................................................................. A1-1
App. 1.2 Detailed Error Codes ..................................................................... A1-10
Appendix 2 Variable Declarations .................................................................... A2-1
Appendix 3 Maximum Values .......................................................................... A3-1
Appendix 4 Reserved Words ............................................................................ A4-1
Appendix 5 Application Size ............................................................................ A5-1
Appendix 6 Differences from XL-BATCH ...................................................... A6-1
Appendix 7 System-Fixed Include Files .......................................................... A7-1
IM 33G3C20-11E xiii
1. Overview
1. Overview
An outline of SEBOL is given in this chapter.
1.1 Introduction
SEBOL, which is an acronym for the SEquence and Batch Oriented Language, is a
programming language designed for use in the control of processes. It has a number of
specific functions designed for the purpose in addition to those basically similar to
FORTRAN, C, and BASIC.
Programs written in SEBOL are used as SEBOL and SFC (sequential function chart)
blocks and run on the CENTUM CS system FCS (field control station).
This manual explains the syntax and other elements of the language using examples.
NOTE
The SEBOL explained in this manual is not the same as the SEBOL used with the
CENTUM XL Batch and their programs are not interchangeable.
IM 33G3C20-11E 1-1
2. Program Units
2. Program Units
This chapter describes SEBOL program units.
SEBOL block
Subprogram Function
• The SFC block is a main program that is graphically generated by using an engineer-
ing function builder.
• The SEBOL block is a main program that is created by using a text editor, similar to
C and BASIC.
• Both SFC and SEBOL blocks run as function blocks on the FCS and can be con-
trolled from another function block or the operation-and-monitoring function.
• The “function” subprogram contains an argument and the result of an operation for an
exchange of data with a calling function. It can be called from the SFC or SEBOL
block or a function.
NOTE: The SFC block and the SEBOL block are noted as “SFC/SEBOL block”
when both blocks are referred to in this manual.
IM 33G3C20-11E 2-1
2.2 Defining the SFC Block
The SFC block builder is used to define an SFC block. For details, see the Builder
Operation Manual (IM33G4L20-11E).
Executable statement
end
<program ending code>: Use a numeric expression with value ranging from -32768 to 32767.
2-2 IM 33G3C20-11E
2. Program Units
Executable statement
end
IM 33G3C20-11E 2-3
3. Syntax and Other Protocols
3.1 Identifiers
An identifier is a sequence of alphanumeric characters, percent signs (%), underscores
(_), and dollar signs ($). It must begin with an alphabetic letter or a percent sign. It can
be of any length but only the first eight characters are significant except a tag name, in
which case up to 16 characters are significant. Uppercase and lowercase letters are not
distinguished.
(2) Comment
A comment can be inserted in the program marking the start of the line by an asterisk
(*). Also it can be written anywhere in the line delimiting it by an exclamation mark (!)
— the text between the exclamation mark and the return code is translated as a com-
ment.
(3) Label
A position-identifying label, or an identifier, can be attached to a statement as shown in
Figure 3.1. If there is no statement on the right side, the label will be attached to the
subsequent statement.
<identifier> : <statement>
IM 33G3C20-11E 3-1
3.3 Data Types
Data types and their ranges of data values SEBOL can manage are shown in Table 3.1:
Data Type Type Specifier No. of Bits Min. Value Max. Value
Character string char*n 8*n — —
Integer integer 16 -32768 32767
Double-length integer long 32 -2147483648 2147483647
Single-precision floating point float 32 -3.402823*10ˆ38 3.402823*10ˆ38
Double-precision floating point double 64 -1.79769313486231*10ˆ308 1.79769313486231*10ˆ308
In this manual, integer and long-integer data types are referred to as the integer type,
single- and double-precision floating-point data types as the real-number type, and these
four data types as the numeric type.
The number of significant digits is seven for single-precision floating-point data and 15
for double-precision floating-point data. Up to 255 bytes can be used for character-
string data (“n” in “char*n” must be less than 255).
The configuration of each data type is shown in Figure 3.2. The mantissa fields of
integer and real-number data are twos complements.
15-bit integer
31-bit integer
3-2 IM 33G3C20-11E
3. Syntax and Other Protocols
3.4 Constants
(1) Integer Constants
A decimal integer constant is long-type data and contains an array of digits 0 through 9.
A hexadecimal integer constant begins with a dollar sign ($) and can contain alphabetic
letters A through F in both uppercase and lowercase in addition to numerals.
EXAMPLES: Decimal integer constants: 10, 100, 123
Hexadecimal integer constants: $10, $FFFF, $ABCD
IM 33G3C20-11E 3-3
The return code following a backslash used in a character-string constant is ignored.
Thus the two snapshot statements in the example shown in Figure 3.3 will be output as
one continuous statement. (The snapshot statement is described in Chapter 9.)
sebolblock example
end
3-4 IM 33G3C20-11E
3. Syntax and Other Protocols
3.5 Variables
Variables are classified according to data types as shown in Figure 3.4.
There are two kinds of variables selectively used according to varied purposes and
ranges as shown in Figure 3.5.
Local variables
Variables
They are further classified according to the number of elements contained as shown in
Figure 3.6 — the two dimensional array is not applicable to the function block data.
Simple variables
Variables
One-dimensional arrays
Arrays
Two-dimensional arrays
IM 33G3C20-11E 3-5
3.6 Declaring Local Variables
Local variables are declared by stating data type and one or more variables.
EXAMPLES: integer i1,i2 (integer-type variables i1 and i2 are declared).
float f1,f2 (float-type variables f1 and f2 are declared).
The declaration statement must be described as action for the start symbol when writing
an SFC block program or preceding the executable statement when writing a SEBOL
block program.
<type specifier>: State the data type (char*n, integer, long, float, or double).
<variable name>: State the variable name using the identifier. More than one variables can be declared
for each data type specifier using commas between variable names.
In the type specifier for a character-string variable (char*n), enter the length of the
variable (1 to 255 bytes) in place of the “n.”
3-6 IM 33G3C20-11E
3. Syntax and Other Protocols
<variable name>
EXAMPLE:
Declaring and referencing simple a local variable (“cat” is a built-in function to connect
character strings):
sebolblock sample2
integer I,J,K
char*4 CHR1,CHR2
char*8 CHR3
......
K = I * J
CHR3 = cat(CHR1,CHR2)
......
end
One-dimensional array:
<type specifier><array name>'['<no. of elements>']'[,…]
Two-dimensional array:
<type specifier><array name>'['<no. of 1-dim. elements>,<no. of 2-dim.
elements>']'[,…]
<type specifier>: State the data type (char'n, integer, long, float, or double).
<array name>: State the element name using the identifier.
<no. of elements>: State the number of elements using the integer constant.
• More than one arrays can be declared for each data type specifier using commas
between array statements.
• Simple variables and arrays can be declared using the same line.
• Subscript expressions begin with 1. When a[n] is declared, elements are expressed
a[1],…a[n].
• With a two-dimensional array, the declared array is placed in memory so that the two-
dimensional elements are renewed first.
IM 33G3C20-11E 3-7
EXAMPLE:
Sequence of data in a two-dimensional array. (The array is placed in memory as shown
in Figure 3.10.)
integer a[2,3]
The range of the numbers of elements in local variable arrays is shown in Table 3.3.
Entire array:
<array name>'['*']' or <array name>
<array name>: State the name of the array to be referenced.
<subscript expression>: Specify the element to be referenced using an integer expression.
Only constants and local simple variables can be used in the subscript expression. (In
this manual, simple variables and array elements may be referred to simply as variables.)
3-8 IM 33G3C20-11E
3. Syntax and Other Protocols
EXAMPLE:
Declaring and referencing an array:
sebolblock sample3
integer I,J,K,SUM,A[3,3]
char*4 STAT[10]
......
SUM = 0
for I = 1 to 3
for J = 1 to 3
SUM = SUM + A[I,J]
next@
next@
......
message ”message %4s %5d”,STAT[K],SUM
......
end
IM 33G3C20-11E 3-9
3.7 Function Block Data
Tag and data item names are used to access function-block data, which are used in
SEBOL as parameters in an expression or a statement similar to local variables.
EXAMPLE:
Reading process variable (PV) value of function block with a tag name of FIC001 to
local variable “pv_value”:
sebolblock example1
block PID FIC001
double pv_value
......
pv_value = FIC001.PV
......
end
The tag name of a function block can be declared using a block statement as in this
example in the manner similar to the declaration of local variables, and the data of a
function block can be accessed by specifying the tag name and the data item name.
There is another way of declaring the tag name of a function block called “implicit
declaration,” which is described in 3.8, Implicit Declaration. The declaration of tag
names is further described in detail in Chapter 7, Section 1.
Function block data can also be accessed by using a local generic name and a function
formal argument instead of the tag name.
See Table 3.4 for a list of variables used in relation to function block data.
3-10 IM 33G3C20-11E
3. Syntax and Other Protocols
NOTE
Implicit declaration is useful with small programs of less than about 50 lines but not so
useful with larger programs. Because erroneous entries of similar letters, such as I, l,
and 1, will be determined as new variables and will not be detected as compile errors,
making it difficult to find errors in large programs. Thus it is recommended to use
implicit declaration only when the program is small.
#IMPLICIT
IM 33G3C20-11E 3-11
3.8.2 Implicitly Declared Local Variables
An undeclared variable is implicitly declared as a local simple variable if the undeclared
variable has no period following its name. And the data type of the implicitly declared
variable is determined by the first letter in the name of the undeclared variable — see
Figure 3.13.
If a variable in the array or array element is not declared, it cannot be implicitly declared
and a compile error will be caused.
NOTE
• The data item check will not be performed if the tag name is not builder-defined or
exists in a different control area from the SFC/SEBOL block.
• If the tag name begins with a numeral or contains a hyphen, implicit declaration is not
applicable and must be declared otherwise — see 5.2.1, Declaring Tag Names; and
5.2.2, Local Generic Name & “assign” Statement.
3-12 IM 33G3C20-11E
3. Syntax and Other Protocols
#define <identifier><token>
A character string as long as to the return code can be entered as a “token” but the white
spaces and comments preceding the return code will be excluded. A line can be
continued in the next line entering a backslash (\) or double slashes (//) at the end of the
line.
Substituting an identifier with a token can make it easier to read the program as in the
example shown below:
EXAMPLE:
The constant “2” is substituted with the token “OPEN” (the drive statement changes the
output state of a switch instrument with an answerback check — see 7.2.4 for descrip-
tion):
sebolblock example
#define OPEN 2
block SIO-22 VALVE1,VALVE2
......
drive [VALVE1 = OPEN]
drive [VALVE2 = OPEN]
......
end
When a substituting token contains a numeric expression, place the expression in
parentheses.
EXAMPLE:
If the numeric expression is not placed in parentheses as in the fourth line, the expres-
sion may not properly be calculated:
sebolblock example2
#define MAXLEN 256
#define GOOD(MAXLEN-1) ! This is correct.
#define BAD MAXLEN-1 ! This is wrong.
integer i1,i2
......
i1 = GOOD * 5 ! Calculated as (MAXLEN-1)*5.
i2 = BAD * 5 ! Calculated as MAXLEN-(1*5).
......
end
IM 33G3C20-11E 3-13
3.10 Inclusion of Files
A command line can be replaced with a file using the compiler-control command
#include — the command line itself is replaced with the file specified in the line.
#include “<filename>”
The inclusion of a file is useful when using the same constant in more than one pro-
gram, for example. A file can be created defining the identifier for the constant in a
#define statement, then the file can be included in more than one SFC/SEBOL blocks
using #include command lines. If the value of the constant changes, the file can be
modified and the blocks containing the included files can then be recompiled.
File inclusion cannot be nested — a compile error will be caused if an included file
contains a #include command line.
If a compile error has been detected in an included file, the line number in the error
message corresponds to that of the #include line used for the inclusion of the file.
Table 3.5 lists the system-fixed include files that are provided by the system.
The contents of the system-fixed include files are described in Appendix 7, “System-
Fixed Include Files.”
3-14 IM 33G3C20-11E
4. Operators and Expressions
SEBOL operators
+ (addition)
– (subtraction)
* (multiplication)
/ (division)
mod (remainder)
+ (positive)
– (negative)
Relational operators
Equality operators
== (equal)
<> (not equal)
— (ones complement)
IM 33G3C20-11E 4-1
SEBOL uses expressions, which represent constants and variables that appear alone or in
combination with operators; they are shown in Figure 4.2.
SEBOL expressions
<function>
<constant>
<variable>
(<expression>)
<expression><relational operator><expression>
<expression><equality operator><expression>
4-2 IM 33G3C20-11E
4. Operators and Expressions
IM 33G3C20-11E 4-3
4.2 Relational and Equality Operations
Relational and equality operations are performed on numeric data as well as character-
string data.
4-4 IM 33G3C20-11E
4. Operators and Expressions
IM 33G3C20-11E 4-5
4.4 Bitwise Logical and Shift Operations
Bitwise logical and shift operations are performed on numeric data .
4-6 IM 33G3C20-11E
4. Operators and Expressions
IM 33G3C20-11E 4-7
4.6 Operation Priority
Priority is given to operators in operations as shown in Table 4.1.
Relational operators (<, <=, >, >=) and equality operators (==, <>) need to be carefully
used.
Expressions (0<A<10) and (0<A and A<10) are taken as two completely different
expressions, for example. The relational operator “<” operates from left to right; thus
the expression (0<A<10) is evaluated as ((0<A)<10), starting operation with (0<A) and
returning 1 (true) when the relational condition is satisfied or 0 (false) when not satis-
fied. The result is then compared with 10 to produce the final value, which cannot be
other than 1 (true) because the compared result always is 1 or 0 and smaller than 10.
Thus, the other expression (0<A and A<10) must be used in this case.
If A is -1, the following two expressions will evaluated to produce different results:
(“<” has priority over “and”):
((0<A) and (A<10)) → (0 and 1) → 0
((0<A) <10)) → (0<10) → 1
EXAMPLES:
• 4*2–8/4 is the same as (4*2)–(8/4) .
• X=A==D is the same as X=(A==D) .
• S<“0” or S>“9” is the same as (S<“0”) or (S>“9”) … (S is a character variable.)
4-8 IM 33G3C20-11E
4. Operators and Expressions
IM 33G3C20-11E 4-9
(2) Arithmetic “mod,” Bitwise Binary Logical and Shift Operators
With the arithmetic operator “mod,” bitwise binary logical operators, and bitwisde shift
operators, real-number operands are converted to integer operands and rounded off
before operation. If an overflow is caused in the type conversion, the maximum
absolute value of the same sign will be used.
4-10 IM 33G3C20-11E
4. Operators and Expressions
<variable> = <expression>
<variable>: Assigned with the result of the expresion on the right-hand side.
<expression>: Calculates the value to be assigned to the variable on the left-hand side.
A: Caution for overflow, B: Caution for column truncation, —: Caution not needed
NOTE
IM 33G3C20-11E 4-11
(2) Character-String Type
When a long character string is assigned to a short character-string variable, excessive
characters are deleted from the end of the long string to match the length of the short
string.
When a short character string is assigned to a long character-string variable, a terminal
symbol is added to the end of the short string judging that the variable has a short string.
4-12 IM 33G3C20-11E
5. Variables
5. Variables
The use of local variables and function-block data is described in this chapter.
integer average()
integer data[NUMDATA]
integer i,ave !←Local variable in SEBOL block “mainprog”.
......
* Value-setup at array “data” considered to have been instructed.
i = data[0]
ave = average(data,NUMDATA)
* Value of “i” does not change because it is different from “i” in function below.
......
end
IM 33G3C20-11E 5-1
The local values in an SFC/SEBOL block are initialized to 0 when the block is started.
The local values in a function, however, are not initialized by the system and their
values are thus indefinite when the function is called.
Local variables are available only during the execution of the program. The local
variables in an SFC block are available only when the block status is RUN or PAUS,
and those in a SEBOL block only in the RUN status. The local variables in a function
are available during the time after the function has been called and until its execution is
terminated by the return or end statement.
Local variables can be accessed at a relatively higher speed than function-block data.
Thus in a program that demands high performance, function-block data, especially those
of other stations, can be stored in local variables, which can then be referenced at high
speeds. However, discrepancies may be caused between the data stored for the conve-
nience and the actual function-block data as time elapses, requiring special attention.
Also when a program contains such local variables, the readability of the program is
generally adversely affected compared to programs that require direct access to function-
block data.
5-2 IM 33G3C20-11E
5. Variables
The format of “%+ ‘data item name’ ” is used to access the data of the present SFC/
SEBOL block.
EXAMPLE:
Referencing the mode of present SEBOL block (reading data to local character-string
variable s1:
sebolblock example
char*8
......
s1 = %.MODE
......
end
The SFC block permits to user-define data items in addition to system-specific data
items; user-defined data items are not allowed in the SEBOL block.
With the SFC block, a compile error is caused if a data item name following ‘%.’
(period) is not defined using the builder’s SFC block data definition.
IM 33G3C20-11E 5-3
5.2.1 Declaring Tag Names
A “block” statement is used to declare the tag name for a function block. A tag name
uses the first 16 characters for identification. However, its eight leading characters must
be unique and distinguishable from local variable names and other identifiers, such as
the names defined using “#define”, which use the first eight characters for identification.
It is necessary to designate an alias for the tag name if it contains a hyphen or begins
with a numeral, and the alias must be used in the program.
EXAMPLE:
Replacing tag name PID-001 with alias PID_001:
sebolblock example
block PID PID_001 alias PID-001
......
PID_001.SV = 100.0 ! Alias must be used in the program.
......
end
NOTE
The tag name declared using the block statement is not checked during compilation
whether it has been builder-defined. An error will be caused during execution if the tag
name is not builder-defined.
Data item names are checked during compilation for the following items:
• Whether the data item exists in the specified block code.
• Whether data can be written if it is an assignment statement or the left-hand side of a
group assignment statement.
• Whether the data item is a numeric or character-string type — so that numeric and
character data will be correctly managed.
5-4 IM 33G3C20-11E
5. Variables
Simple variable
genname<block code><local generic name>[,<local generic name>…]
One-dimensional array
genname<block code><local generic name>‘[’<number of elements>‘]’
[,<local generic name>‘[’<number of elements>‘]’…]
The array element number begins with 1. When the array is declared to be “g[10]”, it
has 10 elements from “g[1]” through “g[10]”. They can be processed as a group for the
entire local generic name array using a group assignment, compare, or drive statement
— see Chapter 7 for details.
Data item names are checked for the specified block code of the declared generic name
and a compile error will be caused if an error is detected.
Local generic names are local variables and the relationships between local generic
names and tag names are specific to the program.
IM 33G3C20-11E 5-5
The “assign” statement is used to assign a tag name to a local general name as shown in
Figure 5.3.
<tag name>: Specifies the tag name to be assigned to the local generic name using a
character-string variable or constant, which can contain hyphens or begin
with a numeral. The first 16 bytes are significant if the string exceeds
16 bytes. The tag name must be specified in uppercase letters.
<local generic name>: Specifies the simple variable or array elements for the local generic name.
The “assign” statement does not check the existence of the same tag name — an error
will be caused if it does when accessing the function block using the local generic name.
No error is caused if the block code for the assigned tag name does not coincide with
the block code specified in the “genname” declaration.
Local generic names are used when changing tag names to be processed at the start of
SFC/SEBOL blocks.
EXAMPLE:
Assigning tag name, specified to character-string parameter of SEBOLP1 SEBOL block,
to local generic name using “assign” statement:
sebolblock example2
genname PID tag001,tag002,tag003
......
assign %.CH01 to tag001
assign %.CH02 to tag002
assign %.CH03 to tag003
......
if (tag001.PV > 100) then
tag002.SV = 100.0
else
tag003.sv = 100.0
endif
......
end
In the example, the data following “%.” are data of the present SEBOL block; the tag
name strings specified at character-string parameters CH01, CH02, and CH03 in the
present block are assigned to local generic names tag001, tag002, and tag003.
5-6 IM 33G3C20-11E
5. Variables
IM 33G3C20-11E 5-7
6. Functions
6. Functions
A number of statements can be grouped together in a subprogram and user-defined as a
function, creating a new procedure, for example. The manners of function defining and
calling are described in this chapter.
Executable statements
end
<type specifier>: Specifies the type of value returned by the function (integer, long, float,
or double). (Character string-type data cannot be used)
<function name>: Specifies the identifier used as the name of the function.
<formal argument list>: Specifies the variable list to receive from the function caller.
The function permits exchanging data with the function-caller by means of the argument
array and the return value. The argument specified in the function call line of the caller
is an actual argument and that used in the function definition is a formal argument. Up
to 32 arguments can be used.
NOTE
• A function can call another function. Function calls can be nested in up to six levels
— an error is caused and the SFC/SEBOL block will be terminated if the function at
the sixth level calls another function.
IM 33G3C20-11E 6-1
The function can be terminated using a “return” or “end” statement — the “return”
statement returns a value to the caller.
Specifying an expression following the “return” command returns the value resulted in
the expression to the function-caller after converting the type of the value to the function
type specified in the “function” statement.
NOTE
• The return value will be infinite when a function is ended using a “return” statement
without any return-specifying expression or an “end” statement.
• An error is caused during execution if a function that does not return a value is
described in a numeric expression or on the right-hand side of an assignment state-
ment — the variable on the left-hand side of the statement will not be affected.
6-2 IM 33G3C20-11E
6. Functions
<type specifier>: Specifies the type of the function to call (integer, long, float, or double).
<function name>: Specifies the name of the function to call.
A function and a local variable can be declared in the same line. The function cannot
return character-string values — use arguments to exchange character-string data.
The declared function can be called using the format shown in Figure 6.4.
<actual argument list>: Specifies the data list for the function.
EXAMPLE:
Function to obtain average value:
sebolblock mainprog
#define NUMDATA 100
integer average(),data(NUMDATA),ave
......
* Value-setup at array “data” considered to have been instructed.
ave = average(data,NUMDATA)
......
end
IM 33G3C20-11E 6-3
6.3 Function Arguments
An argument that the caller to a function specifies on the function call line is called an
actual argument; one that is declared in a definition of that function is called a formal
argument. Up to 32 arguments can be used.
To declare a character string-type formal argument, specify 0 for the length, which is
determined by the actual argument.
To declare one-dimensional array formal argument, specify “*” for the number of
elements, which is determined by the actual argument.
To declare two-dimensional array formal argument, specify “*” for the number of first-
dimension elements. The number of second-dimension elements is determined by the
actual argument. SEBOL arranges two-dimensional array elements so that second-
dimension elements are updated first. Thus the size of second-dimension elements is
required in calculating subscripts of the elements.
6-4 IM 33G3C20-11E
6. Functions
EXAMPLE:
Using character string, one-dimensional array, and two-dimensional array as arguments:
sebolblock mainprog
integer al[10],a2[3,6]
char*16 str
integer example()
integer i1,i2
......
example(a1, i1, a2, i2, str) ! Function call.
......
end
IM 33G3C20-11E 6-5
6.3.1 Verifying Argument Types
The types of actual and formal arguments are verified to ascertain their compatibility
when a function is called for execution, causing an error if they are not compatible.
An error is caused if the actual argument is a local variable and the formal argument is a
function block or vice versa. When both actual and formal arguments are local vari-
ables, they are compatible (●● ) or an error is caused (×) when executed as shown in
Table 6.2.
Actual Arg. Declaration\Formal Arg. Declaration Simple 1-dim. Array 2-dim. Array
Constant ● × ×
Simple ● × ×
Array element ● × ×
One-dimensional array × ● ●
Two-dimensional array × ● ●
The combination of one- and two-dimensional arrays does not cause an error when
executed. Because two-dimensional arrays are arranged so that second-dimension
elements are updated first, they correspond to one-dimensional array elements in the
updated order.
EXAMPLE:
Combination of two-dimensional array actual argument and one-dimensional array
formal argument:
sebolblock mainprog
integer array[2,4] ! Two-dimensional array actual argument.
integer example()
......
example(array,8) ! 8 elements.
......
end
6-6 IM 33G3C20-11E
6. Functions
The compatibility of argument types when formal arguments are local simple variables
is shown in Table 6.3. If both arguments are numeric-type or character string-type, they
will be executed without causing any error. Formal arguments are considered to have
the type of their corresponding actual arguments.
Table 6.3 Correspondence between Actual Arguments and Local Simple Variable
Formal Arguments
Actual Arg. Type\Formal Arg. Type integer long float double char*0
integer ● ● ● ● ×
long ● ● ● ● ×
float ● ● ● ● ×
double ● ● ● ● ×
char*n × × × × ●
The testing of arrays of different types, unlike that of simple variables, results in a run-
time error. Arguments are assumed to have the actual argument type.
Table 6.4 Correspondence between Actual Arguments and Local Variable Array
Formal Arguments
Actual Arg. Type\Formal Arg. Type integer long float double char*0
integer ● × × × ×
long × ● × × ×
float × × ● × ×
double × × × ● ×
char*n × × × × ●
IM 33G3C20-11E 6-7
6.4 Declaring Function Block Formal Arguments
Function block formal arguments are declared using an “argblock” statement as shown
in Figure 6.5.
One-dimensional array formal arguments are declared also using an “argblock” state-
ment as shown in Figure 6.6. They are regarded as having a size of an actual argument.
A one-dimensional array and a simple variable can be declared in the same line. (Two-
dimensional arrays cannot be used in function blocks.)
6-8 IM 33G3C20-11E
6. Functions
char*8 blkmode
blkmode = blk001.MODE
......
return
Actual arguments that can be specified as one-dimensional-arry function-block formal
arguments are listed in Table 6.6:
char*8 blkmode
chart*8 blksts[3]
return
IM 33G3C20-11E 6-9
6.4.1 Referencing Function Block Data
Formal-argument function-block data are referenced using the formal argument name
and a data item name.
EXAMPLE:
integer function example(simple,array,n,max)
argblock PID simple,array[*] ! Formal argument declaration.
integer n,max ! Element No. and array size.
......
simple.MV = 10.0
wait until (simple.PV >= 9.9)
......
if (n <= max) then
array[n].MV = 10.0
wait until (array[n].PV >= 9.0)
end if
......
end
The block code is specified in the “argblock” statement. The compiler checks the
applicability of the data item name with the block code. A compile error is caused if a
non-applicable data item name is used or a write-disable data item name is entered on
the left-hand side of the assignment statement.
When the block code specified in the “argblock” statement and the block code for the
function block specified to the actual argument are not identical, they will be executed
without causing any error.
6-10 IM 33G3C20-11E
6. Functions
char*8 blkmode
ERR900:
message "tag name %s does not exist", tag
return –1
IM 33G3C20-11E 6-11
6.5 Variables Used with Functions
Functions can also use local variables in addition to formal arguments.
6-12 IM 33G3C20-11E
6. Functions
ugen001.MV = value1
wait until(ugen001.PV >= value2)
end
IM 33G3C20-11E 6-13
6.6 Built-in Functions
A built-in function is a system-defined function. Built-in functions can be called by the
function name and argument the same way as ordinary functions are called. Unlike
user-defined functions, built-in functions do not require declaration. The names of built-
in functions are handled as reserved words.
Build-in functions are available in several groups — see Tables 6.7.
labs(a) L L
Absolute value
dabs(a) D D
lmax(a,b,c,…) L L
Max. value
dmax(a,b,c,…) D D
Arithmetic lmin(a,b,c,…) L L
Min. value
dmin(a,b,c,…) D D
Power power(a,b) D D
bitpstn(a,b) I or L(*1), I or L L
Bit operation Bit position search
bitsrch(a,b) I or L(*1), I or L L
llimit(a,b,c) L L
High-low limit High & low limits
dlimit(a,b,c) D D
Sine sin(a) D D
Cosine cos(a) D D
Trigonometric
Tangent tan(a) D D
Arctangent atan(a) D D
Square root Square root sqrt(a) D D
Exponentiation Exponent exp(a) D D
I: integer, L: long, F: float, D: double, C: char (I, L, F, D, C: simple variables or array elements)
*1: Only a local variable can be used to specify an array or array element.
*2: All arguments can use only local simple variables or array elements.
*3: b, c, d, e, f, and g are limited to local simple variables or array elements.
6-14 IM 33G3C20-11E
6. Functions
I: integer, L: long, F: float, D: double, C: char (I, L, F, D, C: Simple variables or array elements)
G: Local generic name or formal argument function block.
DS: Function block data with data item #<data item name>, or long-type local variable.
IM 33G3C20-11E 6-15
6.6.1 Arithmetic Functions
(1) Absolute Value (labs, dabs)
labs (arg) converts the argument type to long and returns a long-type absolute
value of the argument.
dabs (arg) converts the argument type to double and returns a double-type absolute
value of the argument.
6-16 IM 33G3C20-11E
6. Functions
1 16
1 32
1 16 17 32 33 48 49 64 65 80 81
1 32 33 64 65
IM 33G3C20-11E 6-17
When “arg1” is an array element, the search will be made starting with that element and
as far as the elements specified in number by “arg2,” and the most significant bit in the
“arg1”-specified array element is returned. See Figure 6.8
1 16 17 32 33 48
1 32 33
6-18 IM 33G3C20-11E
6. Functions
IM 33G3C20-11E 6-19
6.6.8 Character-String Functions
(1) Conversion to Integer-Type (ichr)
ichr(arg) converts a character-string argument into an integer-type value and returns
the code corresponding to each character. The first character is used when the argument
contains two or more characters.
6-20 IM 33G3C20-11E
6. Functions
IM 33G3C20-11E 6-21
6.6.11 Error Functions
(1) Latest error code (errc)
errc() returns the error code of the most recently occurring error. It returns 0 if no
error has occurred since the initiation of the SFC or SEBOL block.
6-22 IM 33G3C20-11E
6. Functions
IM 33G3C20-11E 6-23
6.6.14 Other Functions
(1) Present Block Tag Name (gettagno)
gettagno() returns the tag name of the present SFC/SEBOL block. In a unit-started
SFC block operation, however, gettagno() returns the tag name of the present unit.
Use getname(%) to acquire the tag name of the present SFC/SEBOL block or
getname(%%) to acquire the tag name of the present unit at all times.
6-24 IM 33G3C20-11E
7. Function Block Data
7.1 Overview
The function block data of the present plant can be described — in the same way as
local variables — within an expression or on the left-hand side of an assignment
statement using SEBOL.
Function block data is written in the format of <tag name>.<data item name>.
EXAMPLE:
Waiting until PV of the block tag-named TAG001 reaches 50.0 or higher:
sebolblock sample
block PID TAG001
......
wait until (TAG001.PV >= 50.0)
......
end
Function block data can also be accessed describing its local generic name and a
function formal argument — one-dimensional arrays can be used for global generic
names and generic names as well as local generic names and formal arguments. See
Table 7.1 for a list of declarations used for function blocks.
Simple variables and two-dimensional arrays can be used to describe data item names as
shown in Table 7.2.
IM 33G3C20-11E 7-1
An entire function block array can be described using a group assignment or “compare”
statement but data item array elements cannot be described.
7-2 IM 33G3C20-11E
7. Function Block Data
Statement Function
Group assignment Grouped input/output of function-block data.
“compare” statement Grouped comparison of function-block data.
“drive” statement Grouped output with answerback check.
The group assignment statement instructs writing or reading multiple function-block data
specifying data on both sides or one side of the statement. The “compare” statement is
used for a group comparison and the “drive” statement for a group output of data to a
switch instrument with answerback check.
The group assignment statements can be used for accessing function-block data of
another plant but the other two statements are used only with the function-block data of
the present plant.
EXAMPLE:
Grouped data writing and comparison:
sebolblock example
block PID TAG001,TAG002
......
[TAG001.SV,TAG002.SV = 10.0,10.0] ! Group assignment statement.
compare[TAG001.PV,TAG002.PV >= 9.7,9.7] ! Compare statement.
......
end
In this example, the group assignment statement sets two function-block setpoint values
at 10.0 and the “compare” statement compares two function-block process variables until
they are 9.7 or higher.
Error processing can be described in any of the three group statements and the duration
of comparison can be specified in seconds in the “compare” statement. Their formats
are described later in this section.
IM 33G3C20-11E 7-3
Local variables, constants, or function-block data variables lists are used on the left- and
right-hand sides of a group statement. Variables used in the function-block data
variables list are shown in Table 7.5. Where local variables can be used, formal argu-
ment local variables can be used; and where local generic names can be used, generic
names and formal argument function blocks can be used.
Assignment “compare”
“drive” Statement
Variable Statement Statement
LH RH LH (*1) RH (*2) LH (*3) RH (*4)
Constant × ● ● ● × ●
Simple local variable ● ● ● ● × ●
Local variable array element ● ● ● ● × ●
Local variable array ● ● ● ● × ●
Tag name + Data item name ● ● ● ● × ×
Simple local generic name + Data item name ● ● ● ● × ×
Local generic name array element + Data item name ● ● ● ● × ×
Local generic name array + Data item name ● ● ● ● × ×
Simple function-block formal argument + Data item name ● ● ● ● × ×
Function-block formal argument array element + Data item name ● ● ● ● × ×
Function-block formal argument array + Data item name ● ● ● ● × ×
Tag name × × × × ● ×
Simple local generic name × × × × ● ×
Local generic name array element × × × × ● ×
Local generic name array × × × × ● ×
Simple function-block formal argument × × × × ● ×
Function-block formal argument array element × × × × ● ×
Function-block formal argument array × × × × ● ×
● : Applicable ×: Not applicable
*1: Variable or constant entered on the left of comparison symbol.
*2: Variable or constant entered on the right of comparison symbol.
*3: Target function block, such as switch instrument, for output.
*4: Output value.
Where tag names can be described, the present block (%) or present unit (%%) can be
described — see SFC Block Function Manual (IM 33G3C31-11E) for the description of
the present unit. See Table 7.6 for the applicability of tag-name and other description in
SEBOL and SFC blocks and functions.
7-4 IM 33G3C20-11E
7. Function Block Data
Where local generic names can be described, generic names and others listed in Table
7.7 can be specified.
Table 7.7 Generic Name & Other Description
IM 33G3C20-11E 7-5
<tag name>.<data item name>[.<data item name>…]
Array:
Enter in “<tag name>“ a tag name that is declared in the “block” or “global block”
statement. Variables that can be described in place of “<local generic name>“ are listed
in Table 7.8.
Simple variables or array elements can be used for data item names when the function
block is a simple variable or array element:
Simple variable: TAG001.PV
One-dimensional array element: TAG001.ITEM[i+l]
Two-dimensional array element: TAG001.ITEM[i,j]
7-6 IM 33G3C20-11E
7. Function Block Data
Only simple variables can be used for data item names with a function-block array.
EXAMPLE:
Reading function-block mode and process values:
sebolblock example
block PID TAG001,TAG002
char*16 s1,s2
double d1,d2
......
[s1,d1,s2,d2 = TAG001.MODE.PV,TAG002.MODE.PV]
......
end
In the above example, the block mode is read to local variables s1 and s2, and process
values to local variables d1 and d2.
EXAMPLE:
Specifying data item names for array:
sebolblock example
genname PID TAG[3]
......
assign ”TAG001” to TAG[1]
assign ”TAG002” to TAG[2]
assign ”TAG003” to TAG[3]
......
[TAG[*].MODE.SV = ”AUT”,”AUT”,”AUT”,10.0,10.0,10.0]
......
end
In this example, data are read to TAG[*].MODE.SV in order of TAG[1].MODE,
TAG[2].MODE, TAG[3].MODE, TAG[1].SV, TAG[2].SV, and TAG[3].SV.
IM 33G3C20-11E 7-7
7.2.1 Group Assignment Statement
The group assignment statement is written as shown in Figure 7.2.
The “variables/constants list” on the right-hand side is set in the “variables list” on the
left-hand side. “Error array” sets an error code in the array element (0 is set when
normal) so that the function-block data that caused an error can be identified. “Label”
specifies the destination for branching when an error is caused. “Error identifier”
permits to identify the location of the error in the error-handling phase, making a built-in
function return the error identifier value. See Chapter 10 for the details of error-
handling.
7-8 IM 33G3C20-11E
7. Function Block Data
IM 33G3C20-11E 7-9
Table 7.9 shows the operations that take place when the amount of data on the left-hand
side and that of data on the right-hand side differs. The tests outlined in Table 7.9 are
made at compile time unless the variable contains an entire array of formal arguments of
the function. If the variable contains an entire array of formal arguments of the func-
tion, an error is detected at execution time. When an error occurs while checking the
amount of data, the assignment variable on the left-hand side and the value of each
element of the error array remain unchanged.
Local variable only Function block data only Error caused if there are more data on the right-hand
side than the left-hand side.
Error caused if there are more data on the left-hand
Function block data only Local variable only side than the right-hand side.
Function block data only Function block data only Error caused if there are more data on the right-hand
Local variable only Local variable only side than the left-hand side.
If the number of error-array elements is larger than the number of processed data, 0 or
an error code is set at the first element of the error array but values of redundant
elements remain unchanged.
If the number of error-array elements is less than the number of processed data, an error
is caused. This error is caused during compilation if any function formal argument array
is contained in the statement — if it is, the error is caused during execution. If the error
is caused when executed, values of the assigned variable and error array elements on the
left-hand side remain as they were before the execution of the statement.
NOTE
• The variable on the left-hand side of a group assignment statement cannot be used on
the right-hand side or in the array subscript in the same statement.
• The user is not informed of whether the value after the assignment is used or the
value before the assignment is used.
7-10 IM 33G3C20-11E
7. Function Block Data
EXAMPLE:
The user is not informed of whether access is made to the local generic name array
GEN001[3] or GEN001[5] in the following program:
......
integer i
genname PID GEN001[10],GNAM001
......
! Incorrect program.
i=3
[i,GEN001[i].MODE,GNAM001.SV=5,”AUT”,100.0]
......
The assignment to subscript variable “i” should be removed from the above incorrect
program, rewriting it as follows:
......
integer i
genname PID GEN001[10],GNAM001
......
! Correct program.
i=5
[GEN001[i].MODE,GNAM001.SV=”AUT”,100.0]
......
EXAMPLE:
It is not known whether TAG001.SV is set with 5 or 10 in the following program:
......
integer i
block PID TAG001
......
! Incorrect program.
i=5
[i,TAG001.SV = 10,i]
......
The program should be written as follows:
......
integer i
block PID TAG001
......
! Correct program.
i=5
[i,TAG001.SV = 10,10]
......
IM 33G3C20-11E 7-11
7.2.2 Data of Another Plant
Function-block data of another plant can be accessed designating the plant name in the
group assignment statement.
The plant name, which can use a character string of 8 or less bytes, is the unit of
managing plants. Tag names need to be unique only within a named plant; that is that
the same tag names can be used with another plant if its name is different.
The function blocks on both sides of the group assignment statement are taken as tag
names that belong to the plant designated in the statement. Two or more plants cannot
be designated in one line, however, to access their function block data.
EXAMPLE:
Reading process values to local variables d1 and d2 from tag names PID001 and PID002
at PLANT-XL:
sebolblock example3
block PID:XL PID001,PID002
double d1,d2
......
[d1,d2=PID001.PV,PID002.PV],”PLANT-XL”
......
end
The “XL” in the “block” statement specifies the system model, which is necessary when
accessing data of a block that uses a model other than CENTUM CS.
Function-block data of another plant can only tbe accessed using the group assignment
statement; they cannot be written on the left-hand side of an ordinary assignment
statement or expression. Also, neither the “compare” nor “drive” statement can be used
for the purpose.
When running a single program to access function blocks that have the same tag number
existing in different plants, use a local generic name for either or both. Assume that the
tag number FIC001 exists in both plants P1 and P2.
sebolblock example4
genname PID P1_FIC001, P2_FIC001
double d1, d2
*1 A plant name is the basic unit of plant management. A plant name must be unique
for each tag name. Identical tag names having different plant names are handled as
different tag names. A plant name is a string of eight or fewer alphanumeric
characters.
7-12 IM 33G3C20-11E
7. Function Block Data
The “compare” statement compares the value of the variable or constant on the left-hand
side of the comparison symbol with that on the right-hand side of the symbol. When the
condition is satisfied after comparing all elements, the statement is normally ended and
the execution of the program proceeds to the next line.
When “time” is specified, comparison is performed until the condition is satisfied and as
long as the specified time period permits — an error will be caused if the condition is
not satisfied within the specified time. Comparison is performed infinitely until the
condition is satisfied when “time” is not specified.
If the types of data on left- and right-hand sides do not agree, they are converted
according to the rules for relational and equality operators — see 4.7, Conversion of
Operands, for details.
To compare function-block data with a local variable/constant, function-block data must
be entered on one side rather than entering them on both sides, which shortens the
processing time.
If a communication error is caused with a variable on either side, the “compare”
statement will be cancelled. The statement will also be cancelled when a comparison of
numeric and character-string data is attempted.
IM 33G3C20-11E 7-13
“Error array” sets an error code in the corresponding array element if an error is caused
when the condition is not satisfied or a value is returned — 0 is set when the condition
is satisfied. “Label” specifies the destination for branching when an error is caused.
“Error identifier” permits to identify the location of the error in the error-handling phase,
making a built-in function return the error identifier value. See Chapter 10 for the
details of error-handling.
The “compare” statement cannot compare ambiguous data, such as “PV 50” or
“approximately 50”; caution is needed when comparing analog or real-number data. It
should also be noted that a comparison of a float- or double-type real-number data and a
real-number constant using the equality operator “==” may result the unsatisfied
condition. Real-number data are values having finite precision and produce diminutive
errors in almost all cases when operated or converted in types from “double” to “float.”
And the comparison of real-number data that contains an error using the equality
operator “==” results the unsatisfied condition. It is thus necessary to use a relational
operator (>=, <=, >, <) to compare real numbers.
As to the timing of getting function-block data for comparison, data on both sides can be
acquired at the same time if they are at the same control station as the SFC/SEBOL
block that executes the “compare” statement.
When comparing data of another station, communication is generated for the acquisition
of data and thus data cannot be acquired at the same timing when comparing them
between the present and another stations or between two other stations. If function
blocks are at other stations, data for the left- and right-hand sides are acquired separately
through communication, so the timing of data acquisition is not guaranteed. Function
blocks on one side allow acquisition of their data at the same timing if they are in the
same area, but not if they are in different control areas even if they are at the same
control station other than the station that contains the SFC/SEBOL block.
When comparing data of the function-blocks of another station or other stations, it is not
guaranteed that comparison is executed every second because of the limited performance
of communication. Although caution is needed, the comparison does take place at least
once even if the specified time is exceeded.
See Figure 7.6 for the processing of data when there is a difference between the num-
bers of data on left- and right-hand sides. If variables do not contain any function
formal argument array, an error is caused when compiled — if they do, an error is
caused when executed. If the error is caused when executed, the error array value
remains unchanged. See Figure 7.6 for the data-checking performed at the time of
compilation.
7-14 IM 33G3C20-11E
7. Function Block Data
If the number of error-array elements is larger than the number of processed data, 0 or
an error code is set at the first element of the error array but values of redundant
elements remain unchanged.
If the number of error-array elements is less than the number of processed data, an error
is caused. This error is caused during compilation if any function formal argument array
is contained in the statement — if it is, the error is caused during execution. If the error
is caused when executed, values of the assigned variable and error array elements on the
left-hand side remain unchanged.
IM 33G3C20-11E 7-15
7.2.4 “drive” Statement
The drive statement alters the output status of a motor control block or switch instru-
ment block and waits for the end of the answerback checking by the block.
<function-blocks list>: Specifies a list of up to 16 function blocks. (The array is counted as one
for every array element.) See Table 7.5 for the types of variables that
can be used. It is not necessary to describe data item names because
they are fixed in the case of the “drive” statement.
<local variable/constants list>: Specifies an output value (0, 1 or 2) using local variables/constants.
<error array>: Specifies an integer-type local variable array in which the error code is
set if an error is caused — 0 is set when normal. A simple local variable
or array element can also be used if only one unit of data is output.
<label>: Specifies the branching destination when an error is caused.
<error identifier>: Specifies a local variable or constant for the identification of the location
where an error is caused.
The “drive” statement sets a value to the manipulated variable (MV) for the function
block on the left-hand side and waits until the block’s answerback check is completed.
The following describes actions of the “drive” statement:
7-16 IM 33G3C20-11E
7. Function Block Data
IM 33G3C20-11E 7-17
If the number of data on the right-hand side is less than the number of data on the left-
hand side, an error is caused. This error is caused during compilation if any function
formal argument array is contained in the statement — if it is, the error is caused during
execution. If the error is caused, output manipulation is not carried out and the error
variable remains as it was before the execution of the statement.
If the number of error-array elements is larger than the number of processed data
(number of function blocks of on the left-hand side), 0 or an error code is set at the first
element of the error array but values of redundant elements remain unchanged.
An error is also caused if the number of error-array elements is smaller than the number
of processed data. This error is caused during compilation if the left-hand side contains
any function formal argument array — if it does, the error is caused during execution.
If the error is caused during execution, output manipulation is not carried out and the
error variable remains unchanged.
Table 7.11 Switch Instrument Block and Motor Control Block Type Names
Type Name
SO-1
SO-2
SIO-11
Switch instrument block SIO-12
SIO-21
SIO-22
SIO-12P
SIO-22P
MC-2
Motor control block MC-3
Note: The switch Instrument blocks SI-1 and SI-2 cannot be handled with the drive
statement.
7-18 IM 33G3C20-11E
7. Function Block Data
EXAMPLE:
Use of “drive” statement:
sebolblock example
#define CLOSE 0
block SIO-22 VALVE01 VALVE02
......
drive[VALVE01,VALVE02 = CLOSE,CLOSE];errorsub ERR000
......
exit
ERR000:
message “VALVE close error line = %d errcode = %d–
%x”,errl(),errc(),errce()
ereturn
......
end
In this example, a switch block instrument with the tag names VALVE01 and
VALVE02 is loaded with an MV value of 0 before the valves are closed. When an
error occurs, the line number and error code are output in a message.
IM 33G3C20-11E 7-19
7.3 Block Modes and Block Statuses
The block mode is a piece of status information that represents the control or output
status of a function block. SEBOL permits reading the block mode as a character string
or changing it.
Nine basic block modes are available as listed in Table 7.13. The basic block modes are
common to all function blocks, though valid function modes vary from one function
block type to another. For definitions of the basic block modes and the types of basic
block modes applicable to particular function block types, refer to FCS Field Control
Station Function Manual (IM 33G3C10-11E).
Symbol Name
O/S Out-of-service
IMAN Initialization manual
TRK Tracking
MAN Manual
AUT Automatic
SEMI Semiautomatic
CAS Cascade
PRD Primary direct
Automatic (AUT) and manual (MAN) modes each are an independent mode of single,
significant action. Initialization manual (IMAN) and tracking (TRK) modes are depen-
dent on other basic modes and determine actions only in combination with others —
forming compound block modes for combined actions.
There are modes that are mutually exclusive or complementary. Those mutually
exclusive are automatic (AUT), MAN, semiautomatic (SEMI), cascade (CAS), and
primary direct (PRD) modes and their actions cannot be combined. Those mutually
complementary are IMAN and TRK modes and they can be combined with others to
form compound block modes.
Basic block modes have the order of priority to determine the order of action when
combined in a compound block mode — see Table 7.14.
7-20 IM 33G3C20-11E
7. Function Block Data
The effective action of a compound block mode is the action of the mode that has the
highest priority among the basic modes used in the compound mode. This basic block
mode of the highest priority is called the active mode in a compound block mode.
To compose a compound block mode, the active basic block mode is written first and it
is followed by other basic block modes each in parentheses according to their order of
priority as in the following example:
EXAMPLE:
Compound block mode of IMAN and AUT modes:
IMAN(AUT(RCAS))
The data item name MODE uses a character string when the mode is composed of
assorted basic block modes, listing the mode of the highest priority first and followed by
the modes of lower priority. If there is only one acceptable basic block mode, MODE
uses the character string for that basic block mode.
The data item name OMOD uses the character string for the acceptable basic block
mode of the lowest priority. The data item name CMOD uses the character string for
the acceptable mode of the highest priority. If there is only one acceptable basic block
mode, OMOD uses the character string for that basic block mode, and CMOD uses a
character string of zero length.
Examples are shown in Table 7.16.
When the OMOD or CMOD character string is less than 4 bytes, the string is shortened
but the space is maintained.
When the basic mode of the lowest priority has a string less than 4 bytes in the MODE
character string, the space is reduced in the first half of the string. Then the character
string for the basic mode of the highest priority starts at the fifth byte; if the string is
less than 4 bytes, it is shortened but the space is maintained in the last half of the
MODE string. If there is only one acceptable basic block mode, MODE uses a character
string of less than 4 bytes for that block.
IM 33G3C20-11E 7-21
Use @MODE to check to see if a particular basic block mode is established or not
among two or more basic block modes that coexist. @MODE is a 32-bit sequence of
data (long type), each bit of which represents one basic block mode. A 1 bit means that
the corresponding basic Block mode is established; a 0 bit means that the corresponding
basic Block mode is not established. The system-fixed include file, smode.h, holds a
definition of the correspondence between the basic block modes and bit numbers as
mask patterns defined by the #define instruction (see Table 7.17).
For example, if the tag name FIC001 is in the mode IMAN (AUT (RCAS)), then the
data items MODE are “RCASIMAN,” OMOD, “RCAS,” and CMOD, “IMAN.”
Whether AUT is established or not cannot be determined from this context (see Table
7.15), thus requiring a check with @MODE.
EXAMPLE:
sebolblock example
#include "smode.h"
block PID FIC001
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
7-22 IM 33G3C20-11E
7. Function Block Data
The IMAN or TRK mode cannot be set using SEBOL. Also some block modes cannot
be changed depending on the current block mode. For details, refer to the FCS Field
Control Station Function Manual (IM 33G3C10-11E).
IM 33G3C20-11E 7-23
7.3.3 Block Statuses
A block status designates the overall operating status a function block in combination
with a block mode. Block statuses are defined only for certain function blocks. The
names and meanings of the block statuses depend on the function block.
The individual statuses defined for a function block are called basic block statuses. Four
levels of priority exist among the basic block statuses. More than one basic block status
may be defined to have the same level of priority. Basic block statuses having the same
level of priority are exclusive with one another and are never established simultaneously.
Basic block statuses varying in their level of priority, on the other hand, may be estab-
lished simultaneously.
Either the data item BSTS or @BSTS with @ is used to read the block status of a
function block. The data item BSTS is a character string of up to eight bytes. Where
two or one basic block statuses coexist, BSTS gives the character string of the highest-
priority basic block status.
@BSTS is a 32-bit sequence of data (long type), each bit of which represents one basic
block status. A 1 bit means that the corresponding basic Block status is established; a 0
bit means that the corresponding basic Block status is not established. The system-fixed
include file, sbsts.h, holds a definition of the correspondence between the basic block
statuses and bit numbers as mask patterns defined by the #define instruction.
The data item BSTS should be used to reference the block status of any function block
whose basic block statuses have the same level of priority, such as SFC/SEBOL blocks
or units, and to program the block status as a character string. The data item @BSTS
should be used, on the other hand, to reference the block status of any function block
whose basic block statuses have varying levels of priority, such as timer blocks, and to
program the block status as 32-bit data. This is because, where two or one basic block
statuses coexist, the data item BSTS cannot check to see if any lower-priority basic
block status is established or not.
An example illustrates how the data item BSTS can be used to reference the block status
of a function block whose basic block statuses have the same level of priority. SFC
blocks involve four different block statuses: RUN, PAUS, STOP, and ABRT. Since not
all these block statuses are established simultaneously, the data item BSTS should be
used for programming purposes in handling SFC blocks.
7-24 IM 33G3C20-11E
7. Function Block Data
EXAMPLE:
sebolblock sample1
if (SFC0301.BSTS<>"RUN") then
!Action to take when the block status RUN is not established
......
end if
......
switch (SFC0301.BSTS)
case"RUN"
!Action to take when the block status RUN is established
......
case"PAUS"
!Action to take when the block status PAUS is established
......
case"STOP"
!Action to take when the block status STOP is established
......
case"ABRT"
!Action to take when the block status ABRT is established
......
end switch
......
end
Next, consider the case of a function block having basic block statuses with varying
levels of priority. As Table 7.19 indicates, three levels of priority exist among the basic
block statuses of a timer block (block model name TM).
NR Normal 11
1 (low) RUN Running 17
STOP Stopped 18
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
When a normally running timer block is paused, its block status changes to PAUS
(NR(RUN)). Since the data item BSTS is PAUS (having the highest level of priority) in
this status, it cannot check to see if any lower-priority basic block status, such as RUN
or NR, is established or not. When the timer block is in the block status PAUS
(NR(RUN)), bits 1, 11,and 17 would be 1, with @BSTS equaling $80208000.
IM 33G3C20-11E 7-25
The system-fixed include file, sbsts.h, is used to check the block status of a function
block with @BSTS. It holds a definition of the mask patterns of the basic block statuses
in the following format of #define:
Figure 7.7
#include "sbsts.h"
block TM TM0305
......
if ((TM0305.@BSTS & BS_RUN)<>0) then
!Action to take when the block status RUN is established
......
end if
......
if ((TM0305.@BSTS & BS_CTUP)==0) then
!Action to take when the block status CTUP is not established
......
end if
......
end
Note that parentheses are used to enclose TM0305.@BSTS&BS_RUN in the conditional
expression ((TM0305.@BSTS&BS_RUN)<>0), since the operator & is lower in priority
than the operators <> and ==.
7-26 IM 33G3C20-11E
7. Function Block Data
IM 33G3C20-11E 7-27
7.4.1 Checking Data Status
The built-in function “dscheck” is used to check the data status as shown in Figure 7.8.
<function block data>: Specifies the function block data for the check of its data status using
the format <function block>.#<data item name>. The tag name
and a simple variable array element for the local generic name and
formal argument are used to specify the function block.
<data status>: Specifies the data status using a character-string constant or variable.
The built-in function “dscheck” returns 1 when the data status is true, or 0 if it is false
— the return value is an integer.
EXAMPLE 1:
Checking PV data status of TAG002 block:
sebolblock example2
block PID TAG002
......
if (dscheck(TAG002.#PV,”CAL”) == 1) then
! Processing if status is CAL.
......
else
! Processing if status is not CAL.
......
end if
......
end
EXAMPLE 2:
Waiting until calibration status of FIC003 is cancelled, terminating CAL status of PV:
sebolblock example3
block PID FIC003
......
wait until (dscheck(FIC003.#PV,”CAL”) == 0)
......
end
7-28 IM 33G3C20-11E
7. Function Block Data
EXAMPLE 3:
Checking more than one data status using logical operator OR:
sebolblock example4
block PID FIC004
......
if (dscheck(TAG004.#PV,”CAL”) == 1
or dscheck(TAG004.#PV,”BAD”) == 1) then
! Processing if status is CAL or BAD.
......
end if
......
end
EXAMPLE 4:
Checking more than one data status using logical operator AND:
sebolblock example5
block PID TAG005
......
if (dscheck(TAG005.#PV,”CAL”) == 0
and dscheck(TAG005.#PV,”BAD”) == 1) then
! Processing if status is not CAL and is BAD.
......
end if
......
end
Logical operators OR and AND can be used together combining examples 3 and 4.
The manner of reading data and checking its data status at the same time is explained
below. The data is acquired using “#data item name” and stored in a long-type variable;
and specifying this long-type value to the built-in function “dscheck” checks the data
status.
<long-type variable>: Specifies the value of the long-type variable using the format
<function block>.#<data item name>. If a different variable is
specified, an erratic action will be caused when executed instead of an error.
<data status>: Specifies the data status using a character-string constant or variable.
IM 33G3C20-11E 7-29
Reading both data and data status using a group assignment statement permits the
reading of data and the checking of data status at the same time.
EXAMPLE:
Reading both PV and data status at the same time and instructing error processing if
status is BAD or using PV read to local variable “pvvalue” if status is not BAD:
sebolblock example6
block PID TAG006
long dstat
double pvvalue
......
[pvvalue,dstat = TAG006.PV,TAG006.#PV]
! Reading both data and data status.
if (dscheck(dstat,”BAD”) == 1) then
! Processing if status is BAD.
......
else
! Processing using “pvvalue.”
......
end if
......
end
7-30 IM 33G3C20-11E
7. Function Block Data
IM 33G3C20-11E 7-31
7.5 Alarm Status
Alarm status indicates the process alarm state that the function block has detected and it
can be referenced using the data item ALRM (alarm status). It cannot be changed by
setting data at ALRM, however.
SFC/SEBOL blocks permit to use a “prcsalarm” statement (see Chapter 9) to generate or
reset a process alarm and have the system change the data item ALRM.
There are other process alarm-related data items in addition to ALRM, which are AF
(alarm detection), AOFS (alarm suppression), and AFLS (alarm flashing). Many
function blocks, including SFC/SEBOL blocks, have these data items and they are used
to control process alarms.
7-32 IM 33G3C20-11E
7. Function Block Data
Table 7.21
For more details on the status change command character strings, refer to FCS Field
Control Station Function Manual (IM 33G3C10-11E). For more details on alarms
occurring in SFC blocks, refer to SFC Block Function Manual (IM 33G3C31-11E). For
more details on alarms occurring in SEBOL blocks, refer to SEBOL Block Function
Manual (IM 33G3C21-11E).
EXAMPLE:
Setting group alarm suppression for function block FIC001:
sebolblock example1
block PID FIC001
......
FIC001.AOFS = ”AOF” ! ”AOF” is status change instruction.
......
end
EXAMPLE:
Setting group alarm acknowledgement for SEBOL block:
sebolblock example2
block SEBOL SEBOL001
......
SEBOL001.AFLS = ”ACK” ! ”ACK” is status change instruction.
......
end
IM 33G3C20-11E 7-33
The system-fixed include file, salarm.h. is used to manipulate AF (alarm detection
specification) and AOFS (alarm masking specification). AFLS (alarm flashing status)
cannot be manipulated individually. salarm.h holds a definition of the labels used to
individually manipulate alarms in the following format of #define:
Figure 7.10
An example of controlling alarms that occur in a PID controller block is shown below.
EXAMPLE:
sebolblock sample1
#include "salarm.h"
end
7-34 IM 33G3C20-11E
7. Function Block Data
The method of individually manipulating alarms that occur in function blocks that
permit user definition of alarm status character strings is explained below. User-defined
alarm statuses are manipulated with status change command character strings in the
formats described in Table 7.22.
end
IM 33G3C20-11E 7-35
Figure 7.11 User-Defined Alarm Status Character String
Data items AF, AOFS, and AFLS each can be read as an 8-byte character string — to
know whether AF or AOFS has any group specification, or whether AFLS has unac-
knowledged flashing alarm. In states other than these, these data items are read as null-
character strings.
EXAMPLE:
sebolblock example3
block PID FIC001
char*4 strl
......
FIC001.AOFS = ”AOF” ! Sets group alarm suppression.
strl = FIC001.AOFS ! Sets ”AOF” to ”strl”.
......
FIC001.AOFS = ”AON” ! Cancels group alarm suppression.
strl = FIC001.AOFS ! Sets null-character string (””) to ”strl”.
......
end
7-36 IM 33G3C20-11E
7. Function Block Data
The correspondence between alarm statuses and bit numbers is explained below. The
leftmost bit number is 32; the rightmost one is 32 (see Figure 7.12). Alarm statuses,
such as OOP, IOP, and IOP-, are assigned to bits 9 to 32. Table 7.25 summarizes the
correspondence between the bit numbers and alarm statuses.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
1 0 (*1) 0 0
2 0 0 (*2) 0
3 0 0 0 (*3)
4 to 8 0 0 0 0
9 to 32 (*4) (*4) (*4) (*4)
AL_<alarm status>
Replace '+' in the alarm status with 'P,' '-' with 'M.'
Figure 7.13
IM 33G3C20-11E 7-37
EXAMPLE: salarm.h mask patterns (some)
......
#define AL_AFL $80000000 ! 1bit
#define AL_AOF $40000000 ! 2bit
#define AL_AF $20000000 ! 3bit
#define AL_NR $00800000 ! 9bit
#define AL_OOP $00400000 ! 10bit
#define AL_IOP $00200000 ! 11bit
#define AL_IOPM $00100000 ! 12bit IOP-
#define AL_HH $00080000 ! 13bit
#define AL_LL $00040000 ! 14bit
#define AL_HI $00008000 ! 17bit
#define AL_LO $00004000 ! 18bit
#define AL_DVP $00000800 ! 21bit DV+
#define AL_DVM $00000400 ! 22bit DV-
......
An example of using the include file, salarm.h, to individually reference alarms in a PID
controller block and a two-position motor control block (MC-2) follows.
EXAMPLE:
sebolblock sample3
#include "salarm.h"
7-38 IM 33G3C20-11E
7. Function Block Data
end
IM 33G3C20-11E 7-39
7.6 Sequence-Table Block
Sequence-table blocks (block model: ST16) in the same control area can be manipulated
for one-shot execution and periodic starts using SEBOL.
• One-shot execution and check can be performed in the MAN or AUT block mode and
the mode will not be changed.
• B- and I-type sequence-table blocks primarily execute user-defined initialization
processing when initial cold-starting or restarting the control station. These blocks
can also be specified for execution using one-shot execution statements; in this case,
however, the one-shot execution takes place when the statement is executed.
7-40 IM 33G3C20-11E
7. Function Block Data
<tag name>: Specifies the tag name of the sequence-table block. Local generic name and formal
argument blocks can also be specified.
<PV>: Specifies the step name of the step-type sequence table using a 2-byte-or-less
character-string constant or variable — the first 2 bytes are significant if the string has
more than 2 bytes.
<check result>: Specifies an integer local variable into which the result of the sequence table condition
check is set. With a nonstep sequence table, 1 is set if any one of the 32 rules is
satisfied, or 0 is set if none are satisfied. With a step sequence table, the rules in the step
with <execution step name> if it is specified (or with the current PV value in the sequence
table if <execution step name> is not specified) are checked. 1 is set if any one of these
rules in the specified step is satisfied, or 0 is set if none of the rules are satisfied.
<error variable>: Specifies the local variable that takes error codes. 0 is entered when no error is caused.
<label>: Specifies the branching destination when an error is caused.
<error identifier>: Specifies a constant or local variable for the identification of the location where an
error is caused.
With a step sequence table, the step to be run by one-shot execution (check) can be
specified in <execution step name>. When the “seqtable” statement is run, all the rules
in the step specified by <execution step name> and step 00 are run (checked). When
<execution step name> is specified, the PV value in the sequence table changes to
<execution step name> if oneshot is specified. With check specified, however, the
execution step specified is checked but the PV value does not change. If the step
specified by <execution step name> does not exist, a runtime error occurs and the
sequence table is not run (tested).
If a step sequence table is run without specifying <execution step name> (with oneshot
specified), the step with the current PV value in the sequence table and step 00 are run.
If a step sequence table is checked without specifying <execution step name> (with
check specified), only step 00 is checked.
With a nonstep sequence table, all the rules are run (checked). The specification of
<execution step name> in a nonstep sequence table is meaningless.
IM 33G3C20-11E 7-41
7.6.2 Periodic Start with One-Shot Execution
TC- and TE-type sequence-table blocks can be specified for one-shot execution that is
followed by a periodic start using the “seqtable drive” statement. The block is first
executed once when the statement is executed; the block mode is changed to AUT at the
same time. The block is then executed for a periodic start according to its own timing
for successive actions.
The “seqtable drivewait” statement instructs the specified block to wait until an SFC/
SEBOL return event message is output after the block has been started in a periodic
start. Instructions other than the wait instruction are the same as the “drive” statement.
<tag name>: Specifies the tag name of the sequence-table block. Local generic name
and formal argument blocks can also be specified.
<execution step name>: Specifies the step name of the step-type sequence table using a 2-byte-or-less
character-string constant or variable — the first 2 bytes are significant if the
string has more than 2 bytes.
<manipulated signal parameter>: Specifies a long-type local variable that takes the parameter (SFC/SEBOL
return event message, %RE) from the manipulated signal column of the
sequence table.
<error variable>: Specifies the local variable that takes error codes. 0 is entered
when no error is caused.
<label>: Specifies the branching destination when an error is caused.
<error identifier>: Specifies a constant or local variable for the identification of the location
where an error is caused.
• When a step name is specified for a step-type sequence-table block, the step is
changed to the specified step before one-shot execution, the specified step and “00”
steps are then executed once, and then a period start follows.
• If a non-existing step name is specified, an error is caused and the block is not
executed nor its mode is changed.
• If a step name is not specified, the step having the current PV of the block and “00”
steps are executed once and then a period start follows.
• If the block is non-step type, all rules are executed and any specified step name will
be ignored.
7-42 IM 33G3C20-11E
7. Function Block Data
• With the “drivewait” statement, the specified manipulated signal parameter is returned
when an SFC/SEBOL return event message is output. The parameter value ranges
from 0 to 65535, thus required a long-type local variable. (An integer-type variable
can only take values ranging from –32768 to 32767.)
• When the mode of the block started by the “drivewait” statement is changed to MAN
without outputting an SFC/SEBOL return event message, the statement will be
normally terminated returning –1 to the manipulated signal parameter. If the block
mode is changed to O/S, an error is caused when executed and the parameter remains
unchanged.
• The system changes the mode of the block started by the “drivewait” statement to
MAN when an SFC/SEBOL return event message is output. Also the system changes
the mode to MAN if the SFC/SEBOL block that started the sequence-table block
specified by the “drivewait” statement is forcibly terminated. Strictly speaking, the
mode is changed to MAN when the SFC/SEBOL block is forcibly terminated by a
block status change command if the mode is AUT and an SFC/SEBOL return event
message has not yet been output.
• If the sequence-table block outputs an SFC/SEBOL return event message when the
block has first been executed in one-shot execution, the block mode changes to MAN
and the periodic start will not be executed.
• An error is not caused when the block mode is AUT before the “seqtable” statement
is executed and the period start has already been executed — one-shot execution and
periodic starts will be executed normally.
IM 33G3C20-11E 7-43
7.6.3 Periodic Start without One-Shot Execution
When the mode of the TC- or TE-type sequence-table block is changed to AUT, the
successive sequence-table block will be periodic-started according to its own timing for
actions.
• A group assignment statement is used to start the block with error-checking. (See
7.2.1 for the description of the group assignment statement.)
• The sequence-table block is executed first in one-shot execution when the “seqtable
drive” statement is executed. If the block mode is changed to AUT, the successive
sequence-table block will be executed according to its own timing for actions.
• The starting of a sequence-table block by changing the block mode is used when not
starting the block with one-shot execution or when starting a sequence-table block in
another area.
7-44 IM 33G3C20-11E
7. Function Block Data
• One-shot execution and check can be performed in the MAN or AUT block mode and
the mode will not be changed.
• B- and I-type logic-chart blocks primarily execute user-defined initialization process-
ing when initial cold-starting or restarting the control station. These blocks can also
be specified for execution using one-shot execution statements; in this case, however,
the one-shot execution takes place when the statement is executed.
<tag name>: Specifies the tag name of the sequence-table block. Local generic name and formal
argument blocks can also be specified.
<error variable>: Specifies the local variable that takes error codes. 0 is entered when no error is caused.
<label>: Specifies the branching destination when an error is caused.
<error identifier>: Specifies a constant or local variable for the identification of the location where an
error is caused.
IM 33G3C20-11E 7-45
7.7.2 Periodic Start with One-Shot Execution
The TE-type logic-chart block can be specified for a periodic start using the “logicchart
drive” statement. The block is first executed once when the statement is executed; the
block mode is changed to AUT at the same time. The block is then executed for a
periodic start according to its own timing for successive actions.
The “logicchart drivewait” statement instructs the specified block to wait until an SFC/
SEBOL return event message is output after the block has been started in a periodic
start. Instructions other than the wait instruction are the same as the “drive” statement.
<tag name>: Specifies the tag name of the logic-chart block. Local generic name
and formal argument blocks can also be specified.
<manipulated signal parameter>: Specifies a long-type local variable that takes the parameter (SFC/SEBOL
return event message, %RE) from the manipulated signal column of the
logic chart.
<error variable>: Specifies the local variable that takes error codes. 0 is entered
when no error is caused.
<error identifier>: Specifies a constant or local variable for the identification of the location
where an error is caused.
• With the “drivewait” statement, the specified manipulated signal parameter is returned
when an SFC/SEBOL return event message is output. The parameter value ranges
from 0 to 65535, thus required a long-type local variable. (An integer-type variable
can only take values ranging from –32768 to 32767.)
• When the mode of the block started by the “drivewait” statement is changed to MAN
without outputting an SFC/SEBOL return event message, the statement will be
normally terminated returning –1 to the manipulated signal parameter. If the block
mode is changed to O/S, an error is caused when executed and the parameter remains
unchanged.
• The system changes the mode of the block started by the “drivewait” statement to
MAN when an SFC/SEBOL return event message is output. Also the system changes
the mode to MAN if the SFC/SEBOL block that started the logic-chart block speci-
fied by the “drivewait” statement is forcibly terminated. Strictly speaking, the mode
is changed to MAN when the SFC/SEBOL block is forcibly terminated by a block
status change command if the mode is AUT and an SFC/SEBOL return event mes-
sage has not yet been output.
• An error is not caused when the block mode is AUT before the “logicchart” statement
is executed and the period start has already been executed — one-shot execution and
periodic starts will be executed normally.
7-46 IM 33G3C20-11E
7. Function Block Data
• A group assignment statement is used to start the block with error-checking. (See 7.2
for the description of the group assignment statement.)
• The logic-chart block is executed first in one-shot execution when the “logicchart
drive” statement is executed. If the block mode is changed to AUT, the successive
logic-chart block will be executed according to its own timing for actions.
• The starting of a logic-chart block by changing the block mode is used when not
starting the block with one-shot execution or when starting a logic-chart block in
another area.
IM 33G3C20-11E 7-47
7.8 Process I/O and Software I/O
Tag names cannot be used with process I/O and software I/O. Terminal numbers are
used to access process I/O and element numbers are used to access software I/O.
See Table 7.28 for the details of process I/O terminal numbers.
7-48 IM 33G3C20-11E
7. Function Block Data
IM 33G3C20-11E 7-49
7.8.2 Software I/O Element Numbers
Software I/O element numbers are expressed as shown in Figure 7.21.
The software I/O that can be accessed using SEBOL are listed in Table 7.29 — others
cannot be accessed. (Add leading zeros to numbers, matching their numbers of digits as
shown in the table.)
7-50 IM 33G3C20-11E
7. Function Block Data
There are differences between the two formats used for global switches, %GSnnnmm
and %GSnnnmmSddss. The %GSnnnmm format permits to access the global switch
image of the present station, which is updated by the global switch under control of
another specified station (mm). The %GSnnnmmSddss format permits to access the
global switch image of the control station, which has the specified domain number (dd)
and station number (ss) and is updated by the global switch under control of another
specified station (mm).
Thus, when %GSnnnmm is used, the data of the present station are accessed even when
another station (mm) is the control station. And when %GSnnnmmSddss is used, the
data of another station are accessed unless the domain number (dd) and station number
(ss) specify the present station.
Data cannot be written to the global switch image of another station using the
%GSnnnmm format — an error is caused if “mm” specifies another station. Data can
be written to the global switch image using the %GSnnnmmSddss format if station
numbers “mm” and “ss are the same — an error is caused if they are not.
Common switches %SW0001 to %SW0099 are reserved elements for use by the system
in identifying start actions of the control station. They can be referenced and their
setting is restricted.
*1 As the register position aaaa, 0001 to 0512 are associated with the receive register numbers 001 to 512,
0513 to 1024, with the send register numbers 001 to 512.
IM 33G3C20-11E 7-51
7.8.4 Declaration
When process I/O or software I/O is used with a “block” or “genname” statement, the
identifiers listed in Table 7.31 are used in place of the block name.
EXAMPLE:
Declaring common switch having tag name SWITCH01:
sebolblock example
block %SW SWITCH01
integer i
......
i = SWITCH01.PV
......
end
7-52 IM 33G3C20-11E
7. Function Block Data
<tag name>.PV16
<local generic name>.PV16
<formal argument function block>.PV16
<terminal number>.PV16
<element number>.PV16
Note: An array or array elements can also be used for local generic names or formal
argument function blocks.
EXAMPLE: %SW0007.PV16
High-order bits Low-order bits
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
Bits 1 to 16: 0
Bit 17: %SW0007.PV
Bit 18: %SW0008.PV
Bit 19: %SW0009.PV
. .
. .
Bit 30: %SW0020.PV
Bit 31: %SW0021.PV
Bit 32: %SW0022.PV
IM 33G3C20-11E 7-53
Zero is entered to the PV16 bit if it has no data. For example, process I/O use terminal
numbers 1 through 32 and thus %Z075129.PV16 (node 7, unit 5, slot 1, terminal 29)
assigns process values at terminal numbers 29, 30, 31, and 32 to bits 17 through 20,
entering 0 to the remaining 12 low-order bits. See Figure 7.24.
EXAMPLE: %Z075129.PV16
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
Bits 1 to 16: 0
Bit 17: %Z075129.PV
Bit 18: %Z075130.PV
Bit 19: %Z075131.PV
Bit 20: %Z075132.PV
Bit 21: 0
Bit 22: 0
.
.
Bit 31: 0
Bit 32: 0
EXAMPLE:
Process value input using PV16:
sebolblock example1
block %SW SW0001
long z1,zdata[3]
......
z1 = %SW0001.PV16
[zdata[*] = %SW0017.PV16,%SW0033.PV16,%SW0049.PV16]
......
end
7-54 IM 33G3C20-11E
7. Function Block Data
When PV16 data are assigned to a long-type variable, zeros are set at the 16 high-order
bits. An overflow is caused if PV16 data are assigned to an integer-type variable and
the process value of the specified 17-bit-compatible process I/O or software I/O is 1.
EXAMPLE:
When %SW0101 PV is 1 and %SW0102 to %SW0116 PVs are 0:
sebolblock example2
block %SW SW0101
integer int1
long lng1
......
lng1 = %SW0101.PV16 ! lng1 16 high-order bits are zeros.
! $00008000 assigned to lng1.
......
int1 = %SW0101.PV16 ! Causes an overflow.
! $00008000=32768 is out of range for integer-type
variable.
......
end
To assign a long-type value to PV16, set the high-order 16 bits to 0. To assign an
integer-type negative value (the MSB being 1) to PV16, set the high-order 16 bits to 0
by masking with $0000FFFF as well.
EXAMPLE:
sebolblock example3
block %SW SW0101
long lngl
integer intl
! A set variable is assumed to have been set in the low-order 16 bits of lng1.
! Set the high-order 16 bits to 0.
%SW101.PV16 = lngl & $0000FFFF
.....
! A set variable is assumed to have been set in the 16 bits of int1.
! The result of int1&$0000FFFF is a long-type value with the high-order 16 bits
! being 0.
%SW0101.PV16 = intl & $0000FFFF
end
Data can be assigned to the data item PV16 in process I/O (%Z, %Y) only if all the 16
pins associated with PV16 have been defined in the SO or PO operation mode.
IM 33G3C20-11E 7-55
7.9 Timer Block
The timer block is a function block that measures time in seconds or minutes and has
the block model of TM. In addition to the measuring of elapsed time, it permits a user-
defined action when a specified time has elapsed, such as changing the SFC/SEBOL
block mode or status and signal transmission to an SFC block.
SEBOL does not have a timer function although its “delay” and “delaycycle” functions
can delay the timer. Thus the timer block must be used to generate actions periodically
or after a specified time has elapsed. The timer block can be started or stopped using
SEBOL. Referencing the block status identifies the status of the timer block.
Referecing the timer block process value informs the elapsed time. Data item names
used for these purposes are shown in Table 7.32.
For the details of the timer block, see the FCS Field Control Station Function Manual
(IM 33G3C10-11E).
The timer block can be manipulated using an assignment statement or a group assign-
ment statement to set an integer to the timer block data item OP — see Table 7.33 and
the example below.
Integer Description
1 Stops the timer.
2 Starts the timer.
3 Restarts the timer.
4 Stops the timer temporarily.
EXAMPLE:
sebolblock example
#include ”std.h ” ! The label TM**** is defined in std.h
block TM TIM0001
TIM0001.OP = TMSTAT ! Starts the timer block
.....
TIM0001.OP = TMPAUS ! Pauses the timer block
.....
TIM0001.OP = TMCONT ! Restarts the timer block
.....
TIM0001.OP = TMSTOP ! Stops the timer block
end
7-56 IM 33G3C20-11E
7. Function Block Data
oneshot<function block>[,<parameter>]
[;<error variable>][; error <label>[,<error identifier>]]
errorsub
<function block>: Specifies a function block using the declared tag name (block statement), local
generic name (genname statement), or generic name (unit genname statement).
<parameter>: Specifies a parameter using a numeric constant or variable. 0 is set when omitted.
<error variable>: Specifies a local variable at which an error code will be set. 0 is set when no errors
are caused.
<label>: Specifies the branching destination when an error is caused.
<error identifier>: Specifies a constant or local variable for the identification of the location where an
error is caused.
See Section 10.1 for further description of “error variable,” “label,” and “error identi-
fier.”
For a list of the function blocks that can be specified using the oneshot statement, see
Table 7.34. The following rules apply in specifying function blocks:
• A function block without the parameter specification will be ignored if a parameter is
specified.
• A sequence table cannot be specified in the oneshot statement. The seqtable oneshot
statement must be used.
• A logic chart cannot be specified in the oneshot statement. The logicchart oneshot
statement must be used.
Two examples of oneshot execution of software counter blocks using the oneshot
statement are shown below:
EXAMPLE 1: Counter update operation
Setting the parameter at 1 in the statement and executing the specified software counter
block updates the counter incrementing the block’s count (data item: PV) by 1.
sebolblock example1
block CTS CTS003
.....
oneshot CTS003,1 !Parameter “1” updates the counter.
.....
end
This example brings the same result as the execution of “CTS003.ACT.ON …… Y” in the
action signal column of a sequence table.
IM 33G3C20-11E 7-57
EXAMPLE 2: Counter stopping operation
Setting the parameter at 0 in the statement and executing the specified software counter
block stops the counter changing the block status (data item: BSTS) to STOP.
sebolblock example2
block CTS CTS003
.....
oneshot CTS003,0 !Parameter “0” stops the counter.
.....
end
……
This example brings the same result as the execution of “CTS003.ACT.OFF Y” in
the action signal column of a sequence table.
7-58 IM 33G3C20-11E
7. Function Block Data
BDA-C Batch data acquisition block (character string data only) 0~17 (Note 3)
Notes:
*1: Software-counter-block parameters and operations are shown in Table 7.35. For the description of the
operations, see IM 33G3C10-11E, FCS Control Station Function Manual.
Parameter Operation
1 Updates the counter.
0 Stops the counter.
IM 33G3C20-11E 7-59
*2: Batch-data-set-block parameters and operations are shown in Table 7.36. For the description of the
operations, see IM 33G3C10-11E, FCS Control Station Function Manual.
Parameter Operation
0 Sets all current set data at 0.
1~16 Sets specified current set data (DTnn).
17 Sets all current set data.
*3: Batch data acquisition-block parameters and operations are shown in Table 7.37. For the description of
the operations, see IM 33G3C10-11E, FCS Control Station Function Manual.
Parameter Operation
0 Sets all acquired data at 0.
1~16 Acquires specified data (DTmm).
17 Acquires all data.
7-60 IM 33G3C20-11E
8. Program Control Statements
(1) if (<expression>)<statement>
(2) if (<expression>) then
......
[else
......]
end if
(3) if (<expression>) then
......
else if (<expression>) then
[else
......]
end if
IM 33G3C20-11E 8-1
• In format (1), the expression is calculated and then, if the result is true, the statement
is executed.
• In format (2), the expression is calculated and then, if the result is true, the statement
entered between “then” and “else” is executed. If the statement is evaluated false, the
“else” clause is executed if an “else” clause is present.
• In format (3), two expressions are successively evaluated and then, if the result of
either one of the two expressions is true, the statement following the “then” for that
expression is executed. If both expressions are evaluated false, the “else” clause is
executed if an “else” clause is present.
• Branching out of an “if” statement can be instructed using a “goto” statement in the
“if~end if” construct, but branching into an “if” statement is not permitted.
EXAMPLE:
Judging local variable A:
integer function FUNC(A,MSG)
integer A,B
......
B = 0
if (A == 0) then
MSG = ”RUN”
else if (A == 1) then
MSG = ”STOP”
else
MSG = ”ERROR”
B = 1
end if
......
return B
......
end
EXAMPLE:
Changing setpoint values and generating message:
sebolblock example
block CT CT001
block PID SC001
......
if (CT001.PV == 1) then
[SC001.MODE.SV = ”AUT”,10] ! Change to low-speed.
else if (CT001.PV == 2) then
[SC001.MODE.SV = ”AUT”,50] ! Change to mid-speed.
else if (CT001.PV == 3) then
[SC001.MODE.SV = ”AUT”,100] ! Change to high-speed.
else
opeguide ”%aRPM SETTING ABNORMAL”,1 ! Message (red).
[SC001.MODE.SV = ”AUT”,10] ! Change to low-speed.
end if
......
end
8-2 IM 33G3C20-11E
8. Program Control Statements
A “for” statement repeats execution of the specified condition in a loop — with a delay
of one scan period imposed following every “for…next” loop process. The delay can be
cancelled using “next@” instead of “next” at the end of the statement — then the loop is
repeatedly executed without interruptions.
• The <variable> in the “for” statement is first set to the <initial value>. The state-
ments intervening between the “for” statement and the associated “next” statement are
run if the <increment> is positive and the <initial value> is less than or equal to the
<final value> or if the <increment> is negative and the <initial value> is greater than
or equal to the <final value>. The value of the <variable> is incremented or
decremented by the statement specified by the <increment> Next, the <variable> and
the <final value> are compared. If the sign of the difference remains unchanged since
the last comparison, control returns to the statement next to the “for” statement to
iterate the same operation. The <final value> and the <increment> are calculated
once before the starts of the iteration. The <final value> and the <increment> thus
calculated are used until control exits from the loop, instead of being recalculated for
each iteration.
• If the type of the initial value, increment, or final value is not the same as the type of
the variable, the former type is converted to the latter type before operation.
The “for” statement is not at all executed if the increment is positive and the initial
value is larger than the final value, or the increment is negative and the initial value is
smaller than the final value.
• If the increment value has a decimal point, the final value may not be executed
because of an error caused in the real-number operation.
• The “for” statement can have a nest construct. When a “for~next” loop is nested
inside another “for” statement, the “next” of the nested loop must associate with its
own “for,” or the nearest preceding “for.” Every “for” statement must be concluded
with a “next” of its own.
• Branching out of a “for” statement can be instructed using a “goto” statement in the
“for~next” loop, but branching into a “for” statement is not permitted, which instabili-
ties actions.
IM 33G3C20-11E 8-3
EXAMPLE:
Function to get SM by repeating the loop N-times:
integer function SUM(N)
integer N,I,SM
......
SM = 0
for I = 1 to N step 1
SM = SM + 1
next@
return SM
......
end
EXAMPLE:
Clearing data of local variable buffer IBUFF:
sebolblock example1
integer IBUFF[50]
integer i
......
for i = 1 to 50 ! Cleared in ascending order.
IBUFF[i] = 0
next@
......
......
for i = 50 to 1 step –1 ! Cleared in descending order.
IBUFF[i] = 0
next@
......
end
8-4 IM 33G3C20-11E
8. Program Control Statements
A “while” statement repeats execution of the specified condition in a loop if the expres-
sion in the statement is evaluated true. A delay of one scan period is imposed following
every “while…wend” loop process. The delay can be cancelled using “wend@” instead
of “wend” at the end of the statement — then the loop is repeatedly executed without
interruptions. The execution of the loop ends when the expression is evaluated false.
• If the initial evaluation of the expression is false, the “while” statement is not at all
executed.
• The “while” statement can have a nest construct. When a “while~wend” loop is
nested inside another “while” statement, the “wend” of the nested loop must associate
with its own “while,” or the nearest preceding “while.” Every “while” statement must
be concluded with a “wend” of its own.
• Branching out of a “while” statement can be instructed using a “goto” statement in
the “while~wend” loop, but branching into a “while” statement is not permitted.
EXAMPLE:
Function to add 1 to SM as long as N is larger than 0:
integer function SUM1(N)
integer N,SM
......
SM = 0
while (N>0)
SM = SM + 1
N = N – 1
wend@
return SM
......
end
IM 33G3C20-11E 8-5
EXAMPLE:
Terminating control when flow rate becomes abnormal before multiplication of FC001 is
completed:
sebolblock example
block BSETU-2 FC001
......
while (FC001.SUM < FC001.BSET)
if (FC001.ALRM <> ”NR”) then
[FC001.SW = 3]
%.BSTS = ”STOP” ! % is present block.
end if
wend
......
end
8-6 IM 33G3C20-11E
8. Program Control Statements
(2) repeat
......
until@ (<expression>)
A “repeat” statement repeats execution of the specified condition in a loop as long as the
expression in the statement is evaluated false. A delay of one scan period is imposed
following every “repeat~until” loop process. The delay can be cancelled using “until@”
instead of “until” at the end of the statement — then the loop is repeatedly executed
without interruptions. The loop condition is evaluated at the end of the loop and thus
the loop is executed at least once for the purpose of the evaluation. The execution of
the loop ends when the expression is evaluated true, and the control is passed to the next
line following “until.”
• The “repeat” statement can have a nest construct. When a “repeat~until” loop is
nested inside another “repeat” statement, the “until” of the nested loop must associate
with its own “until,” or the nearest preceding “until.” Every “repeat” statement must
be concluded with an “until” of its own.
• Branching out of a “repeat” statement can be instructed using a “goto” statement in
the “repeat~until” loop, but branching into a “repeat” statement is not permitted.
EXAMPLE:
Function to add N to SM until N exceeds 0:
integer function SUM2(N)
integer N,SM
......
SM = 0
repeat
SM = SM + 1
N = N – 1
until@ (N<=0)
return SM
......
end
IM 33G3C20-11E 8-7
EXAMPLE:
Terminating control when flow rate becomes abnormal before multiplication of FC002 is
completed:
sebolblock example
block BSETU-2 FC002
......
repeat
if (FC002.ALRM <> ”NR”) then
[FC002.SW = 3]
end if
until (FC002.SUM < FC002.BSET)
......
end
8-8 IM 33G3C20-11E
8. Program Control Statements
A “wait until” statement checks the specified condition until the expression is the
statement is evaluated true. The check is executed just once in one scan period. The
control is passed to the next line when the expression is evaluated true.
• The time option specifies the maximum duration of the check. The <error label>,
<label>, and <error identifier> specify what action should be taken when the condi-
tion is false or when errors occur. If the time option is omitted, the system continues
to wait until the condition becomes true.
• “wait until” statement can not be used in the function referenced in the condition test
formula called by a “wait until” statement. Otherwise, error may occur. The function
referenced in the condition test formula called by a “wait until” statement subjects the
following constraints.
• “delay” and “delaycycle” statement can not be used. “drive” statement can not
direct to a function block in different station.
• “time” parameter can not be applied to “dialogue” or “compare” statement.
IM 33G3C20-11E 8-9
EXAMPLE:
Waiting 30 seconds for TIC001 PV to exceed 50:
sebolblock HEAT
block PID TIC001
......
TIC001.MODE = ”AUT”
TIC001.SV = 60.0
......
wait until (TIC001.PV > 50);time 30,error LBL1
......
exit
LBL1:
......
end
EXAMPLE:
Operating mixer MX1 for 60 seconds:
sebolblock KAKUHAN
block SIO-11 MX1
block TM TM001
#define START 2
#define STOP 0
......
drive [MX1 = START];errorsub DRVERR
......
TM001.PH = 60
TM001.OP = 2 ! Timer start.
wait until (TM001.ALRM == ”CTUP”)
TM001.OP = 1 ! Timer stop.
......
drive [MX1 = STOP];errorsub DRVERR
......
exit
......
DRVERR:
opeguide ”MIXER OPERATION ABNORMAL.”
KAKUHAN.BSTS = ”STOP”
......
end
8-10 IM 33G3C20-11E
8. Program Control Statements
switch (<expression>)
case <constant>[,<constant>…:
......
[case <constant>[,<constant>…]:
[otherwise:
......
]]
end switch
A “switch” statement checks whether its expression satisfies one of the constants in the
“case” clause and then the control is branched according to the evaluation.
• The expression is calculated first and then the result is compared with constants of the
“case” clause when the “switch” statement is executed. If the result of the expression
equals one of the constants, the statement following the “case” clause is executed. If
the result does not equal any of the constants, the “otherwise” clause is executed. If
an “otherwise” clause is not present, none of statements placed between “switch” and
“end switch” are executed.
• When processing following a “case” or “otherwise” clause is completed, the control is
passed to the next line following “end switch.”
• Branching out of a “switch” statement can be instructed using a “goto” statement in
the “switch…end switch” construct, but branching into a “switch” statement is not
permitted.
IM 33G3C20-11E 8-11
EXAMPLE:
Branching according to local variable A:
integer function FUNC1 (A,MSG)
integer A,B
char*10 MSG
......
B = 0
switch(A)
case 0:
MSG = ”RUN”
case 1:
MSG = ”STOP”
B = 0
otherwise:
MSG = ”ERROR”
B = 1
end switch
......
return B
......
end
8-12 IM 33G3C20-11E
8. Program Control Statements
EXAMPLE:
Generating operator guide message according to error variable:
sebolblock KAKUHAN
block SIO-11 V01,P01,MX1
#define OPEN 2
#define START 2
integer ERR
char*12 MSG
......
drive [V01 = OPEN];errorsub DRVERR,1
......
drive [P01 = START];errorsub DRVERR,2
......
drive [MX1 = START];errorsub DRVERR,3
......
exit
......
DRVERR:
ERR = lerroid()
switch(ERR)
case 1:
MSG = ”VALVE”
case 2:
MSG = ”PUMP”
case 3:
MSG = ”MIXER”
otherwise:
MSG = ”SWITCH INSTRUMENT”
end switch
opeguide ”%a%s NOT OPERABLE.”,1,MSG
ereturn
end
IM 33G3C20-11E 8-13
8.7 “goto” Statement
goto <label>
A “goto” statement executes unconditional branching to the line with the specified label.
• A compile error is caused if the specified label is not present in the program.
EXAMPLE:
Function of branching to NML and RTN:
function SUB(A,MSG)
integer A,B
char*10 MSG
......
if (A == 0) then
MSG = ”RUN”
goto NML
else if (A == 1) then
MSG = ”STOP”
goto NML
else
MSG = ”ERROR”
end if
B = 1
goto RTN
......
NML:
B = 0
RTN:
return B
......
end
8-14 IM 33G3C20-11E
8. Program Control Statements
EXAMPLE:
Branching to LBL1 when temperature controller TIC5 PV is less than 50.0:
sebolblock ONCHOU
block PID TIC5
block TM TM001
......
[TIC5.MODE.SV = ”AUT”,60.0]
[TM001.PH.OP = 90,2]
wait until (TM001.ALRM == ”CTUP”)
TM001.OP = 1
......
if (TIC5.PV < 50.0) goto LBL1
......
exit
......
LBL1:
opeguide ”%a LOW INTERNAL TEMPERATURE.”,3
%.BSTS = ”STOP” ! % is present block.
......
end
IM 33G3C20-11E 8-15
8.8 “delay” Statement
delay <delay period>
<delay period>: Specifies the period of time to be delayed in milli-seconds using an integer
real-number or variable.
A “delay” statement causes a delay in processing the program for a period of time
specified in milli-seconds. The precision of the delayed time is dependent on the basic
scan period.
EXAMPLE:
Delaying 200 seconds after setting FIC001 SV:
sebolblock sample6
block PID FIC001
......
FIC001.SV = 10
delay 200000
......
end
EXAMPLE:
Waiting until FIQC1 batch ends:
sebolblock SIKOMI
block BSETU-2 FIQC1
......
FIQC1.BSET = 100.0
[FIQC1.MODE.SV = ”AUT”,1]
delay 1000
wait until (FIQC1.ZONE == 7 or FIQC1.ZONE == 0)
......
end
8-16 IM 33G3C20-11E
8. Program Control Statements
<number of cycles>: Specifies the number of basic scan periods to be delayed using
an integer real-number or variable.
IM 33G3C20-11E 8-17
9. Message Statements
9. Message Statements
SEBOL uses eight statements that control the generation of messages, which are
outlined below and described in detail later in this chapter.
IM 33G3C20-11E 9-1
Message statements are expressed as shown in Table 9.1.
Character string (*11) 128 bytes max (*4) Effective (*10) Effective Effective
“opeguide” White
Element number Fixed (*7) … … … …
Character string (*11) 192 bytes max (*5) Effective (*10) Effective Effective
“dialogue” White
Element number Fixed (*7) … … … …
“sysalarm” Character string (*11) 128 bytes max (*8) White Effective (*6) (*10) Effective Effective
“prcsalarm” Character string (*9) 8 bytes max White Not allowed (*9) (*6) (*10) … …
• The message statements other than “snapshot” are transmitted to the control station at
which the SFC/SEBOL block that has executed them and to all the operation and
monitoring functions in the same operation group. To which operation and monitor-
ing station in the system the messages are output is determined to the builder defini-
tion.
See the following pages for details of each message statement and the formatting string.
9-2 IM 33G3C20-11E
9. Message Statements
• The message of a specified character string can be displayed in a color other than the
default white using the “%a” specification in the formatting statement. (See 9.9 for
details.)
• Up to 70 bytes can be displayed in one line in the operator guide panel and any
excessive bytes are shown in the second line. Up to 128 bytes can be printed or
stored in the historical file.
• If a color other than the default white is specified, which uses 6 bytes, the information
is not included in the number of bytes displayed, but it is included in the number of
bytes printed or stored.
• To which operation and monitoring station in the system the message is sent is
determined according to the operation group definition.
EXAMPLE:
Message output using formatting statement:
sebolblock example1
#define WHITE 7
#define GREEN 2
integer temp ! Local variable to maintain temperature.
......
* Displaying the temperature part in green and the rest in white.
opeguide ”CURRENT TEMPERATURE IS
%a%d%a DEGREES.”,GREEN,temp,WHITE
......
end
EXAMPLE:
Outputting %OG0001 of present control station:
sebolblock example2
......
opeguide OG,1
......
end
IM 33G3C20-11E 9-3
9.2 “dialogue” Statement
A “dialogue” statement specifies an interactive operation using a dialogue window of the
operation and monitoring function. The statement takes different forms according to the
three message types as shown in Figure 9.2.
<dialogue name>: Specifies a dialogue name using a character constant or variable of up to 8 bytes
— eight asterisks are entered if omitted.
<formatting string>: See 9.8 for details.
<output data>: Specifies up to eight integer expressions or character strings to be output.
<element number>: Specifies the message element number (“nnnn” in “%OGnnnn”) using an integer
expression (1 through 9999).
<prompt string>: Specifies an input prompting message using a character constant or variable of
up to 32 bytes.
<retry string>: Specifies a reentry prompting message using a character constant or variable of
up to 32 bytes.
<input variable>: Specifies a local variable to which entered data are stored using an integer, or
characters of up to 32 bytes.
<wait time>: Specifies a maximum waiting period in seconds using an integer constant or
local variable.
<error variable>: Specifies a local variable that takes error codes. 0 is entered when no error is
caused.
<label>: Specifies the branching destination when an error is caused.
<error identifier>: Specifies a constant or local variable for the identification of the location where
an error is caused in the error-handling phase.
9-4 IM 33G3C20-11E
9. Message Statements
• The data-entry “dialogue” statement calls the dialogue window and permits the
operator an entry operation when he touches the dialogue softkey in the window. The
SFC/SEBOL block suspends processing until the operator makes an entry and it is
assigned to the input variable in the “dialogue” statement — then the block exits the
statement to resume execution with the next line.
• The acknowledgement “dialogue” statement permits the operator to make an
acknowledgement using the “confirm” softkey.
• The reentry “dialogue” statement makes effective again the message the SFC/SEBOL
block previously generated on the operator guide panel. The reentry message can be
printed and is stored in the historical file.
• When the dialog message is a reentry type interactive message, the input variable of
the reentry type dialogue statement must also be numeric if the input variable of the
last executed reentry type dialogue statement is numeric, or it must be a character
string if the input variable of the last executed reentry type dialogue statement is a
character string. Mismatched input variable types would cause a runtime error to
occur during execution of a reentry type dialogue statement.
• The dialogue name is displayed on the tuning and other panels of the SFC/SEBOL
block.
• For data entry type and confirmation operation type interactive messages, the operator
guide message in any character string or with any element number displays in the
interactive message panel. Any character string can be displayed in a length up to 70
bytes per line onscreen and on up to seven lines in the dialog window. The length of
the character string may not exceed 192 bytes. The prompt character string is neither
stored in the historical file nor printed.
• When specifying “wait time,” it is necessary to consider the case of when all opera-
tion and monitoring stations in the operation group of the control station are not being
operated. The specification may be omitted to effect infinite waiting, or should be
ample enough to take up the time required for the startup of an operation and moni-
toring station. (An error is caused when the specified time period is up.)
• When the error identifier is specified, the identifier can be referenced using a built-in
function in the error-handling phase. Available built-in functions are integer-type
“lerrorid(),” real number-type “derrorid(),” and character-type “cerrorid().” See
Chapter 10 for the detail of error-handling.
• To which operation and monitoring station in the system the message is sent is
determined according to the operation group definition. That is that the message is
transmitted to all operation and monitoring stations that belong to the same operation
group as the control station executing the SFC/SEBOL block.
IM 33G3C20-11E 9-5
EXAMPLE 1:
Data-entry and reentry diaglogues:
sebolblock example2
block PID FIC001
long setvalue
......
dialogue ”MSG001”;”ENTER SETPOINT.”\
;”SETPOINT=”,setvalue;time 120,error LBL2
while (setvalue<50 or setvalue>100)
dialogue ”RANGE ERROR. REENTER.”\
;retry setvalue;time 120,error LBL2
wend
......
FIC001.SV = setvalue ! Assigning entered value to SV.
......
exit
......
LBL2:
* Error-processing defined for no entry.
end
In the above example, the message “ENTER SETPOINT.” is output to the message
panel and window. And if the data entered in the window is out of the 50-100 range,
the message “RANGE ERROR. REENTER.” is output.
EXAMPLE 2:
Acknowledgement dialogue:
sebolblock example3
......
dialogue ”MSG002”;”CATALYST CHARGED?”\
;confirm;time 120;error LBL2
......
exit
......
LBL2:
* Error-processing defined for no acknowledgement.
end
In the above example, the processing is suspended until the “confirm” softkey is pressed
in response to the message “CATALYST CHARGED?”.
9-6 IM 33G3C20-11E
9. Message Statements
IM 33G3C20-11E 9-7
9.4 “history” Statement
9-8 IM 33G3C20-11E
9. Message Statements
IM 33G3C20-11E 9-9
9.6 “sysalarm” Statement
A “sysalarm” statement specifies system-alarm message strings to be generated for the
present station when an alarm has occurred in the system and when the normal condition
is recovered.
• The message mark in the system alarm message panel changes to red when the alarm
message is generated and green when the recovery message is generated.
• Up to 76 bytes can be displayed in one line in the system alarm message panel and
any excessive bytes are shown in the second line. In the message window, however,
only up to 58 bytes can be displayed. Up to 128 bytes can be printed or stored in the
historical file.
• The destination of the message transmission is determined according to the operation
group definition.
EXAMPLE:
Outputting system alarm and recover messages:
sebolblock example5
block PVI T100
......
if (T100.ALRM == ”IOP”) then
sysalarm ”T100 THERMOMETER IS OUT OF ORDER.”
end if
......
if (T100.ALRM <> ”IOP”) then
sysalarm recover ”T100 THERMOMETER NORMALIZED.”
end if
......
end
In this example, the message ”T100 THERMOMETER OUT OF ORDER.” is generated
when the status of T100 has changed to IOP and the message ”T100 THERMOMETER
NORMALIZED.” when the normal condition is recovered.
9-10 IM 33G3C20-11E
9. Message Statements
<alarm status string>: Specifies a character string to be generated using a constant or variable.
The string can use up to 8 bytes.
• The “prcsalarm” statement outputs a process alarm occurrence message in the <alarm
status character string> specified, with an alarm in the alarm status (data item ALRM)
occurring. No process alarm occurrence message is output if the alarm already exists.
• The “prcsalarm” statement with recover specified outputs a process alarm recovery
message in the <alarm status character string> specified, with an alarm in the alarm
status (data item ALRM) being cleared. No process alarm recovery message is output
if the alarm does not exist. If an alarm status character string is not specified, all the
alarms existing in the SFC/SEBOL block are cleared, with a process alarm recovery
message being output for each alarm cleared. When all the alarms existing in the
SFC/SEBOL block are cleared by executing the recovery specification of the
“prcsalarm” statement, a process alarm clear message with the alarm status name NR
is output.
• An <alarm status character string> is a user-defined character string defined with the
builder. Up to 23 alarm status character strings can be defined, each consisting of a
user-defined character string of NR (normal status NoRmal).
• Users can define one alarm status character string for use in SEBOL blocks (*1) and
specify one alarm status character string for use in the SFC blocks (*2) for each
model name involved. A runtime error would occur if an alarm status character string
not defined with the builder is specified as a parameter of the “prcsalarm” statement.
*1: SEBOL block alarm status character strings are defined at USER10.
*2: SFC block alarm status character strings are default-set at USER10.
• Process alarm occurrence and clear messages occurring in SEBOL blocks have the
value of the data item LINE, as of the time of their occurrence, appended to them as
data (*3). Those occurring in SFC blocks have the value of the data item STEPNO,
as of the time of their occurrence, appended to them as data.
*3: When repeated warning alarm messages occur, the value of the data item LINE or STEPNO, as of the
time of their occurrence, is appended to them, not the line or step number in which the “prcsalarm”
statement is executed.
IM 33G3C20-11E 9-11
• Each SFC/SEBOL block can output only one process alarm message in one basic
scan period. If an attempt is made to output two process alarm messages in one basic
scan period, the SFC/SEBOL block would be delayed by one period. The second
“prcsalarm” (or “prcsalarm recover”) statement is executed in the next scan period.
• Each time an SFC/SEBOL block is run, the alarm status ALRM is reset to NR. Any
process alarm left over from the last run of the SFC/SEBOL block is cleared by the
system with a process alarm clear message being output.
• A repeated warning alarm message can be output according to the builder definition
when SFC/SEBOL blocks are kept running for longer than a predetermined period of
time without running a “prcsalarm recover” statement to clear the process alarm
message output by a “prcsalarm” statement. Only SFC/SEBOL blocks in the running
state (block status RUN or PAUS) are subject to repeated warning alarm message
output. No repeated warning alarm message is output even if the SFC/SEBOL block
stops running (block status STOP or ABRT) without clearing the existing process
alarm message. SFC/SEBOL blocks are similar to other function blocks except that
they are subject to repeated warning alarm message output while in the running state.
• SFC/SEBOL blocks have the data items, AF (alarm detection specification) and
AOFS (alarm masking specification). The process alarm messages that are output by
the “prcsalarm” statement are governed by the specification of these two data items.
Figures 9.8 and 9.9 show the flows of generating and clearing process alarms in SFC/
SEBOL blocks, respectively.
• SFC/SEBOL blocks have the data item, AFLS (alarm flashing status). Since the
correspondence between the alarm flashing action of SFC/SEBOL blocks and alarm
flashing status in the implementation of the operation and monitoring functions, refer
to FCS Field Control Station Function Manual (IM 33G3C10-11E) for a description
of alarm handling. For more details on alarms occurring in SFC/SEBOL blocks, refer
to SFC Block Function Manual (IM 33G3C31-11E) and SEBOL Block Function
Manual (IM 33G3C21-11E). For how to reference and alter alarm data items, see
Section 7.5, “Alarm Statuses.”
9-12 IM 33G3C20-11E
9. Message Statements
Yes
Alarm detection group by-pass
specified (AF)
No
No
Alarm group suppression
specified (AOFS)
Yes
Yes
Alarm has occurred
No
End
IM 33G3C20-11E 9-13
“prcsalarm recover” statement executed
Yes
Alarm detection group by-pass
specified (AF)
No
No
Alarm group suppression
specified (AOFS)
Yes
No
Alarm has occurred
Yes
Alarm is reset
No
Alarm is cleared
Yes
End
9-14 IM 33G3C20-11E
9. Message Statements
EXAMPLE:
Output of one process-alarm and recovery messages:
sebolblock example1
......
* No alarm is assumed at this moment.
prcsalarm “HIGH” ! Output of alarm message “HIGH.”
......
prcsalarm recover “HIGH” ! Output of two messages informing
! alarm recovery and normalization (NR).
......
end
EXAMPLE:
Output of two process-alarm and recovery messages:
sebolblock example2
......
* No alarm is assumed at this moment.
prcsalarm “HIGH” ! Output of alarm message “HIGH.”
prcsalarm “LOW” ! Output of alarm message “LOW.”
......
prcsalarm recover ! Output of three messages informing alarm (HIGH
! and LOW) recovery and normalization (NR).
......
end
IM 33G3C20-11E 9-15
9.8 Formatting String
Messages specified for formatting in their statements are formatted as described below
before being output. The formatted messages have two major types:
1. Formatted and output in an ordinary character string.
2. Formatted and output with output values converted. The converted message starts
with “%” and ends with a conversion character as shown below — specifying “%%”
outputs “%”:
Figure 9.10.
(1) Flag Character (omittable)
–: Closes up the converted result to the left.
+: Attaches a sign to the numeric result.
9-16 IM 33G3C20-11E
9. Message Statements
“g” Uses the “e” or “f” format for output. The “e” format is used when the exponent
resulted in the “e” format conversion is less than –4 or larger than the specified
precision. A decimal point is not attached unless it is followed by a numeral.
Invalid leading zeros are not output.
“o” Converts the output value to an octal numeral. Precision is specified using the
minimum number of output digits — 1 is assumed when omitted.
“s” Receives the output value as a character string and outputs all characters in the
string or as many characters as specified by “precision.”
“x” Converts the output value to a lowercase hexadecimal numeral without sign and “$.”
Precision is specified using the minimum number of output digits — 1 is assumed
when omitted.
“X”Converts the output value to a uppercase hexadecimal numeral without sign and “$.”
Precision is specified using the minimum number of output digits — 1 is assumed
when omitted.
EXAMPLE:
Converting 14-character string “YOKOGAWA SEBOL” using “%s” (output range is
identified using a pair of colons):
:%s: :YOKOGAWA SEBOL:
:%10s: :YOKOGAWA SEBOL:
:%.10s: :YOKOGAWA S:
:%–10s: :YOKOGAWA SEBOL:
:%20s: : YOKOGAWA SEBOL:
:%.20s: :YOKOGAWA SEBOL:
:%–20s: :YOKOGAWA SEBOL :
:%20.10s: : YOKOGAWA S:
:%–20.10s: :YOKOGAWA S :
IM 33G3C20-11E 9-17
9.8.1 “format” Statement
A “format” statement is used to format a character string and store the formatted string
to a local value.
EXAMPLE:
Formatting a date and time string:
sebolblock sample
integer year,mon,day
integer hour,min,sec
char*80 str
......
getdate(year,mon,day) ! Built-in function to get date.
gettime(hour,min,sec) ! Built-in function to get time.
......
format ”%2d :%2d :%2d (%02d :%02d :%02d )”,
year,mon,day,hour,min,sec;str
......
end
When this sample program is executed, the variable “str” is assigned with a character
string stating the date and time ”95 : 3 :14 (08 :12 :07 )”, for example.
Because the date conversion is specified as “%2d,” one-digit data is added with a
leading null character making it two-digit. For the time conversion, which is specified
as “%02d,” one-digit data is added with a leading zero.
9-18 IM 33G3C20-11E
9. Message Statements
“opeguide” statement
“dialogue” statement
“message” statement
“history” statement
“request” statement
“sysalarm” statement The SFC/SEBOL block is delayed one scan period if the
“sysalarm recover” statement output of a message is attempted exceeding the restriction
“prcsalarm” statement (*1) and the message will be output in the next scan period.
“prcsalarm recover” statement (*1)
unit prscalarm statement (*3)
unit prscalarm recover statement (*3)
urload (built-in function) (*4)
urassign (built-in function) (*4)
rpreserve (built-in function) (*5)
*1: There is an additional restriction for process alarms that only one process alarm can be output in one scan
period.
*2: If the error does not permit the continuation of execution, the system forcibly terminates the SFC/SEBOL
block. See 10.3, Classified Error Codes, for details. 2.
*3: In addition to this restriction, only one unit process alarm can be output in one cycle of the scan period.
*4: The results of manipulation of unit recipes by urload and urassign are posted to the operation and
monitoring functions as messages.
*5: The recipe setup request by rpreserve is sent to the operation and monitoring function as a message.
IM 33G3C20-11E 9-19
Limitations that apply where CPU time is exclusively allocated as with a “nopreempt”
statement (see Chapter 12, “Allocating CPU Time”) are summarized below. CPU time
is exclusively allocated on the following three occasions:
• Between “nopreempt begin” and “nopreempt end” (See Chapter 12, “Allocating CPU
Time.”)
• SEBOL one-shot execution step in an SFC block (Refer to SFC Block Function
Manual (IM 33G3C31-11E).)
• Status change preprocessing in an SFC block (Refer to SFC Block Function Manual
(IM 33G3C31-11E).)
Messages that can be output while CPU time is exclusively allocated are subject to the
following limitations:
(A) A total of up to three messages can be output with the “opeguide” statement,
“message” statement, “history” statement, “request” statement, “sysalarm” state-
ment, and “sysalarm recover” statement. An attempt to output a fourth message
would cause a runtime error to occur (*1). If CPU time is exclusively allocated
with a “nopreempt” statement or to a SEBOL one-shot execution step, the fourth
message is output in the next period. In status change preprocessing, the fourth
message would be abandoned.
(B) An attempt to execute a “dialogue” statement would cause a runtime error to occur
(*1). If CPU time is exclusively allocated with a “nopreempt” statement or to a
SEBOL one-shot execution step, the “dialogue” statement is executed next time
CPU time has been allocated. In status change preprocessing, the dialog message
would be abandoned.
(C) Only one message can be output with a “prcsalarm” or “prcsalarm recover”
statement while CPU time is exclusively allocated with a “nopreempt” statement or
to a SEBOL one-shot execution step. An attempt to output a second message
would cause a runtime error to occur (*1). The second message is output in the
next period.
(D) The “prcsalarm” statement and “prcsalarm recover” statement cannot be executed in
status change preprocessing. An attempt to execute these statements would cause a
runtime error to occur, with the message being abandoned.
The relationship between limitation (A) and limitations (1) and (2) that apply where
CPU time is not exclusively allocated is explained below. The up to three messages that
can be output while CPU time is exclusively allocated do not include messages that may
have been output prior to the exclusive allocation of CPU time in the same control
period, though the messages that are output during the exclusive allocation of CPU time
are included as part of the messages mentioned in (1) and (2).
The SFC/SEBOL block would be delayed by one period if the total number of messages
output (including those output prior to the exclusive allocation of CPU time) exceeds
limitation (1) or (2) when the exclusive allocation of CPU time with a “nopreempt”
statement or to a SEBOL one-shot execution step is canceled, but not after status change
preprocessing.
9-20 IM 33G3C20-11E
9. Message Statements
Regarding limitation (C), if the SFC/SEBOL block has already executed a “prcsalarm”
or “prcsalarm recover” statement in the same period when it starts running with CPU
time exclusively allocated, that is, on executing a “nopreempt” statement or on starting
the execution of a SEBOL one-shot execution step, it would be delayed by one period,
so it would execute the operation to which CPU time is exclusively allocated in the next
period.
*1 Even though error/errorsub or common error handling routines are specified, a SEBOL error message is
output without branching control to these routines.
IM 33G3C20-11E 9-21
10. Error Processing
Statement Operation
[] Group assignment.
drive Changes output status of motor and switch instruments
compare Group comparison.
seqtable Operates sequence tables.
logicchart Operates logic charts.
wait until Holds operation until condition is satisfied.
dialogue Controls interactive operation.
signal Outputs signals.
qsigcancel Cancels queing signals.
qsigmove Shifts queing signals.
semlock Locks semaphores.
semunlock Unlocks semaphores.
wait for qsignal Waits for reception of a queued signal.
IM 33G3C20-11E 10-1
10.1.1 Error Variable
The checking of the error variable is recommended if each line of the statement requires
different error processing.
When an error variable is specified, it is set to 0 if the statement ends normally or to an
error code if the statement abnormally. If the detailed code is 0, a classified error code
is set in the error variable;: if the detailed code is not 0, it is set in the error variable.
For more information on the classified error codes, detailed codes, and whether detailed
codes are available or not, see Appendix 1, “Error Codes.”
If an error variable is specified, no error message is output even when a runtime error
occurs. (An error message would be output, however, if fatal errors occur.) An error
message is output if an error, such as an array subscript out of limits occurs when an
error code is set in the error variable.
The syntax of the error-processing instruction is shown in Figure 10.1 (note that the
semicolon in front of the error variable is not entered in the function block group
statement).
• The error variable must be an integer- or long-type local variable. Function block
data cannot be used.
• The error identifier must be a constant or local variable.
10-2 IM 33G3C20-11E
10. Error Processing
EXAMPLE 1:
Error processing specified for “drive” statements:
sebolblock example1
#define OPEN 2
block SIO-22 SWITCH01,SWITCH02,SWITCH03
integer errval
......
drive [SWITCH01 = OPEN] errval ! Error variable.
if (errval <> 0) then
* - - - Error processing description - - -
endif
......
drive [SWITCH02 = OPEN];error ERR000,2 ! Branching.
......
drive [SWITCH03 = OPEN];errorsub ERR010,3 ! Branching.
......
exit
......
ERR000: ! - - - Branching destination. - - -
message ”drive error:line=%d %d-%x ID=%d\n”,\
err1(), errc(), errce(), lerrorid()
exit -1
......
ERR010: ! - - - Branching destination. - - -
message ”drive error:line=%d %d-%x ID=%d\n”,\
err1(), errc(), errce(), lerrorid()
ereturn
end
In the above example, zero or an error code is returned to the error variable in the first
“drive” statement, the returned value is checked using the following “if” statement, and
then in the case of an error the instruction to process the error can be written.
The error variable can also be used to ignore errors — that is, errors are ignored if the
value of the variable is not checked after a value is returned. It is not desirable to ignore
errors, however, it may be useful when using a “semunlock” statement to securely keep
the semaphore unlocked in a program involving a semaphore operation.
EXAMPLE 2:
Ignoring errors:
sebolblock example2
integer junk
......
* Conditionally locking SEMNAME.
......
semunlock ”SEMNAME” junk
* Unconditionally unlocking SEMNAME and unchecking error variable.
......
end
IM 33G3C20-11E 10-3
10.1.2 Branching Destination
When a common error-processing instruction is applicable to a number of lines, a
branching destination can be specified for every line so that the lines branch to the same
destination when errors occur.
The syntax of the error-processing instruction is shown in Figure 10.2.
<error variable>: Specifies an integer-type local variable to which the error code is returned when an error is
caused or zero is returned if no error is caused.
<label>: Specifies the branching destination when an error is caused.
<error identifier>: Specifies an integer-, real number-, or character string-type constant or local variable to
identify the location of the error. In the case of a character string, the leading 16 bytes are
valid and the remaining bytes are ignored.
• If an error is caused with a line for which the branching destination is specified,
branching is executed without outputting any error message.
• The branching specification does not affect values returned to the error variable —
zero when no error is caused and the error code when an error is caused.
• The branching destination is specified using “error” for simple branching and error
processing; or “errorsub” for branching, error processing, and resuming execution
from the line following the line that has caused the error according to the “ereturn”
statement.
<label>:
ereturn
10-4 IM 33G3C20-11E
10. Error Processing
In both “error” and “errorsub” branching, built-in functions “cerrorid,” “lerrorid,” and
“derrorid” permit to obtain the value of the specified error identifier for the line that
caused an error.
cerrorid()
lerrorid()
derrorid()
IM 33G3C20-11E 10-5
10.2 Common Error-Processing Definition
When an error is caused in a line that does not allow individual error-processing routine
or if the instruction has not been written, the error can be processed if a common error-
processing instruction has been defined.
In SFC blocks, common error handlers are described in a common error handling SFC.
In SEBOL blocks, common error handlers are defined with an entry error statement.
entry error
<common error-processing>
return
• Only one common error handler is allowed in one SFC or SEBOL block definition.
The presence of two entry error statements in one SEBOL block, for example, would
cause a compile error to occur.
• Control branches to a redefined common error handler when an error occurs, but no
SEBOL error message is output by the system at this time. Execution is resumed
with the line next to the line in error upon completion of the common error handler
SFC for an SFC block or upon completion of the common error handler after reaching
the return statement for a SEBOL block.
Example 3 shows an example of using a common error handler for a SEBOL block.
In Example 3, two errors, overflow and division by zero, are caused to occur inten-
tionally. Running this program would run the common error handler twice, with an
error message being output by the message statement twice.
EXAMPLE 3:
Common error-processing in SEBOL block:
sebolblock example4
integer i,j,k
long x,y,z
......
x = 10000
y = 10000
i = x * y ! Causing overflow exceeding 32767.
z = 100
j = 0
k = z/j ! Causing zero-division error.
......
exit
......
entry error
message ”error line=%d %d-%x\n”,errl(),errc(),errce()
return
end
10-6 IM 33G3C20-11E
10. Error Processing
In Example-3, overflow and zero-division errors are caused on purpose. Common error
processing will be executed twice when this program is run, outputting error messages
twice according to the “message” statement.
Table 10.2 shows a list of built-in functions used to get error-caused line numbers and
error codes.
• Functions “errl,” “errc,” and “errce” return 0 if no errors have been caused since the
SFC/SEBOL block was started. The “errf” function returns a null-character string.
The “errce” function returns 0 if an error that has no detail code, such as overflow,
has been caused.
• errp and errs are built-in functions dedicated to SFC blocks. errp returns the number
of the plane in which an error occurs. errs returns the number of step in which an
error occurs. For additional details on these built-in functions, see Section 6.6.11,
“Error Functions.”
• These built-in functions are used for individual and common error processing and can
be called anywhere in the program.
IM 33G3C20-11E 10-7
When an error occurs during execution of a user-defined function, control branches to a
predefined common error handler. A common error handler cannot be defined for each
individual function, but only one can be defined in one SFC or SEBOL block. The
common error handler defined for the main program is run when errors occur during the
execution of any function.
EXAMPLE 4:
Common Error Handler
Main program
sebolblock example4
long func1()
char*8 fname
long x,y
x = 10000
y = 10000
func1(x,y)
......
exit
Function func1
long func1(x,y)
integer i
long m
i = x * y
!If x and y are 10000, x*y would exceed 32767, resulting in an overflow
......
return m
end
If both arguments x and y in the line i=x*y in the function func1 are 10000, an overflow
error would occur. Information on the error, such as the name of the function in error,
posted by errf() during the common error handler defined for the main program is output
in a message by the message statement before execution is resumed with the line next to
the line i=x*y in the function func1.
10-8 IM 33G3C20-11E
10. Error Processing
IM 33G3C20-11E 10-9
10.4 Substitution of Values
An error-caused variable or expression is substituted with a correct value to resume the
execution of the SFC/SEBOL block in which an execution-continuable error has been
caused. The substitution is made as described below.
In a division operation using the “/” operator, an invalid operation error is caused
terminating the operation if either or both operands are real numbers and zero is divided
by zero. The execution of the SFC/SEBOL block continues, however.
10-10 IM 33G3C20-11E
10. Error Processing
IM 33G3C20-11E 10-11
10.5 Conditional Expression Errors
Execution-continuable errors caused during the conditional-expression calculation in
control statements are handled as shown in Figure 10.6.
“for” statement: The execution is resumed from the statement following the “next” statement.
“wait until” statement: Branching is executed if specified by “error” or “errorsub” — if not, the
execution is resumed from the next statement.
“switch” statement: The execution is resumed from the line next to “otherwise” if it is present —
if not, from the statement following the “end switch” statement.
10-12 IM 33G3C20-11E
10. Error Processing
Program Type
Step Type
Status Change Status Change Interrupt Signal
Main Program
Processing Postprocessing Handling
IM 33G3C20-11E 10-13
11. Use of Variables and Expressions
*1: The type changes to Type 2 when a variable other than simple variables is assigned to the first argument.
IM 33G3C20-11E 11-1
11.2 Classification of Expressions
Expressions can be classified into three categories:
[Category 1] Right-hand side of an assignment expression and conditional expression,
such as an “if” statement
Expressions falling into this category
• Right-hand side of an assignment expression
• Conditional expression, such as “if” statement, “repeat-until” statement, “wait until”
statement, “switch” statement, and “wait for qsignal” statement
• Expression of the initial value, terminal value, and increment in a “for” statement
11-2 IM 33G3C20-11E
11. Use of Variables and Expressions
• User-created functions and type 2 built-in functions are not allowed in Category 2
expressions. Type 1 built-in functions can be called from Category 1 and 2 expres-
sions. As many functions as desired can be called, provided, however, that built-in
functions that return a character string cannot be used in Category 2 expressions. The
value that a built-in function returns must be assigned to a character string local
variable before the character string is specified as a statement operand.
• Category 3 subscript expressions consist of integer or long type local variables
(including formal arguments of a function) and integer constants.
Table 11.2 lists the types of variables that can be used in the different categories of
expressions. Function block data is allowed in Category 1 and 2 expressions. Up to 32
expressions of function block data can be used in one statement. (If a single statement
contains multiple expressions, the total number of expressions in all the statements may
not exceed 32.)
Category 1 ● ● ● ● ● ● ● ●
Category 2 ● ● ● ● ● × ● ×
Category 3 × × ● × ● × × ×
Where a local variable can be used in a user-created function, a formal argument that
has a local variable as its corresponding real argument can be written. Where a function
block can be written, a formal argument that has a function block as its corresponding
real argument can be written.
IM 33G3C20-11E 11-3
11.3 Special Operands
SEBOL uses special operands shown in Table 11.3. These operands can only use local
variables, or formal arguments of which actual arguments are local variables.
11-4 IM 33G3C20-11E
11. Use of Variables and Expressions
IM 33G3C20-11E 11-5
12. Allocating CPU Time
nopreempt begin
nopreempt end
Figure 12.1
• The SFC/SEBOL block monopolizes CPU time to run the statements intervening
between the “nopreempt begin” statement and the “nopreempt end” statement. No
interrupt handler is invoked on receipt of any interrupt signal or status change
command in the meantime, until the “nopreempt end” statement is run, thus assuring
that the statements intervening between the two statements will be run at the same
timing.
• A runtime error occurs if a “nopreempt begin” statement is run between the
“nopreempt begin” statement and the “nopreempt end” statement, with the CPU time
being deallocated. If a “nopreempt begin” statement is run when no “preempt begin”
statement has been run, it invokes no error but is simply ignored.
• SEBOL one-shot execution steps in an SFC blocks are run by monopolizing CPU
time exactly the same way as they would be enclosed between the “nopreempt begin”
statement and the “nopreempt end” statement.
IM 33G3C20-11E 12-1
• If a “nopreempt” statement is run during a common error routine in a SEBOL block
or during an interrupt handler in an SFC block, then the interrupt handler is termi-
nated by running a “return” statement instead of a “nopreempt end” statement, the
CPU time is deallocated.
• The CPU time remains monopolized if a function is terminated by running a “return”
statement.
• The CPU time monopolized by an SFC block is deallocated if a step action is
terminated with a “quit” statement in the SFC block.
• If an SFC/SEBOL block that monopolizes CPU time continues running or enters a
wait state, the CPU time would be available for allocation to remote SFC/SEBOL
blocks in the same control station. Hence, the statements that can be run between the
“nopreempt begin” statement and the “nopreempt end” statement are subject to the
limitations listed below. A runtime error occurs if any of these limitations is ex-
ceeded.
• A statement longer than 20 lines invokes a runtime error. These 20 lines do not
include the “nopreempt begin” statement and the “nopreempt end” statement. Line 21
and subsequent lines are run without monopolizing the CPU time next time it is
allocated to the SFC/SEBOL block. Even if an error/errorsub destination or common
error handler is encountered on line 21, a SEBOL error message is output at all times,
without control branching to the error handler.
• An attempt to access data in a remote station causes a runtime error to occur. The
data is neither read nor written. Data in other control areas in the local station is
accessible, though.
• If the condition specified by the “compare” statement does not hold true in a single
run, the statement functions the same as it would do when the time specified by the
time option expires.
• The “drive” statement cannot be used.
• The drive vpmon and drive vpmoff statements are not available. For details, see Valve
Pattern Monitor Package Manual (IM33G3C22-11E)”.
• The drivewait option of the “seqtable” statement and the “logicchart” statement
cannot be used.
• “while” to “wend,” “repeat” to “until,” and “for” to “next” involving iterations with
delays cannot be used, but “while” to “wend@,” “repeat” to “until@,” and “for” to
“next@” can be used since they do not involve a delay for each iteration.
• The “wait until” statement cannot be used.
• The “delay” statement and the “delaycycle” cannot be used.
• Signals cannot be sent to remote stations, but can be sent to SFC blocks/units in
other control areas in the local station.
• The “qsigcancel” statement and the “qsigmove” statement cannot be used for SFC
blocks in remote stations, but can be used for SFC blocks in other control areas in the
local station.
• The “dialogue” statement cannot be used.
• The nopreempt begin” statement cannot be used.
• The “semlock wait” statement cannot be used. (A “semlock” statement without the
wait option can be used, though.)
• The “wait for qsignal” statement cannot be used.
• ssdtwrite and ssdtwritebit statement cannot be used.
12-2 IM 33G3C20-11E
12. Allocating CPU Time
Table 12.1 lists the statements that are limited. Failure to observe these limitations
could cause a runtime error, such as an overblow, to occur. The CPU time is
deallocated if a runtime error occurs during execution of any statement intervening
between the “nopreempt begin” statement and the “nopreempt end” statement (*1).
Even if an error variable has been specified, the CPU time would be deallocated upon
detection of a runtime error.
The CPU time would also be deallocated if control branches to a error/errorsub destina-
tion or common error handler as specified. The error recovery action that takes place is
the same except that the CPU time is deallocated. See Chapter 10 for relevant informa-
tion.
If an interrupt signal is received anywhere between the “nopreempt begin” statement and
the “nopreempt end” statement, no interrupt handler invoked run until the “nopreempt
end” statement is run (*2). Likewise, if a status change command is received, no status
change processing is run until the “nopreempt end” statement is run (*2). (Status
change preprocessing and status changes are executed after execution of the “nopreempt
end” statement.)
If an interrupt signal is sent to the local SFC block between the “nopreempt begin”
statement and the “nopreempt end” statement, an interrupt handler is invoked after
execution of the “nopreempt end” statement (*3).
.....
nopreempt begin
.....
signal ”SG1” ! Send an interrupt signal to the local SFC bock
opeguide OG, 2
.....
nopreempt end
In the example above, “opeguide OG,2” and the subsequent lines continue to monopo-
lize the CPU time after the execution of signal “SG1”. The “SG1” interrupt procedure
is not run until after execution of “nopreempt end” statement is completed.
IM 33G3C20-11E 12-3
*1: The CPU time is not monopolized in the execution of the remaining part of the program after the
occurrence of the error.
*2: Interrupt signal/status change command from a remote station. While the SFC/SEBOL block monopo-
lizes the CPU time, other SFC/SEBOL blocks in the same station are prevented from running “signal” or
other statements.
*3: This also holds true when a sequence table (logic chart) that has run a “seqtable” statement (“logicchart”
statement) by one-shot execution sends an interrupt signal to the local SFC block via %EV.
Even if the local SEBOL block is changed to the STOP block status between the
nopreempt begin and the nopreempt end statement, it continues running with the CPU
monopolized until it encounters the nopreempt end statement. The SEBOL block ends
on reaching the nopreempt end statement. Its block status changes at the timing of
execution of %BSTS=“STOP” (*4).
.....
nopreempt begin
.....
%.BSTS = "STOP" ! % denotes a local block.
.....
nopreempt end
Even if the local SFC block is changed to the STOP block status between the nopreempt
begin and the nopreempt end statement (or in a SEBOL one-shot execution step), it
continues running with the CPU monopolized until it encounters the nopreempt end
statement. Its block status changes when any status change preprocessing is executed at
the timing of execution of %BSTS=“STOP”. When the SFC block reaches the
nopreempt end statement, it executes any status change preprocessing, if defined, with
the CPU time being deallocated. The SFC block ends when the status change process-
ing is finished. If no status change preprocessing is defined, the SFC block ends on
reaching the nopreempt end statement.
Even if the local SFC block is changed to the PAUS block status between the nopreempt
begin and the nopreempt end statement (or in a SEBOL one-shot execution step), it
continues running with the CPU monopolized until it encounters the nopreempt end
statement. Its block status changes when any status change preprocessing is executed at
the timing of execution of %BSTS= “PAUS”. When the SFC block reaches the
nopreempt end statement, it executes any status change preprocessing, if defined, with
the CPU time being deallocated. The SFC block ends when the status change process-
ing is finished. If no status change preprocessing is defined, the SFC block ends on
reaching the nopreempt end statement.
.....
nopreempt begin
.....
%.BSTS = "PAUS" ! % denotes a local block.
.....
nopreempt end
*4: A similar operation would also take place if a sequence table (logic chart) run by one-shot execution with
a *** statement (*** statement) has changed the block status of the SFC or SEBOL block.
12-4 IM 33G3C20-11E
12. Allocating CPU Time
IM 33G3C20-11E 12-5
Table 12.1 Limitations on Monopolization of CPU Time
Statement Limitation Remarks
Expressions, assignment statements, and
Data in remote stations not accessible *1
built-in functions
drive Not available *2
drive vpmon *1 Not available *2
drive vpmoff *1 Not available *2
compare Compares only once *1
seqtable Drivewait option not permitted *2
logicchart Drivewait option not permitted *2
for~next Delay assumed an error *3
while~wend Delay assumed an error *3
repeat~until Delay assumed an error *3
wait until Not available *2
delay Not available *2
delaycycle Not available *2
dialogue Not available *2
signal Cannot sent signals to remote stations *1
SFC block in a remote station not
qsigcancel *1
manipulatable
SFC block in a remote station not
qsigmove *1
manipulatable
semlock wait Not available *2
nopreempt begin Not available *2
wait for qsignal Not available *2
*1 For details on the drive vpmon and drive vpmoff statements, see “Valve Pattern Monitor Package Manual
(IM33G3C22-11E)”.
The action that takes place when a runtime error occurs as a result of failure to observe
these limitations is divided into the following three courses:
*1 Control branches to an error/errorsub destination or common error handler if one is defined. (No SEBOL
error message is output when control branches to an error handler.) Next time CPU time is allocated to
the SFC/SEBOL block, execution is resumed with the line next to the line in error (or with an error
handler if one is defined).
*2 Control does not branch even if an error/errorsub destination or common error handler is defined. (A
SEBOL error message is output at all times.) Next time CPU time is allocated to the SFC/SEBOL block,
execution is resumed with the line in error; that is, the line in error is retried.
*3 Control branches to a common error handler if one is defined. (No SEBOL error message is output when
control branches to an error handler.) Next time CPU time is allocated to the SFC/SEBOL block,
execution is resumed with the statement next to the “next,” “wend,” or “until” statement (or with an error
handler if one is defined).
12-6 IM 33G3C20-11E
13. Managing Shared Resources
Exit Semaphore
Hazardous zone
Figure 13.1
This hazardous zone may be likened by analogy to a shared resource, trains to SFC/
SEBOL blocks. Given a means to manipulate the semaphore, multiple SFC/SEBOL
blocks can be synchronized to access a shared resource. Hereafter, the operation of
lowering the semaphore is called locking the semaphore, and that of raising the sema-
phore is called unlocking the semaphore.
• Users can name a semaphore with a character string not exceeding 8 bytes. This
name is called a semaphore name.
• Multiple SFC/SEBOL blocks (*1) in the same control area can be synchronized with
one another by performing semaphore operations on the same semaphore name. Users
can define 0 to 64 semaphores in one control area at the same time (*2). The default
is 10. A runtime error occurs when the number of semaphores permitted per control
area is exceeded. Add to the number of semaphores as needed. Changing the number
of semaphores defined requires regeneration of the control area as a whole. The
number of semaphores defined cannot be altered by online maintenance.
IM 33G3C20-11E 13-1
• Only SFC/SEBOL blocks (*1) in the same control area can be synchronized by the
use of semaphores.
*1: These are independently started blocks and not unit-started operation sequences.
*2: The semaphore area cannot be established unless SFC/SEBOL blocks are residing in the control area.
And it is necessary to specify more than one blocks for “Number of SEBOL blocks” or “SFC/SEBOL
block executable number” in the control area. See Appendix 5, Application Size, for more information.
UNIT101
5 SFC101 6 SFC201
Semaphore
UNIT101
13-2 IM 33G3C20-11E
13. Managing Shared Resources
Figure 13.2 shows an example of controlling the semaphore “SEM0” from two SEBOL
blocks, prog1 and prog2.
prog1
prog2
IM 33G3C20-11E 13-3
13.1 “semlock” Statement and “semunlock” Statement
A semaphore is locked with a “semlock” statement and unlocked with a “semunlock”
statement. When SFC/SEBOL block runs a “semlock” statement with the wait option
specified, it waits for the semaphore to be unlocked if it has already been locked.
Running a “semlock” statement without the wait option specified will invoke an error
immediately if the semaphore has already been locked.
<semaphore name>: Specifies the name of a semaphore with a character string constant or character string variable
not exceeding 8 bytes. If the character string exceeds 8 bytes, only the first 8 bytes are accepted.
<error variable>: Specifies the local variable in which an error code is set when errors occur. It is set to 0 in the
absence of errors.
<label>: Specifies where control should branch when errors occur.
<error identifier>: Specifies a constant or local variable to identify the location of an error during an error handler.
Figure 13.3
• A runtime error occurs when a single SFC/SEBOL block attempts to lock the same
semaphore in duplicate (even if the wait option is specified).
• A runtime error also occurs when a SFC/SEBOL block attempts to unlock a sema-
phore that it has not locked.
• Once a SFC/SEBOL block enters a state of waiting for a semaphore to be unlocked
by running a “semlock wait” statement, the program would not go any farther unless
the semaphore is unlocked. If a SFC/SEBOL block receives an interrupt signal while
waiting for the semaphore to be unlocked, it executes interrupt signal receive process-
ing. SFC/SEBOL block can receive status change commands while they are waiting
for semaphores to be unlocked. When the SFC/SEBOL block receives a status
change command, status change preprocessing/postprocessing is executed, thereby
changing the block status (if such change is permitted). The “semlock wait” state-
ment cannot be used during interrupt signal handling, status change postprocessing,
and common error handling routines, but a “semlock” statement and a “semunlock”
statement without the wait option specified can be used. The “semlock,” “semlock
wait,” and “semunlock” statements cannot be used in status change preprocessing.
• If there is any SFC/SEBOL block that has been waiting for a semaphore to be
unlocked when the semaphore is unlocked with a “semunlock” statement, the SFC/
SEBOL block is released from the state of waiting to resume its execution. If more
than SFC/SEBOL block has been waiting for semaphores to be locked, the sema-
phores are unlocked in the order in which the blocks have started waiting for the
semaphores to be unlocked.
13-4 IM 33G3C20-11E
13. Managing Shared Resources
• When an SFC/SEBOL block that has locked a semaphore is halted (thereby entering
the STOP or ABRT block status), the system unlocks the semaphore.
• Even when an SFC block that has locked a semaphore pauses (thereby entering the
PAUS block status), the semaphore is not unlocked. If an SFC block pauses with a
semaphore locked, the SFC/SEBOL blocks that have been waiting for the semaphore
to be unlocked would be left waiting. In this case, use the “semunlock” statement to
unlock the semaphore with a status change postprocessing for the status change
command PAUS. Figure 13.4 shows a typical application.
• SFC/SEBOL blocks have the system-fixed data item SEMA. The name of the
semaphore that has been locked with a “semlock” or “semlock wait” statement is set
in SEMA by the system. If a single SFC/SEBOL block locks more than semaphore,
the name of the first semaphore locked is set in SEMA. SEMA is set to ”” (a
character string with a length of 0) when there are no locked semaphores since all
have been unlocked with a “semunlock” statement.
semunlock "SEM01"
3 Phase 2
Pause
Main program
IM 33G3C20-11E 13-5
13.2 Deadlocks and Their Prevention
When a single SFC/SEBOL block attempts to lock two or more semaphores at the same
time, protection against deadlocks should deserve special consideration.
Consider locking the two semaphores, SEM1 and SEM2, from the two SEBOL blocks,
sebol1 and sebol2, for example. If sebol1 and sebol2 run “semlock” statements with the
wait option, the former to lock SEM1 and SEM2 in this order and the latter to lock
SEM2 and SEM1 in this order, both SEBOL blocks could wait for semaphore unlocking
at the same time, depending on the timing. This state is called a deadlock.
The only way to resolve the deadlock is to abort either SEBOL block. (The semaphores
that have been locked by the SEBOL block thus aborted are unlocked, thereby allowing
the other SEBOL block to be released from the state of semaphore waiting.
Deadlock
sebol1 sebol2
13-6 IM 33G3C20-11E
13. Managing Shared Resources
IM 33G3C20-11E 13-7
14. Subsystem Communication
IM 33G3C20-11E 14-1
Control station
PI/O library
PI/O image
PI/O driver
Data area
Subsystem
14-2 IM 33G3C20-11E
14. Subsystem Communication
IM 33G3C20-11E 14-3
14.1.1 Reading Subsystem Data
The ssread statement reads subsystem data from the subsystem I/O image (DDC/SEQ
data area) at the control station.
<line number> Specifies the line number of the ACM card as an integer constant or
variable.
<card number> Specifies the card number of the ACM card as an integer constant or
variable.
<access number> Specifies the number of the block (DDC/SEQ definition) as an integer
constant or variable.
<relative position> Specifies the relative position from the beginning of the block (DDC/SEQ
definition) (in words) as an integer constant or variable.
<option> Specifies a read option. See Section 14.3 for the description of options.
<data status storage variable> Specifies a double-length integer variable into which the data status is
read. The data status of the specified block is stored here.
<data storage variable> Specifies a local variable into which data is read. It may be a simple
variable, array element or entire array.
<data type> Specifies the data type of the subsystem data. This data type is that of
the subsystem data and not that of a SEBOL variable.
<error variable> Specifies a local variable that is loaded with an error code when an error
occurs. 0 is set when no error is present.
<error identifier> Specifies a constant or variable that identifies the occurrence of an error
to the error handler.
Figure 14.2
ACM1 ACM2
line number 1~2 1~2
card number 1~6 21~24
access number 1~30 1~60
relative position 0~127 0~1023
The ssread statement reads data from the block of subsystem data that is identified by
<line number>, <card number>, and <access number>. It retrieves data of <data type>
starting at <relative position> in the block and reads it into the corresponding <data
storage variable>. Up to 32 sets of <data storage variable>:<data type> can be speci-
fied.
If <error variable> is specified, it is loaded with 0 when no error is present or with an
error code when an error occurs. <Label> may specify where control should branch
when errors occur. <Error identifier> identifies the location of an error to the error
handler as it occurs. Built-in functions enable the error handler to get the value of
<error identifier>. For more details on error handling, see Chapter 10, “Error Process-
ing.”
14-4 IM 33G3C20-11E
14. Subsystem Communication
IM 33G3C20-11E 14-5
14.1.2 Data Statuses
Each block of subsystem data has a data status. Table 14.4 indicates the bit patterns of
the data statuses that the ssread statement may post. The most significant (leftmost) bit
position is 1, and the least significant (rightmost) bit position is 32. All bits other than
bits 20 to 22 are always 0.
Table 14.5 lists the possible combinations of the data statuses of subsystem data and the
associated statuses of the card. If a block of subsystem data is in the data status NRDY,
it can neither be read with the ssread statement nor written with the sswrite or sswritebit
statement.
The data status obtained with the ssread statement can be tested with the built-in
function dscheck().
For information how to use dscheck(), see Section 7.4.1, “Checking Data Status.”
EXAMPLE 1:
The subsystem data read by the ssread statement can be judged for applicability by
verifying the NRDY data status. In this example, the data status returned to local
variable “ds” by the ssread statement is verified using built-in function “dscheck()”.
sebolblock example1
long ds
integer i1, i2, i3
14-6 IM 33G3C20-11E
14. Subsystem Communication
EXAMPLE 2:
To judge normalcy of the card or the communication with the subsystem, a check is
made for data status “BAD” in this example.
sebolblock example2
long ds
integer i1,i2,i3
ssread 1,1,10,0;ds;i1:integer,i2:integer,i3:integer
if (dscheck(ds,”BAD”) <> 0) then
!Executes processing if data status is BAD.
!Card or subsystem communication abnormality detected.
.....
end if
.....
end
IM 33G3C20-11E 14-7
14.1.3 Writing Subsystem Data
The sswrite statement writes subsystem data in words, while the sswritebit statement
writes to bit fields. The sswrite and sswritebit statements end normally when writing to
the I/O image of a subsystem in the field control station is complete.
● Writing in words
<line number> Specifies the line number of the ACM card as an integer constant or
variable.
<card number> Specifies the card number of the ACM card as an integer constant or
variable.
<access number> Specifies the number of the block (DDC/SEQ definition) as an integer
constant or variable.
<relative position> Specifies the relative position from the beginning of the block (DDC/SEQ
definition) (in words) as an integer constant or variable .
<option> Specifies a write option. See Section 14.3 for the description of options.
<variable> Specifies a local variable containing to the data to write. It may be a simple
variable, array element or entire array.
<data type> Specifies the data type of the subsystem data. This data type is that of the
subsystem data and not that of a SEBOL variable.
<bit position> Specifies the bit position from the most significant bit as an integer
constant or variable (1 to 32). The most significant (leftmost) bit position is
1, and the least significant (rightmost) bit position is 32.
<bit length> Specifies the length of the bits to write as an integer constant or variable (0
to 32).
<bit field data> Specifies an integer constant or variable containing the data (bits) to write,
right-justified. A lower address means a lower bit.
<error variable> Specifies a local variable that is loaded with an error code when an error
occurs. 0 is set when no error is present.
<label> Specifies where control branches when errors occur.
<error identifier> Specifies a constant or variable that identifies the occurrence of an error to
the error handler.
Figure 14.3
14-8 IM 33G3C20-11E
14. Subsystem Communication
ACM1 ACM2
line number 1~2 1~2
card number 1~6 21~24
access number 1~30 1~60
relative position 0~127 0~1023
The sswrite statement writes data to the block of subsystem data that is identified by
<line number>, <card number>, and <access number>. SEBOL <variable> is converted
to <data type> to write the data starting at <relative position> in the block. Up to 32
sets of <data storage variable>:<data type> can be specified.
The sswritebit statement writes data to a specified bit field in 32-bit integer data starting
at <relative position> in the block of subsystem data that is identified by <line number>,
<card number>, and <access number>. If <bit position> is m and <bit length> is n, data
like that shown in Figure 14.4 is written to the I/O image of subsystem data.
1 32
SEBOL <bit field data> 1 2 ....... n
1 m m+n+1 32
Data set in the subsystem 1 2 ....... n
Locations other than the bit field specified (in Figure 14.4, bit 1 to bit (m-1) and bit
(n+m) to bit 32) would remain with the values in effect prior to the execution of the
sswritebit statement.
For both the sswrite and sswritebit statements, if <error variable> is specified, it is
loaded with 0 when no error is present or with an error code when an error occurs.
<Label> may specify where control should branch when errors occur. <Error identifier>
identifies the location of an error to the error handler as it occurs. Built-in functions
enable the error handler to get the value of <error identifier>. For more details on error
handling, see Chapter 10, “Error Processing.”
IM 33G3C20-11E 14-9
Precautions in using the sswritebit statement are summarized below.
• Data can be written only to blocks that have the data type DO or AO*** specified by
the DDC/SEQ definition.
• Specify an integer from 1 to 32 as <bit length>. A value higher than 32 or a negative
value is assumed an error. If a value of 0 is specified, it does not cause an error but
is not written either.
• Remember that, if the data to write to has the data type DO specified by the DDC/
SEQ definition, the value of <variable> would be written without bit inversion,
regardless of whether bit inversion is specified or not.
• Specify a multiple of 2 (4-byte boundary) as <relative position>.
• An error occurs when more than 33 sets of <bit position> and <bit length> are
specified.
14-10 IM 33G3C20-11E
14. Subsystem Communication
14.1.4 Example
An example of defining blocks of subsystem data and accessing them with SEBOL
statements is described below. A line number of 1 and an ACM card number of 5 are
assumed in this example.
It is assumed that data is arranged in the block with definition number 1 as shown in
Figure 14.5. Numbers found on the left side indicate a relative position (in words) each.
0 integer
1 integer
2
long
4
long
6
float
char8
12
char8
Figure 14.5
It is assumed that eight 16-bit signed integers are arranged in the block with definition
number 2.
0 integer
1 integer
2 integer
3 integer
4 integer
5 integer
6 integer
7 integer
Figure 14.6
IM 33G3C20-11E 14-11
(1) Read two sets of data from the block with definition number 1 each as a 16-bit
signed integer, from the beginning of the block (relative position 0) downwards.
sebolblock sample1
integer data1, data2
long dSts
data[1] = 10
data[2] = 20
data[3] = 30
data[4] = 40
sswrite 1, 5, 2, 3; data[*]:integer
.....
end
(4) Read three sets of data from the block with definition number 2, starting at relative
position 4 (byte 8). If an entire array is specified (in the example, data[*]), data is
read in the number of array elements involved.
sebolblock sample4
integer data [3]
14-12 IM 33G3C20-11E
14. Subsystem Communication
IM 33G3C20-11E 14-13
14.2.1 Reading Subsystem Data
The ssread statement reads subsystem data from the monitor declaration data area of the
control station.
<line number> Specifies the ACM card line number using an integer constant or
variable (1 to 2).
<card number> Specifies the ACM card number using an integer constant or variable
(21 to 24).
<access number> Specifies an access number using an integer constant or variable
obtained by adding 1000 to the block number specified in the monitor
declaration (1001 to 1128).
<relative position> Specifies the relative position (in word units) from the start of the monitor
declaration-specified block using an integer constant or variable
(0 to 1023).
<option> Specifies a read option. See Section 14.3 for the description of options.
<data storage variable> Specifies a local variable into which data is read. The variable may be a
simple variable, array element, or entire array.
<data type> Specifies the subsystem data type — not a SEBOL variable type.
<data status storage variable> Specifies a double-length integer variable into which the data status of
the specified block is read and stored.
<error variable> Specifies a local variable into which the error code is loaded when an
error occurs. 0 is set when no error is present.
<label> Specifies the control branching destination in the case of an error.
<error identifier> Specifies a constant or variable that identifies the occurrence of an error
to the error handler.
The ssread statement reads the monitor declaration data identified by <line number>,
<card number>, and <access number>. <line number> and <card number> determines
the ACM card through which communication is carried out between the control station
and the subsystem. <access number> determines the block of the ACM card, <relative
position> determines the position of the data, and <data type> fetches the data, which
are then read into the variable specified by <data storage variable>. Up to 32 sets of
<data storage variable>:<data type> can be specified.
14-14 IM 33G3C20-11E
14. Subsystem Communication
<error variable> loads in the specified local variable 0 when no error is present or an
error code when an error occurs. <label> specifies where control branches when an error
occurs. <error identifier> identifies the location of error to the error handler, which
obtains the <error identifier> data by means of a built-in function. See Chapter 10,
Error Processing, for the description of error handling.
Precautions in using the ssread statement are summarized below:
• If the ssread statement results in a subsystem communication error (classified error
code: 500), data are not read into any <data storage variable> at all. In this case, the
<data storage variable> data prior to the execution of the statement remain un-
changed.
• A single execution of the ssread statement cannot read data that exceed the range of
one block.
• One simple variable or array element should be specified as an error variable — an
entire array cannot be specified. The error variable in a ssread statement is not
returned with an error code for each set of <data storage variable>:<data type> but
only with one error code for that ssread statement.
• The data status is the same as in accessing DDC/SEQ data. See Subsection 14.1.2,
Data Status, for details.
• If I/O is separated in the test function, 0 is returned to the numeric <data storage
variable>, a null character string to the character string <data storage variable>, and 0
to data status.
IM 33G3C20-11E 14-15
14.2.2 Writing Subsystem Data
The ssdtwrite statement writes data in units of words to the subsystem. The ssdtwritebit
statement writes the bit fields. These statements execute communication to the sub-
system to write and set the data in the subsystem. They are properly terminated when
the communication is finished completing the writing.
● “ssdtwrite” statement
● “ssdtwritebit” statement
<line number> Specifies the ACM card line number using an integer constant or variable
(1 to 2).
<card number> Specifies the ACM card number using an integer constant or variable
(21 to 24).
<station number> Specifies the station number for the subsystem, to which data are written,
using an integer constant or variable.
<address> Specifies the address of the data to write using a character string constant
or variable. The address can be a device number, etc., and represented
by an alphanumeric character string using up to 8 bytes — an error occurs
if the number of bytes is exceeded. Different addresses are used in
different subsystems.
<option> Specifies a write option. See Section 14.3 for the description of options.
<variable> Specifies a local variable in which the written data is stored using a simple
variable, array element, or entire array.
<data type> Specifies the subsystem data type — not a SEBOL variable type.
<bit position> Sets the bit position at 1 using a constant or variable.
<bit length> Specifies the length of the bits to write using an integer constant or variable
(0 to 32).
<bit field data> Specifies an integer constant or variable to store the data bits written right-
justified. A smaller address represents a lower bit.
<error variable> Specifies a local variable into which the error code is loaded when an error
occurs. 0 is set when no error is present.
<label> Specifies the control branching destination in the case of an error.
<error identifier> Specifies a constant or variable that identifies the occurrence of an error to
the error handler.
14-16 IM 33G3C20-11E
14. Subsystem Communication
The ssdtwrite statement converts <variable> to <data type> and then writes the data in
position starting at <address>. <line number> and <card number> specify the position
of the ACM card, and <station number> identifies the subsystem connected to the ACM
card. <address> specifies the position of the data in the subsystem — every subsystem
has a unique address.
The ssdtwritebit statement writes data in the specified bit fields of 32-bit integer data at
the subsystem’s <address> determined by <line number>, <card number>, and <station
number>. <bit position> is fixed at 1. When <bit length> is n, the data are set in the
subsystem as shown in Figure 14.9:
1 32
SEBOL <bit field data> 1 2 ...... n
1 n 32
Data set in subsystem 1 2 ...... n
Locations other than the bit field specified (bits n+1 to 32 in Figure 14.9) retain data in
effect prior to the execution of the ssdtwritebit statement.
When <error variable> is specified for both ssdtwrite and ssdtwritebit statements, the
variable is loaded with 0 if no error is present or with an error code if an error occurs.
<label> specifies where control branches when an error occurs. <error identifier>
identifies the location of error to the error handler, which obtains the <error identifier>
data by means of a built-in function. See Chapter 10, Error Processing, for the descrip-
tion of error handling.
Precautions in using the ssdtwrite statement are summarized below:
• If the ssdtwrite statement results in a subsystem communication error (classified error
code: 500), data are not written at all. The subsystem data prior to the execution of
the statement remain unchanged.
• No more than 32 words (64 bytes) per line of data can be written in a single execu-
tion of the ssdtwrite statement.
• One simple variable or array element should be specified as an error variable — an
entire array cannot be specified. The error variable in a ssdtwrite statement is not
returned with an error code for each set of <data storage variable>:<data type> but
only with one error code for that ssdtwrite statement.
Precautions in using the ssdtwritebit statement are summarized below:
• An integer within a range of 1 to 32 should be specified to <bit length>. An error
occurs if the range is exceeded or a negative value is specified. Specifying 0 does not
cause an error but not data will be written.
IM 33G3C20-11E 14-17
The following precautions apply to both the ssdtwrite and ssdtwritebit statements:
• Even when the ssdtwrite or ssdtwritebit statement has been completed, the ssread
statement will not be able to read the written data until they are copied from the
subsystem data area to the monitor declaration data area of the control station. The
time required for the copying is dependent on the subsystem, communication defini-
tion, and transmission rate.
• A time-out error occurs for the ssdtwrite or ssdtwritebit statement if no response is
received from the ACM card within 60 seconds of the writing communication.
• If I/O is separated in the test function, data are not written but the ssdtwrite or
ssdtwritebit statement will be properly terminated.
• If more than 32 ssdtwrite or ssdtwritebit statements are executed at the same time
within the same control station, an error occurs when the 33rd statement is executed.
14-18 IM 33G3C20-11E
14. Subsystem Communication
(1)
Write request
(2)
Interrupt signal
ssdtwrite
Subsystem executed
(3) (4)
Response
• The received interrupt signal is not processed until the data are written by the
ssdtwrite or ssdtwritebit statement and set in the subsystem.
• The execution of the ssdtwrite or ssdtwritebit statement takes several seconds. The
time required to complete the writing is dependent on the subsystem.
• The execution of an SFC block interrupt signal or a post status-change processing is
delayed until immediately after completing the execution of the ssdtwrite or
ssdtwritebit statement.
• The SFC block pre-status-change processing is executed instantly when a status
change command is received.
• The SEBOL block or the SFC block that has no post-STOP status-change processing
immediately stops when the STOP command is received during or before completing
the execution of the ssdtwrite or ssdtwritebit statement.
• No precautions are required in using the ssdtwrite and ssdtwritebit statements with
SEBOL blocks since they do not allow the description of interrupt processing.
IM 33G3C20-11E 14-19
If it is absolutely necessary to have an interrupt signal processed while the ssdtwrite or
ssdtwritebit statement is being executed, an SFC block that processes the interrupt signal
and an SFC/SEBOL block that writes data in the subsystem should be used in combina-
tion as described below.
In an example shown in Figure 14.11, an SFC block (SFCINTR) used for interrupt
processing stops another SFC block (SFCSBSYS) used for writing data in the sub-
system. SFCINTR does not use the ssdtwrite or ssdtwritebit statement and is thus able
to execute the interrupt program immediately upon receiving a signal or a status change
command. SFCINTR also stops SFCSBSYS in the post-status-change processing when
the STOP status change command is received.
SFCINTR
. . . . .
2 Data setting ssdtwrite 1,3,3, "SM0a", 0; 10:integer
. . . . .
14-20 IM 33G3C20-11E
14. Subsystem Communication
14.3 Options
Options that can be used with some SEBOL subsystem statements are described. These
options are 32-bit integers and used as shown in Table 14.8.
• $00000001
When this option is used with the ssread statement, an error is caused if the data
status becomes BAD during the execution of the statement. Otherwise no error
occurs and the statement properly ends even when the data status is BAD.
• $00000002
When this option is used with the ssdtwrite or ssdtwritebit statement , an error is
caused if the subsystem power momentarily fails during the execution of the state-
ment. Otherwise no error occurs and the statement rewrites data.
IM 33G3C20-11E 14-21
15. Signaling Operation
IM 33G3C20-11E 15-1
15.3 “signal” Statement
The “signal” statement allows SFC/SEBOL blocks to send both queued signals and
interrupt signals to SFC blocks.
It also can transmit signals to units. For details, refer to SFC Block Function Manual
(IM 33G3C31-11E), Section 4.5, Signals to Unit Instruments.
<signal name> Specifies the signal name with a character string constant or
character string variable not exceeding 8 bytes.
<signal parameter> Specifies a signal parameter with a numeric expression or charac-
ter string. The signal parameter is of the type integer, long, float,
double, and character string. If the character string exceeds 16
bytes, only the first 16 bytes are accepted. Up to eight signal
parameters can be specified.
<tag name> Specifies the tag name of the signal recipient SFC block. It is the
tag name declared in a “block” statement, local generic name
declared in a “genname” statement, or a function block with the
formal argument declared in an “argblock” statement.
<plant name> Specifies the plant name with a character string constant or
character string variable not exceeding 8 bytes.
<return signal name> Name of the signal that the SFC block, on receiving a queued
signal, returns to start signal handling.
<error variable> Specifies the local variable in which an error code is set when
errors occur. It is set to 0 in the absence of errors.
<label> Specifies where control should branch when errors occur.
<error identifier> Specifies a constant or local variable to identify the location of an
error during an error handler.
15-2 IM 33G3C20-11E
15. Signaling Operation
The “signal” statement in format (1) sends a signal to the SFC block that has executes
the “signal” statement. Using this format in a SEBOL block program would invoke a
compile error, since SEBOL blocks cannot receive signals.
The “signal” statement in format (2) sends a signal to the SFC block having a specified
tag name even when it exists in a control station separate from the SFC/SEBOL block
that executes the “signal” statement.
In both formats (1) and (2), the “signal” statement causes a runtime error to occur if the
signal recipient SFC block cannot receive the signal.
The tag name of the signal recipient SFC block can be altered as desired by using a
local generic name in format (2). Assume that a return signal name is specified in the
first parameter of the signal that an SFC block has received, with the tag name character
string of the SFC block to which the signal is to be returned in the second parameter.
The program below retrieves the signal name and the recipient SFC block tag name with
the “creadpara” built-in function. The SFC block, on receiving the signal, associates the
local generic name, gen001, with the tag name of the recipient SFC block using the
“assign” statement, then returns the signal to that recipient SFC block.
......
genname SFC gen001
char*16 signame,tagname
......
signame = creadpara(1)
tagname = creadpara(2)
assign tagname to gen001
signal signame to gen001
......
The “signal” statement in format (3) sends a signal to an SFC block existing in another
plant.
If return<return signal name> is specified when a queued signal is sent to a remote SFC
block, the queued signal recipient SFC block returns the signal with <return signal
name> to the SFC block that executed the “signal” statement at the timing at which it
starts signal receive processing by exiting from the “wait for qsignal” statement.
The first parameter of the return signal is of the type long and assumes one of the values
listed in Table 15.1.
Value Meaning
0 Signal handling has started
1 Signal canceled (*1)
2 SFC block aborted before the start of signal handling (*2)
3 Error detected while dequeuing a queued signal
*1: If the SFC block that has sent the signal cancels the signal by itself, no return signal is sent.
*2: An SFC block returns a return signal when it stops and not when it halted by a fatal error or ABRT
command (thereby entering the ABRT block status).
IM 33G3C20-11E 15-3
The execution of a “signal” statement with the return option would invoke a runtime
error in the following situations:
• The “signal” statement with the return option is run in a SEBOL block.
• The SFC block that ran the “signal” statement does not have an interrupt signal
handler with <return signal name> defined and <return signal name> has not been
defined in the “queue signal” statement either.
• The signal name has not been defined in the “queue signal” statement in the signal
recipient SFC block.
Since the signal that is sent by a “signal” statement with the return option is a queued
signal, an error would result even if an interrupt signal handler with the signal name is
defined in the signal recipient SFC block. The signal is discarded without being
received.
On receiving the queued signal, the SFC block returns the signal with <return signal
name> to the SFC block that executed the “signal” statement at the timing at which it
starts signal receive processing (*2). If the SFC block that executed the “signal”
statement is unable to receive the return signal (*3), a SEBOL error message is output
for the SFC block that attempted to send the return signal (*4). The execution of the
SFC block to which return signal transmission was attempted, however, is unaffected in
any way, except that the SEBOL error message is output. Control does not branch even
if a common error handler is defined.
*2: The timing at which the signal recipient SFC block exists from the “wait for qsignal” statement. For
more details, refer to SFC Block Function Manual (IM 33G3C31-11E).
*3: Once the maximum number of queued signals has been received, no more signal can be received.
*4: The system sends a return signal when a queued signal is canceled or the queued signal receiving SFC
block is halted. If this transmission results in an error, the line and step numbers in the resultant SEBOL
error message indicate the position of the “wait for qsignal” statement.
15-4 IM 33G3C20-11E
15. Signaling Operation
<signal name> Specifies the queued signal name with a character string
constant or character string variable not exceeding 8
bytes.
<signal parameter number> Specifies a signal parameter number with a numeric
expression.
<signal parameter> Specifies a signal parameter with a numeric expression
or character string. The signal with its signal parameter
<signal parameter number> matching the <signal
parameter> is controlled.
<tag name> Specifies the tag name of the SFC block on which to
manipulate queued signals. It is the tag name declared
in a “block” statement, local generic name declared in a
“genname” statement, or a function block with the
formal argument declared in an “argblock” statement.
Omit this parameter when manipulating queued signals
on the local SFC block.
<plant name> Specifies the plant name with a character string constant
or character string variable not exceeding 8 bytes.
<number of signals canceled> Specifies the name of an integer local variable in which
the number of signals dequeued is set.
<move result> Specifies the name of an integer local variable in which
the move result is set. 1 is returned if the specified
signal is placed on top of the queue. 0 is returned if the
specified signal is not found in the queue.
IM 33G3C20-11E 15-5
To manipulate a queued signal on the local SFC block, run the “qsigcancel” or
“qsigmove” statement without specifying a tag name. To manipulate a queued signal on
a remote SFC block, run the “qsigcancel” or “qsigmove” statement with the tag name
specified.
SEBOL blocks can manipulate queued signals on remote SFC blocks. SEBOL blocks
cannot use a “qsigcancel” or “qsigmove” statement without having a tag name specified.
A plant name specification is also needed to manipulate SFC blocks in other plants.
If the “qsigcancel” statement is run without parameters specified, all the signals queued
for processing on the current SFC block are canceled. If the “qsigcancel” statement is
run with <signal name> specified, all the signals having the <signal name> are canceled.
The number of dequeued signals is returned to <number of signals canceled>. 0 is
returned if none have been canceled. (The “qsigcancel” statement ends normally.) If
the signal name has not been defined in the “queue signal” statement in the initial step
in the SFC block, the “qsigcancel” statement results in a runtime error. The scope of
signals that are manipulated can be narrowed by specifying <signal parameter number>
and <signal parameter>
Writing
will cancel signals with the signal name “SIG1” having the “HI” as their first parameter,
with the number of signals thus canceled being returned to the variable ncancel.
Writing
will cancel signals with the signal name “SIG2” having 5 as their second parameter.
Figure 15.1 shows a sample run of the “qsigcancel” statement.
If a numeric signal parameter is used to narrow the scope of signals that are manipu-
lated, use one of the type integer (integer or long). A signal parameter of the type real
(float or double) should deserve special notice, for data of the type real could be
evaluated as being a mismatch due to errors. Because data of the type real has a finite
precision, it is bound to produce a negligible error on calculation or type conversion
from double to float. Comparing with a value involving an error results in a mismatch.
15-6 IM 33G3C20-11E
15. Signaling Operation
The “qsigmove” statement moves a specified signal to the top of the queue. Only one
signal can be manipulated. Even if there is more than one applicable signal, only the
signal closest to the top of the queue is manipulated. Figure 15.2 shows a sample run
of the “qsigmove” statement.
Signal queue
5 3 7 0 3
Signal queue
5 7 0
IM 33G3C20-11E 15-7
Signal queue
5 3 7 0 3
Signal queue
3 5 7 0 3
15-8 IM 33G3C20-11E
15. Signaling Operation
isigmask
isigunmask
The “isigmask” statement and the “isigunmask” statement have effect on all the interrupt
signals in the current SFC block.
Interrupt signals cannot be masked individually by name. Interrupt signals are not
masked by default.
Even if an interrupt signal is received while interrupt signals are masked, an interrupt
signal handler is not invoked. Interrupt signals that are received while interrupt signals
are masked are stored, so that control will pass to an interrupt signal handler as soon as
the interrupt signals are unmasked.
The execution of the “isigmask” or “isigunmask” statement does not affect the interrupt
signal handler in progress in any way.
IM 33G3C20-11E 15-9
Appendix
*1: These classified error codes indicate an error that occurred in a unit sequence being run in the same unit
as the unit sequence in which the “assign” statement was executed.
295 $0127 Attempt to output more than three messages while CPU
time was monopolized.
Attempt to output more than one process alarm while
296 $0128
CPU time was monopolized.
341 $0155 Cannot change the block mode to SEMI due to the
specification of the SEMI mode operation
Cannot change the block status while change preprocessing
342 $0156
is in progress
343 $0157 Cannot change the block status while status change
postprocessing is in progress
Cannot change the block status while SEBOL/SFC
344 $0158 block termination processing is in progress
345 $0159 Cannot run an SFC block while the function block type
definition is under online maintenance
Cannot run an SFC/SEBOL while an SFC sequence or
346 $015A SEBOL block main program is under online
maintenance
Cannot find the database associated with a specified
20347 $4F7B SFC sequence name
353 $0161 Cannot change the block mode while status change
preprocessing is in progress
354 $0162 Cannot change the block mode while status change
postprocessing is in progress
Cannot change the block mode while SEBOL/SFC
355 $0163 block termination processing is in progress
*1: If online maintenance is completed before fatal error 20606 or 20607 is caused, the SFC/SEBOL block
properly calls functions to continue operation even when error 608 or 609 has been caused.
*2: Detailed error codes use the numbers of arguments, counting 1, 2, 3, and so on from the left.
45573 $B205 Attempt to run a block other than a unit sequence from a block
45574 $B206 Cannot change the block status of a unit sequence in O/S block mode
45578 $B20A Database associated with the SFC sequence name not found
45579 $B20B SFC sequence or SEBOL block main program under online maintenance
45580 $B20C Inability to change status determined by status change preprocessing
45581 $B20D Error detected during status change preprocessing
Status change preprocessing in excess of the maximum number of lines that can
45582 $B20E
be run
45583 $B20F SFC sequence or SEBOL block main program not existing
Online maintenance of the SFC sequence or SEBOL block main program yet to be
45584 $B210
completed
45585 $B211 SEBOL database not existing
45586 $B212 Cannot run a unit sequence because no dynamically allocated area is available
Cannot change the block status while unit sequence termination processing is
45587 $B213
in progress
45616 $B230 Internal error in a unit sequence
Cannot run an SFC/SEBOL block because no dynamically allocated area is
46081 $B401
available
46097 $B411 Cannot change STEPNO except in the PAUS block status
Cannot change a step to an interrupt program step (interrupt program step number
46098 $B412
cannot be set to STEPNO)
46100 $B414 Cannot change STEPNO while status change preprocessing is in progress
46101 $B415 Cannot change STEPNO while status change postprocessing is in progress
46113 $B421 Cannot change the block mode to O/S except in the STOP or ABRT block status
*1: A total of array elements in one program unit counting a simple variable as one.
*2: A compile error is caused if the size of the local variable area exceeds 2147483646($7FFFFFFE) bytes
— this area contains an area for alignment. See Table A2.2 for the alignment of variables.
*3: Including the tag names of the actions that are described in the sequence tables/logic charts in the SFC
block. The present block (%) and the present unit (%%) are not included in the count.
The size of a dummy argument array is determined by the actual argument — thus there
are no restrictions other than that the maximum number of dummy arguments usable in
a function is 32.
*1: Up to 99 SFC steps in the main program and interrupt program each.
*2: Up to 300 SFC programs across the main program and interrupt program in one SFC block.
Table 4.1a
ACOS (B) CKMODE (XL) DOUBLE (D) GETNAME (B)
ACTION (N) CKSTATUS (XL) DREADPARA (B) GETOPNAME (XL)
ALIAS (D) CKSTEP (B) DRIVE (S) GETPROC (XL)
AND (O) CKSTEPCL (B) DRIVEWAIT (S) GETTAGNO (B)
ARGBLOCK (D) CMWRITE (B) DSBREAD (XL) GETTASK (XL)
ASIN (B) CMWRITEBID (B) DSBWRITE (XL) GETTIME (B)
ASSIGN (S) COMMON (SL) DSCHECK (B) GETUNIT (XL)
ASTM1 ( CALC) COMPARE (S) DUDREAD (XL) GETURNO (XL)
ASTM2 ( CALC) CONDITION (XL) DUDWRITE (XL) GLOBAL (D)
ASTM3 ( CALC) CONFIRM (N) EFFECTIVE (XL) GOTO (S)
ASTM4 ( CALC) COS (B) ELSE (S) GROUP (XL)
ATAN (B) CP (N) END (S) HISTORY (S)
BASIC (XL) CREADPARA (B) ENTRY (S) HOLD (XL)
BEGIN (S) CRPGET (XL) EOR (O) ICHR (B)
BITPSTN (B) CRPPUT (XL) ERETURN (S) IDLE (XL)
BITSRCH (B) CSBREAD (XL) ERRC (B) IF (S)
BLOCK (D) CSBWRITE (XL) ERRCE (B) INDEPENDENT (S)
BOOT (B) CUBGET (XL) ERRF (B) INDEX (B)
CASE (S) CUBPUT (XL) ERRL (B) INEFFECTIVE (XL)
CAT (B) CUDGET (XL) ERROR (S) INITIAL (N)
CCMREAD (B) CUDREAD (XL) ERRORSUB (N) INSTRUMENT (XL)
CCMREADBID (B) CUDWRITE (XL) ERRORVAL (B) INT (B)
CCMWRITE (XL) CURGET (XL) ERRP (B) INTEGER (D)
CERRORID (B) CURPUT (XL) ERRS (B) INTERVAL (XL)
CHANGE (N) DABS (B) ESTEP (N) INVALIDATE (XL)
CHAR (D) DCMREAD (B) EVENT (N) ISIGMASK (S)
CHAR16 (N) DCMREADBID (B) EXIT (S) ISIGUNMASK (S)
CHAR32 (N) DCMWRITE (XL) EXP (B) ISTEP (N)
CHAR4 (N) DELAY (S) FLOAT (D) IUDGET (XL)
CHAR8 (N) DELAYCYCLE (S) FOR (S) LABS (B)
CHECK (S) DERRORID (B) FORMAT (S) LCMREAD (B)
CHMODE (XL) DIALOGUE (S) FUNCTION (S) LCMREADBID (B)
CHR (B) DLIMIT (B) GENERIC (XL ) LCMWRITE (XL)
CHSTATUS (XL) DMAX (B) GENNAME (D) LEFT (B)
CISTEP (N) DMIN (B) GETDATE (B) LEN (B)
*1: The text area is an object generated by compiling run lines, such as i=i+1 and FIC001.PV=10.0. Adding
to run lines increases the size of the text area. Variable areas, as for local variables, are not included in
the text area. (Precisely speaking, declaring variables generates an object for managing the variables,
with the result of an increased text area size.)
*1: The text area is an object generated by compiling run lines, such as i=i+1 and FIC001.PV=10.0. Adding
to run lines increases the size of the text area. Variable areas, as for local variables, are not included in
the text area. (Precisely speaking, declaring variables generates an object for managing the variables,
with the result of an increased text area size.)
*2: If the number of SEBOL blocks in every control area is 0, changing the number of SEBOL blocks in a
control area from 0 to any larger value requires offline generation of the control station.
The system assigns to the SEF/SEBOL block a dynamically allocated area in which
functions are executed when the system calls a function. The system deassigns the area
as soon as the function is completed with the “return” statement.
If an area needed to run an SFC/SEBOL block is not available when it is started, the
error message “Cannot run an SFC/SEBOL block because of an insufficient area” is
displayed. In this case, add to the number of more SFC/SEBOL blocks run and regener-
ate the control area, or terminate the SFC/SEBOL blocks that need not be run to create
more space in the dynamically allocated area.
Similarly, if a sufficient area is not available when a function is called, the same error
message as in the above case is also displayed. In this case, increase the SFC/SEBOL
block executable number and off-line generate the control area, or terminate the SFC/
SEBOL blocks that need not be run to create more space in the dynamically allocated
area.
The SFC/SEBOL block executable number provides a clue to determining the dynami-
cally allocated area requirement. If a sufficient dynamically allocated area is allocated,
SFC/SEBOL blocks in excess of the SFC/SEBOL block executable number can be run
concurrently. If a sufficient dynamically allocated area is not available (because SFC/
SEBOL blocks that use a large area are running), however, SFC/SEBOL blocks can only
be run below the SFC/SEBOL block executable number.
(1) SFCs
While operations would be created as text using a text editor, SFC block programs are
created graphically in SFCs. Parallel runs as described in the parallel statement in
operations cannot be used in SFC blocks. For more information on the SFCs of SFC
blocks, refer to SFC Block Function Manual (IM 33GC31-11E).
Table A6.1 lists the differences in variable declarations between CENTUM CS and XL-
BATCH.
Table A6.3 lists the differences in interrupt handling between CENTUM CS and XL-
BATCH.
Table A6.4 lists the differences in program writing between CENTUM CS and XL-
BATCH.
Tables A6.6 list the differences in built-in functions between CENTUM CS and XL-
BATCH.
[Other changes]
(1) Identifier %
CS supports the use of % as an identifier, as in %SW0001. Consequently, the modulo
operator has been changed from % for XL to mod for CS.
#define TMPAUS 4
(3) sbsts.h
sbsts.h is a system-fixed include file used to reference block statuses individually. It
defines the mask patterns of basic block statuses as #define. For how to reference block
statuses individually, see Section 7.3.3, “Block Statuses.”
.........................................................................................................................................................................................................................................
.........................................................................................................................................................................................................................................
.........................................................................................................................................................................................................................................
.........................................................................................................................................................................................................................................
.........................................................................................................................................................................................................................................
.........................................................................................................................................................................................................................................
.........................................................................................................................................................................................................................................
.........................................................................................................................................................................................................................................
.........................................................................................................................................................................................................................................
.........................................................................................................................................................................................................................................
◆ Revision Record
● Manual No. : IM 33G3C20-11E
● Title : SEBOL Function Manual
* : Denotes the release number of the software corresponding to the contents of this instruction manual.
The revised contents are valid until the next edition is issued.
IM 33G3C20-11E i