TABLE OF CONTENTS LIST OF ILLUSTRATIONS

Similar documents
TABLE OF CONTENTS SECTION TITLE 1.0 INTRODUCTION DESCRIPTION RELATED LITERATURE LADDER LOGIC ELEMENTS...

Structured Text Programming

\n is used in a string to indicate the newline character. An expression produces data. The simplest expression

PHPoC vs PHP > Overview. Overview

1 Lexical Considerations

Chapter 1 Summary. Chapter 2 Summary. end of a string, in which case the string can span multiple lines.

Language Reference Manual

PHPoC. PHPoC vs PHP. Version 1.1. Sollae Systems Co., Ttd. PHPoC Forum: Homepage:

Alternate Appendix A: Using the TI-92 Calculator

CHAD Language Reference Manual

Contents. Jairo Pava COMS W4115 June 28, 2013 LEARN: Language Reference Manual

CHIL CSS HTML Integrated Language

Introduction to Visual Basic and Visual C++ Arithmetic Expression. Arithmetic Expression. Using Arithmetic Expression. Lesson 4.

YOLOP Language Reference Manual

Decaf Language Reference Manual

WEEK 4 OPERATORS, EXPRESSIONS AND STATEMENTS

Language Reference Manual

ISaGRAF complies with the requirements set forth in IEC , for the following language features:

Ordinary Differential Equation Solver Language (ODESL) Reference Manual

Lexical Considerations

CA4003 Compiler Construction Assignment Language Definition

Operators. Java operators are classified into three categories:

KE Process Automation project work - ABB 800xA PLC programming

The PCAT Programming Language Reference Manual

MATVEC: MATRIX-VECTOR COMPUTATION LANGUAGE REFERENCE MANUAL. John C. Murphy jcm2105 Programming Languages and Translators Professor Stephen Edwards

GridLang: Grid Based Game Development Language Language Reference Manual. Programming Language and Translators - Spring 2017 Prof.

BoredGames Language Reference Manual A Language for Board Games. Brandon Kessler (bpk2107) and Kristen Wise (kew2132)

IPCoreL. Phillip Duane Douglas, Jr. 11/3/2010

Language Reference Manual simplicity

Lexical Considerations

x = 3 * y + 1; // x becomes 3 * y + 1 a = b = 0; // multiple assignment: a and b both get the value 0

Control Structures. CIS 118 Intro to LINUX

C/C++ Programming Lecture 7 Name:

An algorithm may be expressed in a number of ways:

A complex expression to evaluate we need to reduce it to a series of simple expressions. E.g * 7 =>2+ 35 => 37. E.g.

Objectives. Introduce the core C# language features class Main types variables basic input and output operators arrays control constructs comments

Basics of ST. Each must end with a semi-colon (";") Basic statement. Q:=IN; Q:=sin(angle); Q := (IN1 + (IN2 / IN 3)) * IN4;

Industrial Automation course

Le L c e t c ur u e e 2 To T p o i p c i s c t o o b e b e co c v o e v r e ed e Variables Operators

Senet. Language Reference Manual. 26 th October Lilia Nikolova Maxim Sigalov Dhruvkumar Motwani Srihari Sridhar Richard Muñoz

Data Types and Variables in C language

LESSON 1. A C program is constructed as a sequence of characters. Among the characters that can be used in a program are:

C++ Programming: From Problem Analysis to Program Design, Third Edition

Visual C# Instructor s Manual Table of Contents

UNIT- 3 Introduction to C++

Petros: A Multi-purpose Text File Manipulation Language

Fundamental of Programming (C)

ESCI 386 IDL Programming for Advanced Earth Science Applications Lesson 1 IDL Operators

The Absolute Value Symbol

Statements and Operators

Chapter 3: Operators, Expressions and Type Conversion

Chapter 2. C++ Basics. Copyright 2014 Pearson Addison-Wesley. All rights reserved.

egrapher Language Reference Manual

CS1622. Semantic Analysis. The Compiler So Far. Lecture 15 Semantic Analysis. How to build symbol tables How to use them to find

Operators and Expressions in C & C++ Mahesh Jangid Assistant Professor Manipal University, Jaipur

easel LANGUAGE REFERENCE MANUAL

MATLIP: MATLAB-Like Language for Image Processing

