© 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.

Slides:



Advertisements
Similar presentations
Microsoft Visual Basic 2005: Reloaded Second Edition Chapter 4 Making Decisions in a Program.
Advertisements

1 Chapter Five Selection and Repetition. 2 Objectives How to make decisions using the if statement How to make decisions using the if-else statement How.
CHAPTER 5: Repetition Control Structure. Objectives  To develop algorithms that use DOWHILE and REPEAT.. UNTIL structures  Introduce a pseudocode for.
Week 6 - Programming I So far, we’ve looked at simple programming via “scripts” = programs of sequentially evaluated commands Today, extend features to:
1 CS101 Introduction to Computing Lecture 23 Flow Control & Loops (Web Development Lecture 8)
Chapter 4 Control Structures I. Objectives ► Examine relational and logical operators ► Explore how to form and evaluate logical (Boolean) expressions.
IS437: Fall 2004 Instructor: Dr. Boris Jukic Program Flow Control: Decisions and Conditions (Branching) Controlled Repetition (Looping)
1 Chapter 4 Language Fundamentals. 2 Identifiers Program parts such as packages, classes, and class members have names, which are formally known as identifiers.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Java Software Solutions Foundations of Program Design Sixth Edition by Lewis.
CSCI/CMPE 4341 Topic: Programming in Python Chapter 3: Control Structures (Part 1) – Exercises 1 Xiang Lian The University of Texas – Pan American Edinburg,
 2008 Pearson Education, Inc. All rights reserved JavaScript: Control Statements II.
IS 1181 IS 118 Introduction to Development Tools VB Chapter 03.
VB .NET Programming Fundamentals
4. Python - Basic Operators
CONTROL STATEMENTS IF-ELSE, SWITCH- CASE Introduction to Computer Science I - COMP 1005, 1405 Instructor : Behnam Hajian
Chapter 4 The If…Then Statement
Computer Science Selection Structures.
Control Structures – Selection Chapter 4 2 Chapter Topics  Control Structures  Relational Operators  Logical (Boolean) Operators  Logical Expressions.
Chapter 5 – Decisions 5.1 Relational and Logical Operators 5.2 If Blocks 5.3 Select Case Blocks.
Lecture Set 5 Control Structures Part A - Decisions Structures.
CMPS 211 JavaScript Topic 1 JavaScript Syntax. 2Outline Goals and Objectives Goals and Objectives Chapter Headlines Chapter Headlines Introduction Introduction.
PL/SQL Loops. Building Logical Conditions All logical conditions must yield a boolean condition. You can build a simple Boolean condition by combining.
Problem Solving and Control Statements. Using Exit to Terminate Repetition Statements There are many forms of the Exit statement, designed to terminate.
Programming Logic and Design Fifth Edition, Comprehensive
Chapter 3 Selections Liang, Introduction to Java Programming, Seventh Edition, (c) 2009 Pearson Education, Inc. All rights reserved
Flow of Control Part 1: Selection
1 Boolean Expressions to Make Comparisons Boolean expression –Represents only one of two states –Expression evaluates to either true or false Expressions.
CPS120: Introduction to Computer Science Decision Making in Programs.
Controlling Execution Programming Right from the Start with Visual Basic.NET 1/e 8.
VBScript Language. What is VBScript Based on the Visual Basic family of languages Supports object oriented features Interpreted Loosely Typed Implicitly.
CHAPTER 4: Selection Control Structure. Objectives  Use the relational comparison operators  Learn about AND logic  Learn about OR logic  Make selections.
CompSci 100E 2.1 Java Basics - Expressions  Literals  A literal is a constant value also called a self-defining term  Possibilities: o Object: null,
Saeed Ghanbartehrani Summer 2015 Lecture Notes #5: Programming Structures IE 212: Computational Methods for Industrial Engineering.
An Object-Oriented Approach to Programming Logic and Design Fourth Edition Chapter 4 Looping.
Chapter 3 Functions, Events, and Control Structures JavaScript, Third Edition.
Chapter 10 Function Block Diagram
© 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 x A Chapter 6 Application Structures Course T314.
JavaScript, Fourth Edition
Assignment statement: Assigns a value to a variable Variable must appear on the left side, value on the right side of the assignment operator Right side.
Chapter 5 Selection Statements Mr. Dave Clausen La Cañada High School.
Sections © Copyright by Pearson Education, Inc. All Rights Reserved.
Loops cause a section of a program to be repeated a certain number of times. The repetition continues while a condition remains true. When a condition.
Introduction to Programming Lecture Note - 2 Visual Basic Programming Fundamentals.
 Control Flow statements ◦ Selection statements ◦ Iteration statements ◦ Jump statements.
An Object-Oriented Approach to Programming Logic and Design Chapter 5 Making Decisions.
CPS120: Introduction to Computer Science Decision Making in Programs.
 2002 Prentice Hall. All rights reserved. 1 Chapter 5 – Control Structures: Part 2 Outline 5.1Introduction 5.2 Essentials of Counter-Controlled Repetition.
Control Flow (Python) Dr. José M. Reyes Álamo. 2 Control Flow Sequential statements Decision statements Repetition statements (loops)
Java Basics. Tokens: 1.Keywords int test12 = 10, i; int TEst12 = 20; Int keyword is used to declare integer variables All Key words are lower case java.
Perl Chapter 3 Conditional statements. Control Expressions Control expressions – interpreted as T/F (evaluated as strings or numbers) – simple, relational,
Concept V2.5 Lesson 17 Objectives: After completing this lesson, the learner will be able to: –Program logic using the ST Editor. –Demonstrate an Understanding.
Control Flow (Python) Dr. José M. Reyes Álamo. 2 Control Flow Sequential statements Decision statements Repetition statements (loops)
1 Lecture 2 - Introduction to C Programming Outline 2.1Introduction 2.2A Simple C Program: Printing a Line of Text 2.3Another Simple C Program: Adding.
Control Flow (Python) Dr. José M. Reyes Álamo.
Java Programming Fifth Edition
Sequence, Selection, Iteration The IF Statement
Selections Java.
Chapter 3 Control Statements Lecturer: Mrs Rohani Hassan
Chapter 4 – Control Structures Part 1
During the last lecture we had a discussion on Data Types, Variables & Operators
Chapter 8: More on the Repetition Structure
Chapter 6 Control Statements: Part 2
Introduction to Programming Using Python PART 2
Problem Solving and Control Statements
Boolean Expressions to Make Comparisons
Matlab Basics.
Structured Text a high level language
Controlling Program Flow
Problem 1 Given n, calculate 2n
Chapter 5 Selection Statements
Presentation transcript:

© 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 x A Chapter 11 Structured Text Course T314

© 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

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

© 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

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

© ABB University - 6 Revision C Comments / Assignments OperatorDescription (*…*)Comment according to IEC (#…#)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

© 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

© 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

© 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

© 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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

© ABB University - 25 Revision C