Presentation is loading. Please wait.

Presentation is loading. Please wait.

© ABB University - 1 Revision C E x t e n d e d A u t o m a t i o n S y s t e m 8 0 0 x A Chapter 11 Structured Text Course T314.

Similar presentations


Presentation on theme: "© ABB University - 1 Revision C E x t e n d e d A u t o m a t i o n S y s t e m 8 0 0 x A Chapter 11 Structured Text Course T314."— Presentation transcript:

1 © ABB University - 1 Revision C E x t e n d e d A u t o m a t i o n S y s t e m 8 0 0 x A Chapter 11 Structured Text Course T314

2 © ABB University - 2 Revision C Overview Objectives After this chapter you should be able to: Describe the Structured Text Language rules Write simple application code in ST Use Functions and Function Blocks in ST Reference Documentation 3BSE043732Industrial IT 800xA – Control and I/O Application Programming – Introduction and Design 3BSE035980Industrial IT 800xA – Control and I/O Basic Control Software – Introduction and Configuration 3BSE035981Industrial IT 800xA – Control and I/O Extended Control Software – Binary and Analog Handling Structured Text

3 © ABB University - 3 Revision C Language Elements Functions and Function Blocks Common Mistakes and Error Messages Change Language in Online Structured Text

4 © ABB University - 4 Revision C Advantages Structured Text (ST) is a high-level programming language Free layout of code and comments When in online mode the layout can be changed to Function Block or Ladder for viewing by different personnel. Text may be generated in any external text editor and pasted into the ST editor. For example you might use macros in MS Word to generate code. Structured text reads like English and is the most efficient way of writing code. You will have to learn Structured Text in any case because it is the only choice in the SFC editor! Language Elements

5 © ABB University - 5 Revision C Structured Text Editor Language Elements

6 © ABB University - 6 Revision C Comments / Assignments OperatorDescription (*…*)Comment according to IEC 1131-3. (#…#)Comment that can be nested (ABB extension). OperatorDescription :=Assigns a value (number, logical or string) to a variable ( )Parentheses. Commonly used to change the priority of an expression. (* This is not (* Inner Comment *) allowed *) (# This is (* Inner Comment *) allowed #) Result := In1 AND In2 OR In3; AverageFlow := (Flow1 + Flow2)/2; Language Elements

7 © ABB University - 7 Revision C Boolean / Arithmetic / Relational OperatorDescription NOT,Negates the Boolean value (1/0, on/off or True/False). ANDBoolean AND. &Boolean AND. See AND. XORBoolean XOR. ORBoolean OR. OperatorDescription **Exponential, i.e. raising to the power. *Multiplication /Division. +Addition. -Subtraction. MODModulus. OperatorDescription <Less than. >Greater than. <=Less than or equal to. >=Greater than or equal to. =Equal to. <>Not equal to. Language Elements

8 © ABB University - 8 Revision C Order of Precedence OperatorDescriptionPriority (…)Parenthesized expression.Highest Function (…)Parameter list of a function, function evaluation. Not, -Negation, Boolean complement, i.e. value with "opposite" value (0 becomes 1, 1 becomes 0) and arithmetical negation ( - ). **Exponentiation, i.e. raising to a power. *, /,modMultiplication, division and modulus. +, -Addition and subtraction., =Comparison operators =, <>Equality and inequality. and, &Boolean AND. xorBoolean exclusive OR orBoolean ORLowest Language Elements

9 © ABB University - 9 Revision C Conditional Statements OperatorDescription IFBoolean Expression THEN Statement(s); END_IF; If (and only If) the Boolean Expression evaluates to True, then the Statement(s) between the IF and END_IF is/are executed. IFBoolean Expression THEN Statement(s); ELSE Statement(s); END_IF; If the Boolean Expression evaluates to True, then the Statement(s) before the ELSE is/are executed. Else the statements after the ELSE and before the END_IF are executed. IFBoolean Expression 1 THEN Statement(s); ELSIFBoolean Expression 2 THEN Statement(s); ELSIFBoolean Expression n THEN Statement(s); ELSE Statement(s); END_IF; If the Boolean Expression 1 evaluates to True, then the Statement(s) before the first ELSIF is/are executed. If this condition is false then the subsequent Boolean Condition is tested and so on for each ELSIF. If no expression is true then the ELSE statement(s) execute. The ELSE clause is optional. You may have as many ELSIF clauses as you wish. OperatorDescription CASE Integer Expression OF Integer Literal1 : Statement(s); END_CASE; A statement is executed depending on the value of an integer variable or an integer expression. The is one or several integer values or one or several ranges of values. CASE Integer Expression OF Integer Literal1 : Statement(s); Integer Literal2 : Statement(s); Integer Literal3 : Statement(s); ELSE Statement(s); END_CASE; In this example, three values are tested and the appropriate statements) executed. One variation is to permit a range of values to be tested rather than an exact single value. If none of the test literals match the result of the expression then the statement(s) in the ELSE clause will be executed. If no ELSE exists, none of the statements will be executed. Language Elements

10 © ABB University - 10 Revision C Iteration Statements OperatorDescription FOR i := 0 to 15 DO Statement(s); END_FOR; The FOR statement is used to allow a statement (or statements) to be executed repeatedly for a given number of times. The counter used in the repetition process can be used in the statements. In the example, the statements between the FOR and END_FOR will be executed 16 times. WHILE Level > 80.0 DO Statement(s); END_WHILE; The WHILE statement is used in order to allow a statement (or statements) to be executed repeatedly while a certain condition is True. This separates it from the FOR statement. It has some similarities with the REPEAT statement. REPEAT Statement(s); UNTIL Boolean Expression END_REPEAT; The REPEAT statement is used in order to allow a statement (or statements) to be executed repeatedly until a certain condition is True. Note that the test to exit the loop is placed at the end, so a minimum of one execution of the statement(s) will occur even if the expression is true at the time the loop is entered. EXITUse the EXIT statement whenever you want to terminate a loop immediately and continue execution from the first line after the iteration statement. Language Elements

11 © ABB University - 11 Revision C Language Elements Functions and Function Blocks Common Mistakes and Error Messages Change Language in Online Structured Text

12 © ABB University - 12 Revision C Overview Functions and Function Blocks

13 © ABB University - 13 Revision C Declare Function Block Instances Functions and Function Blocks Absolute minimum = Name and function block Type

14 © ABB University - 14 Revision C Call a Function Block Instance (1) Functions and Function Blocks

15 © ABB University - 15 Revision C Call a Function Block Instance (2) Functions and Function Blocks

16 © ABB University - 16 Revision C Language Elements Functions and Function Blocks Common Mistakes and Error Messages Change Language in Online Structured Text

17 © ABB University - 17 Revision C Identifier, constant or opening parenthesis Common Mistakes

18 © ABB University - 18 Revision C Variable name is not unique Common Mistakes

19 © ABB University - 19 Revision C Identifier too long or invalid Common Mistakes

20 © ABB University - 20 Revision C Undefined function block Common Mistakes

21 © ABB University - 21 Revision C Type mismatch in assignment Common Mistakes

22 © ABB University - 22 Revision C Incompatible types in expression Common Mistakes

23 © ABB University - 23 Revision C Language Elements Functions and Function Blocks Common Mistakes and Error Messages Change Language in Online Structured Text

24 © ABB University - 24 Revision C Change from ST to FBD in Online Change Language

25 © ABB University - 25 Revision C


Download ppt "© ABB University - 1 Revision C E x t e n d e d A u t o m a t i o n S y s t e m 8 0 0 x A Chapter 11 Structured Text Course T314."

Similar presentations


Ads by Google