Unit 3. Operators. School of Science and Technology INTRODUCTION

Transform data - Compute Variables

DEPARTMENT OF MATHS, MJ COLLEGE

Full file at

Sketchpad Graphics Language Reference Manual. Zhongyu Wang, zw2259 Yichen Liu, yl2904 Yan Peng, yp2321

Java provides a rich set of operators to manipulate variables. We can divide all the Java operators into the following groups:

Expr Language Reference

GraphQuil Language Reference Manual COMS W4115

Assoc. Prof. Dr. Marenglen Biba. (C) 2010 Pearson Education, Inc. All rights reserved.

Chapter Overview. C++ Basics. Variables and Assignments. Variables and Assignments. Keywords. Identifiers. 2.1 Variables and Assignments

corgi Language Reference Manual COMS W4115

CSc 10200! Introduction to Computing. Lecture 2-3 Edgardo Molina Fall 2013 City College of New York

bc an arbitrary precision calculator language version 1.06

VENTURE. Section 1. Lexical Elements. 1.1 Identifiers. 1.2 Keywords. 1.3 Literals

BASIC ELEMENTS OF A COMPUTER PROGRAM

Chapter 2. C++ Basics. Copyright 2014 Pearson Addison-Wesley. All rights reserved.

Chapter 2. C++ Basics

TED Language Reference Manual

TABLE OF CONTENTS SECTION AND TITLE

Full file at C How to Program, 6/e Multiple Choice Test Bank

Unit-II Programming and Problem Solving (BE1/4 CSE-2)

PLT Fall Shoo. Language Reference Manual

Data Structure using C++ Lecture 04. Data Structures and algorithm analysis in C++ Chapter , 3.2, 3.2.1

SPARK-PL: Introduction

EDIABAS BEST/2 LANGUAGE DESCRIPTION. VERSION 6b. Electronic Diagnostic Basic System EDIABAS - BEST/2 LANGUAGE DESCRIPTION

Here n is a variable name. The value of that variable is 176.

INTRODUCTION TO ABAP PROGRAMMING: SYNTAX FUNDAMENTALS

7/8/10 KEY CONCEPTS. Problem COMP 10 EXPLORING COMPUTER SCIENCE. Algorithm. Lecture 2 Variables, Types, and Programs. Program PROBLEM SOLVING

Chapter 4: Basic C Operators

Structured Text TM246

CGS 3066: Spring 2015 JavaScript Reference

Department of Computer Science

Java+- Language Reference Manual

COLOGO A Graph Language Reference Manual

Mirage. Language Reference Manual. Image drawn using Mirage 1.1. Columbia University COMS W4115 Programming Languages and Translators Fall 2006

CMAT Language - Language Reference Manual COMS 4115

function [s p] = sumprod (f, g)

Spoke. Language Reference Manual* CS4118 PROGRAMMING LANGUAGES AND TRANSLATORS. William Yang Wang, Chia-che Tsai, Zhou Yu, Xin Chen 2010/11/03

GeoCode Language Reference Manual

Declaration and Memory

Java Notes. 10th ICSE. Saravanan Ganesh

JAVA OPERATORS GENERAL

UNIT-II. Part-2: CENTRAL PROCESSING UNIT

Transcription:

CG39-28 CONTENTS TABLE OF CONTENTS SECTION AND TITLE PAGE 1.0 INTRODUCTION... 1-1 1.1 DESCRIPTION... 1-1 1.2 RELATED LITERATURE... 1-2 2.0 EXPRESSIONS... 2-1 3.0 STATEMENTS... 3-1 3.1 DECLARATION STATEMENTS... 3-1 3.1.1 Variable Declaration Statements... 3-2 3.1.2 Standard and Derived Function Block Declaration Statements... 3-3 3.2 ASSIGNMENT STATEMENT... 3-4 3.3 FUNCTION BLOCK CONTROL STATEMENTS... 3-5 3.4 SELECTION STATEMENTS... 3-7 3.4.1 IF...END_IF Statement... 3-7 3.4.2 CASE...END_CASE Statement... 3-8 3.5 ITERATION STATEMENTS... 3-10 3.5.1 FOR...END_FOR Statement... 3-11 3.5.2 WHILE...END_WHILE Statement... 3-12 3.5.3 REPEAT...END_REPEAT Statement... 3-12 3.5.4 EXIT Statement... 3-13 4.0 STRUCTURED TEXT INSIDE A DFB... 4-1 LIST OF ILLUSTRATIONS FIGURE AND TITLE PAGE 3-1 Structured Text Declaration and Expression Example... 3-3 3-2 A Function Block Declaration Statement Example... 3-4 3-3 Function Block Control Statement Example... 3-6 3-4 IF...END_IF Statement Example... 3-8 3-5 CASE...END_CASE Statement Example... 3-9 3-6 FOR...END_FOR Statement Example... 3-11 3-7 WHILE...END_WHILE Statement Example... 3-12 3-8 REPEAT...END_REPEAT Statement Example... 3-13 4-1 Pressure and Temperature Compensation DFB... 4-1 4-2 Body of Pressure and Temperature Compensation DFB... 4-2 i

CONTENTS CG39-28 LIST OF TABLES TABLE AND TITLE PAGE 2-1 Operators in Structured Text... 2-1 3-1 Iteration Statement Summary... 3-10 SIGNIFICANT CHANGES FOR REVISION 2 The significant change for revision 2 of this document is listed below. This and other minor changes are identified by change bars located in the page margins. 3.5 ITERATION STATEMENTS - This section has been updated with a new information about how control modules respond to endless loops in iteration statements. Moore Products Co. assumes no liability for errors or omissions in this document or for the application and use of information included in this document. The information herein is subject to change without notice. The Moore logo, APACS, the APACS logo, QUADLOG, and 4-mation are trademarks of Moore Products Co. All other trademarks are the property of the respective owners. ii

CG39-28 CONTENTS 1997 Moore Products Co. All rights reserved. iii

CG39-28 INTRODUCTION 1.0 INTRODUCTION This Guide provides reference information for the Structured Text (ST) language of the 4-mation configuration software. It is intended to be used in conjunction with the configuration procedures located in Using the 4-mation Configuration Software (document number CG39-20). This Guide is arranged into the following sections: C Section 1, Introduction C Section 2, Expressions C Section 3, Statements C Section 4, Example of Structured Text Inside a DFB 1.1 DESCRIPTION The structured text (ST) language supplements the other graphical configuration languages with a text-based programming tool. It is typically used for functions that are more easily implemented in a programming environment than in a graphical format. This is often the case for items such as initialization procedures or process calculations involving complex math operations. The Structured Text language is entered on an editable text sheet (no cells). In the ST language, configuration elements are textual expressions used to create structured text statements. A group of statements is called a structured text file. The statements are created by typing them on the sheet. The elements permitted in a ST file include: C Structured Text Expressions C Standard Function Blocks C Derived Function Blocks C User-Defined Function Blocks C Variables C Comments All function blocks are declared in structured text like variables, where the Type is one of the function block types (e.g. PID) as opposed to a data type. 1-1

INTRODUCTION CG39-28 1.2 RELATED LITERATURE The following documents are available to complement the use of structured text. Refer to these documents as needed or as called for in text. C APACS Basic Application Library (document CG39-23, located in binder UM39-15) * * C APACS Standard Function Blocks (document CG39-22, located in binder UM39-12) * * C QUADLOG Standard Function Blocks (document CGQL-3, located in binder UM39-12) * * C Using the 4-mation Configuration Software Version 4.20 or Higher (document CG39-20, located in * binder UM39-11) * # 1-2

CG39-28 EXPRESSIONS 2.0 EXPRESSIONS Expressions consist of operands and operators. Operands can be numbers, variables, function block invocations, or expressions. Operators are applied to the operands and the expression is evaluated. Multiple operands are permitted in one expression. The order of evaluation is from the operator with the highest precedence to the operator with the lowest precedence. If the operators have equal precedence then they are evaluated from left to right. The precedence of ST operators is defined in the following table: TABLE 2-1 Operators in Structured Text TYPE SYMBOL PRECEDENCE Parenthesis (expression) Highest Exponentiation ** Negation, Complement -, NOT Multiply, Divide, *, /, MOD Modulo Add, Subtract +, - Comparison <, >, <=, >= Equality = Inequality <> Boolean AND & or AND Boolean OR OR Assignment := Lowest The following examples show the results of precedence in expressions: If A = 1.0, B = 2.0, C = 3.0 then: A + 4 - C/B equals 3.5 A + (4 - C)/B equals 1.5 A * 4 - C/B equals 2.5 A * (4 - C)/B equals 0.5 For exponentiation, the data type of the exponent must match the data type of the base. For example, if A and F are REALs then the statement F: = A**(0.5); is correct, not F: = A**(1/2); However, if N and I are integers then N: = I**(1/2); is correct, not N: = I**(0.5); # 2-1

EXPRESSIONS CG39-28 2-2

CG39-28 STATEMENTS 3.0 STATEMENTS A statement is an expression followed by a semicolon. The syntax in this document used for all statements is shown in the following format: C Square brackets [ ] indicate an optional portion of the statement C Regular brackets { } indicate user-defined variables, statements or expressions C No delimiters and bold print indicate a necessary component of the statement C Spaces are allowed between operators in any quantity For memory usage and ACM execution time information on all standard configuration elements, see Appendix C in Using the 4-mation Configuration Software (document number CG39-20). IMPORTANT The keywords in Structured Text statements are not case sensitive, but variable names used in the statements are. 3.1 DECLARATION STATEMENTS Declaration statements allow variables and function blocks to be recognized inside ST programs. These statements must exist before a variable can be used or before a function block can be invoked (called). For this reason, a sheet using structured text usually begins with the declaration keyword sequence. The declaration statement is comprised of two parts: C The declaration key words (VAR and END_VAR) C The declaration operator (the colon, : ) All Declaration Statements must be located within the declaration key words. The syntax of the statement is shown in the description of each type of declaration statement, while the syntax of the key words is shown below: Syntax of Declaration Key Words: VAR {declaration statement} : : {declaration statement} END_VAR These keywords are used to declare local variables and function blocks. However, if it is desired to declare a variable and make it a retained variable, one which retains its value through a warm restart, the following keyword must be used instead. 3-1

STATEMENTS CG39-28 Syntax of the Retain Declaration Key Words: VAR RETAIN {variable declaration statement} : : {variable declaration statement} END_VAR 3.1.1 Variable Declaration Statements The Variable Declaration Statements create local variables in the ST program. Global variables can be created via the Variable Declaration dialog box only. All the same limitations on variable names apply: variable names are case sensitive and can have a maximum of 16 characters (including the 10 numeric characters, upper and lower case of the 26 alphabetic characters, and the underscore character), and variable names cannot begin with a numeric character. The data type must also be assigned in the Variable Declaration Statement. Typical data types are: BOOL, REAL, INT, SINT, DINT, UINT, USINT, UDINT, TIME, DATE, TIME_OF_DAY, WORD, DATE_AND_TIME, and STRING Data types are defined in the Basic Configuration Elements section of Using the 4-mation Configuration Software (document number CG39-20). An initial value can be assigned if desired. Initial values are assigned at start up and at warm or cold restarts. This means any changes to the initial value will not be reflected by the variable until the controller is restarted. The syntax of the Variable Declaration Statement is shown below. Syntax of the Variable Declaration Statement: {variable name} : {data type} [:= {initial value}] ; or {variable name},{variable name},...,{variable name} : {data type} [:= {initial value}] ; The ST statements in Figure 3-1 demonstrate the declaration of local variables. Note that the declaration statements are located within the declaration key words and that an initial value is assigned to all variables declared in the same declaration statement. 3-2

CG39-28 STATEMENTS 00001108 FIGURE 3-1 Structured Text Declaration and Expression Example 3.1.2 Standard and Derived Function Block Declaration Statements Any function block can be used on a Structured Text sheet, including standard, derived, and user-defined function blocks. A function block must be declared in the declaration section of the sheet before it can be used in the body of the sheet. In a function block declaration statement, an instance name or list of instance names is associated with a particular function block type to create one or more instances of that type. If a list is used, the names on the list are separated by a comma. Each instance name is used in the invoking statement described in Section 3.3. Derived or user-defined types must have been previously defined in the Function Block Type dialog box, or in an Application Library, before they may be used on a structured text sheet. In a declaration of a standard function block with a soft list (e.g. PID), an optional list of soft list starting values, described below, may also be specified. The list follows the function block Type name and is enclosed in parentheses. Each list entry assigns a starting value to a named soft list parameter, and the list entries are separated by a semicolon (;). A function block declaration statement must be located between VAR and END_VAR keywords in the declaration section at the top of a structured text sheet. Syntax of the Function Block Declaration Statement: {instance name [,{instance name},...] : {function block type name}[({soft List parameter}:=constant;{soft List parameter}:=constant...)]; Any soft list parameters not specified in the optional list take on default starting values, as described in the documentation under the particular function block type. The soft list parameters specified on the list use the corresponding constants as starting values, when the database is first transferred to an on-line control module. These starting values are also be used on subsequent off-line to on-line transfers, if and only if the structured text sheet is downloaded while off-line. In all other cases, the most recent on-line soft list values are preserved. This means that if the sheet is downloaded while on-line, any soft list starting values in the list are ignored. It also means that at any time after the first transfer to on-line, the actual current value of a soft list 3-3

STATEMENTS CG39-28 parameter may be different from the specified starting value. The actual current value of a soft list parameter in an on-line database can be accessed via the Variable Control dialog box, the SET_VAL function block, or an operator interface. At a cold start or warm start, all soft list parameters are reset to default values and any specified starting values are ignored. In this respect, soft list starting values are different from variable initializers. If a function block does not have any soft list parameters, the parenthesis portion of the statement can be omitted. A representative function block declaration statement is shown in Figure 3-2. 00001107 FIGURE 3-2 A Function Block Declaration Statement Example In this example, the Lead Lag function block has been given the instance name of LAG1, and all the soft list parameters have been assigned values. Note that the soft list parameters are separated by semicolons and that constants must be used to assign starting values to the soft list parameters. When this function block is invoked, the instance name is be used (invoking is explained in section 3.3). 3.2 ASSIGNMENT STATEMENT The assignment statement consists of: C A variable name destination C The assignment operator (:=) C An expression source C A terminating semicolon The assignment operator is a colon followed by an equal sign (:=). The variable on the left of the assignment operator is given the current value of the expression on the right of the operator. For example, the assignment statement A:=B+C (previously shown in Figure 3-2) would cause the current value of A to be replaced with the value of the expression B+C. 3-4

CG39-28 STATEMENTS Syntax of the Assignment Statement: {variable name} := {expression} ; 3.3 FUNCTION BLOCK CONTROL STATEMENTS Function block control statements consist of invoking (calling) a standard, derived, or user-defined function block from ST and returning control to the main program. A function block is typically invoked in cases where repeating the code of the block in ST would be cumbersome. To invoke a function block, at least two statements are required: one statement sets the input values of the block, and the other statement(s) read(s) the output value(s). Syntax of the Invoking Function Block Control Statement: {instance name} ( {input nub name} := {variable or constant}, {input nub name} := {variable or constant}...) ; {variable name} := {instance name}.{output nub name} ; NOTE The input and output nub names come from the standard function block that is being invoked. See the example below. The example shown in Figure 3-3 shows two flip-flops configured in both Function Block Diagram and in Structured Text. Note that all variable names are the same to demonstrate the equivalent configuration in each language. For example, the input nub S1 of the flip-flop block is used in the function block control statement. For additional information on the SR block, refer to the appropriate document as listed here: C APACS Standard Function Blocks (document number CG3922, located in binder UM39-12) C QUADLOG Standard Function Blocks (document number CGQL-3, located in binder UM39-12) 3-5

STATEMENTS CG39-28 = FIGURE 3-3 Function Block Control Statement Example 00001109 IMPORTANT Figure 3-3 shows the equivalent configuration, not the body of the SR flipflop. Creating a derived function block to mimic the SR flip-flop and copying the function in ST would need passed variables and additional code in the ST file. In the above example, one SR (set-reset) flip-flop is given the instance name of FlipFlop1 and the other FlipFlop2. Parentheses are not necessary in the declaration statement because the SR block does not have any soft list parameters. The control statements identify the function blocks by their instance names and assign values to the input variables. Note that the inputs are separated by commas. The first output assignment assigns the value of the output of the SR block identified as FlipFlop1 to the local variable 1varout1. The second output assignment assigns the value of the output of the SR block identified as FlipFlop2 to the local variable lvarout2. The order of the inputs in the function block control statement has no effect on the functionality. All inputs do not have to be assigned a value in the control statement but it is the only place these assignments are permitted. If an input is not assigned a value in the control statement, the default or initial value is used. Returning Control The RETURN statement allows early termination from an ST program before all statements are executed. Syntax of the return function block control statement: RETURN ; 3-6

CG39-28 STATEMENTS 3.4 SELECTION STATEMENTS The selection statements include the IF...END_IF and the CASE...END_CASE statements. Both choose a particular course of action based on the value of the expression. 3.4.1 IF...END_IF Statement The IF...END_IF statement selects a group of statements (one or more) to be executed when the IF expression is TRUE, or a different group of statements (zero or more) to be executed if the IF expression is FALSE. There are four parts to the IF...END_IF statement: C IF C ELSIF C ELSE C END_IF The first part, the IF, is mandatory. The IF provides the first expression that is evaluated. If this expression is TRUE, the statements following THEN are evaluated. The second portion of the IF...END_IF is the ELSIF. There may be none, one, or multiple ELSIF statements in an IF...END_IF statement. The ELSIFs are only evaluated if the IF portion is FALSE. Once one ELSIF is found to be TRUE, the statements inside are executed and no other ELSIFs are evaluated; IF...END_IF is complete. If no ELSIFs are found to be TRUE, the statement(s) following the ELSE is executed. There may either be one or no ELSE statement in an IF...END_IF statement. The fourth part of an IF...END_IF is the END_IF statement. The END_IF, with the ending semicolon, is mandatory since it terminates the statement. Syntax of the IF...END_IF Statement: IF {expression} THEN {statement(s)} ; [ELSIF {expression} THEN {statement(s)} ;]... [ELSE {statement(s)} ;] END_IF ; 3-7

STATEMENTS CG39-28 An example of an IF...END_IF statement is shown in Figure 3-4. 00001110 FIGURE 3-4 IF...END_IF Statement Example 3.4.2 CASE...END_CASE Statement The CASE...END_CASE statement also selects one group of statements to be executed, but it uses integer values to arbitrate. Each CASE...END_CASE statement can have several different groups of statements to be executed on a selective basis. Each of these groups can be selected based on an integer value, a group of integer values, a range of integer values or an ELSE. If the value of the integer selector matches an integer value in one of the CASE groups, then the statements in that group, and only that group, are executed. If the selector does not match any of the integers of a CASE group, and there is an ELSE statement within the CASE...END_CASE statement, then the statements contained in the ELSE statement are executed. As with the IF...END_IF statement, there may be one or no ELSE statement in the CASE...END_CASE statement. Syntax of the CASE...END_CASE Statement: CASE {integer variable name or integer expression} OF {integer, integer series or integer range} : {statement(s)} ; : : {integer, integer series or integer range} : {statement(s)} ; [ELSE {statement(s)} ;] END_CASE ; 3-8

CG39-28 STATEMENTS Figure 3-5 shows an example of a CASE...END_CASE statement. Note that a range of integers is * represented by the low value, two dots, then the high value. Whereas, in a series of integers, each value is * separated with a comma. * * 00001111 FIGURE 3-5 CASE...END_CASE Statement Example 3-9

STATEMENTS CG39-28 3.5 ITERATION STATEMENTS Iteration statements are used when a statement or group of statements is to be executed repeatedly. There are three iteration statements: C FOR...END_FOR C WHILE...END_WHILE C REPEAT...END_REPEAT These statements are summarized in Table 3-1. TABLE 3-1 Iteration Statement Summary ITERATION STATEMENT FOR...END_FOR WHILE...END_WHILE REPEAT...END_REPEAT STATEMENT SUMMARY Statements within may not be executed because test for execution is done before any statements are executed. Use when number of iterations is known. Statements within may not be executed because the test for execution is done before any statements are executed. All statements are executed at least once because the test for execution is done after the statements are executed. WARNING * * Any iteration statement that takes more than 4 seconds to execute during a single scan is * considered to be an endless loop. For this reason, use the iteration statements with * great care, and do not configure loops that could exceed this time limit. * * Starting with ACM software version 4.20 (which ships with 4-mation 4.20), an endless * loop is detected if it exceeds 4 seconds in one scan. The control module stops executing the * Action or DFB containing the endless loop and posts a class 4 error (SSC 08, EC 09). In * this case, the module does not reset. Normal operation can be restored by correcting the * structured text sheet containing the endless loop and downloading this sheet. * * In previous ACM software versions, the control module (ACM) is automatically reset * when an 8 second time limit is reached. All configuration information is lost. After a reset, * the configuration database must be reloaded using 4-mation (using the menu selection File, * Transfer, Resource). * * For safety, these iteration statements are not available for QUADLOG control module * (ACM, CCM) configuration. They can only be used in an APACS control module (ACM) * or Satellite Control Module (SCM). Cut and paste operations between APACS and * QUADLOG control modules automatically prevent an iteration loop from being pasted into * a QUADLOG control module. * 3-10

CG39-28 STATEMENTS 3.5.1 FOR...END_FOR Statement The FOR statement is used when the number of executions required is known. The FOR...END_FOR statement increments or decrements a value until the end value has been reached. The test for completion is done each scan before the DO statements are executed so that the iteration is executed again if the end value has been reached. The initial value and the final value can be integer constants or integer variables, while the increment value (located in the BY portion of the statement) must be an integer constant. If the increment value is not included in the statement, it is assumed to be 1. Therefore, to create a decrementing loop, the incrementing value must be explicitly stated as negative. These iteration-controlling values cannot be altered by any of the statements inside the FOR...END_FOR statement. The END_FOR line terminates the FOR...END_FOR statement. Syntax of the FOR...END_FOR Statement: FOR {INT variable} := {INT var. or constant} TO {INT var. or constant} [BY {constant}] DO {statement(s)} ; END_FOR ; NOTE The iteration variable and the initial and final values of the iteration variable must be of data type INT, SINT and DINT. Other data types are not accepted. The example in Figure 3-6 illustrates the FOR...END_FOR statement. 00001112 FIGURE 3-6 FOR...END_FOR Statement Example 3-11

STATEMENTS CG39-28 3.5.2 WHILE...END_WHILE Statement The WHILE...END_WHILE statement executes all the statements it contains while the given Boolean expression is TRUE. If the Boolean expression is FALSE at the onset, then none of the statement(s) within that WHILE...END_WHILE are executed. Syntax of the WHILE...END_WHILE Statement: WHILE {Boolean expression} DO {statement(s)} ; END_WHILE ; The example shown in Figure 3-7 shows how the FOR...END_FOR example (shown previously) can be written as a WHILE...END_WHILE statement, although the WHILE...END_WHILE is not normally used when the number of iterations is known. 00001113 FIGURE 3-7 WHILE...END_WHILE Statement Example 3.5.3 REPEAT...END_REPEAT Statement The REPEAT...END_REPEAT statement works the same way as the WHILE...END_WHILE statement. The statements within the REPEAT...END_REPEAT statement are executed until the given Boolean expression becomes TRUE. The Boolean expression follows the keyword UNTIL and must be located immediately preceding the...end_repeat keyword. Syntax of the REPEAT...END_REPEAT Statement: REPEAT {statement(s)} ; UNTIL {Boolean expression} 3-12

CG39-28 STATEMENTS END_REPEAT ; The example in Figure 3-8 shows how the previous examples used for the other iterative statements can be written using REPEAT...END_REPEAT. 00001114 FIGURE 3-8 REPEAT...END_REPEAT Statement Example 3.5.4 EXIT Statement The EXIT statement can only be used inside any of the iteration statements. It is used to leave the iteration before the end value has been reached. For an example of the EXIT statement, refer to Figure 3-6. # 3-13

STATEMENTS CG39-28 3-14

CG39-28 STRUCTURED TEXT INSIDE A DFB 4.0 STRUCTURED TEXT INSIDE A DFB This section presents an example of structured text inside a derived function block (DFB). The Figures 4-1 and 4-2 show the Pressure and Temperature compensation block (P_T_COMP_FLOW) obtained from the Basic Application Library. Notice the input and output nub names of the DFB are used in the structured text file with brackets around them indicating that they are passed either from or to the sheet above it in the configuration hierarchy. Using brackets allows the value connected to the PRESS input nub and all other input nubs to be passed to the ST calculations and allows the ST calculations to assign a value to the FLOW output(s). 00001115 FIGURE 4-1 Pressure and Temperature Compensation DFB 4-1

STRUCTURED TEXT INSIDE A DFB CG39-28 00001116 FIGURE 4-2 Body of Pressure and Temperature Compensation DFB # 4-2