1 / 28

Concept V2.5

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 of ST Language. Concept V2.5. Overview ST is a high level language, similar to PASCAL or BASIC.

Download Presentation

Concept V2.5

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 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 of ST Language.

  2. Concept V2.5 • Overview • ST is a high level language, similar to PASCAL or BASIC. • ST is a distinct language that has been specifically developed for industrial control applications. • ST has a comprehensive range of constructs for assigning values to variables, calling FFBs, creating expressions, for conditional evaluation of selected statements, or for iteration, i.e. repeating selected section of code.

  3. Concept V2.5 • Advantages • Fairly straight forward and easy to learn and to use. • Compact formulation of a complex programming task. • Clear program construction by instruction blocks. • Powerful constructs for controlling the instruction flow. • Useful for complex mathematic solutions. • Simple solutions for difficult problems in FBD, LD or IL.

  4. Concept V2.5 • Executed operations • Logical, arithmetic, compare operations and allocations. • Complex instructions and instruction groupsunconditioned / conditioned. • Declaration of functions and function blocks. • Execute functions and function blocksunconditioned / conditioned.

  5. Concept V2.5 • Invocation of Function Blocks • Each FFB instance must be invoked once • Multiple invocation (instantiation) is allowed • FFB-call: with a list of input parameters

  6. Concept V2.5 • Statements, Expressions and Operators • A structured text program contains: • statements. • A statement contains: • Expressions • Keywords • An expression contains one or more: • Operators with Operands • Admissible Operands • Literals, all variables, elements of multi-element variables, FFB outputs or direct addresses

  7. Concept V2.5 • Statements must close with semicolons (;) One line may contain several statements, separated by (;) • The following statements are available: • VAR ... END_VAR Declaration of FFB's • Function Block Calls Invoking of FFBs • IF ... THEN ... END_IF Conditioned execution of statements • ELSIF ... THEN Conditioned execution of statements, if the preceded expression is not fulfilled (false). • ELSE ... Execution of statements, if expressions of preceded statements are not fulfilled (false). NOTE: ( ... means condition/expression)

  8. Concept V2.5 • CASE ... OF ... END_CASE A list of statements with given labels. Execution, if the label is true. • FOR ... TO ... BY ... DO ... END_FOR Repeated execution of statements up to a given number. • WHILE...DO...END_WHILE Repeated execution of statements up to preceded condition = 0. • REPEAT ... UNTIL ... END_REPEAT Repeated execution of statements up to succeeded condition = 0. • EXIT To terminate repeat statements (FOR, WHILE, REPEAT) before the end condition is true. NOTE: ( ... means condition/expression)

  9. Concept V2.5 • Keywords That Can Not Be used • TYPE...END_TYP • VAR_INPUT...END_VAR • VAR_OUTPUT...END_VAR • VAR_IN_OUT...END_VAR • VAR_EXTERNAL...END_VAR • FUNCTION...END_FUNCTION • FUNCTION_BLOCK...END_FUNCTION_BLOCK • PROGRAM...END_PROGRAM • STEP...END_STEP • TRANSITION...END_TRANSITION • ACTION...END_ACTION • SEGMENT_SCHEDULER • RETURN

  10. Concept V2.5 • Operators • Operators are generic, i.e. they automatically adjust to the data type of the operand. • The evaluation of an expression consists of applying the operators to the operands in the order defined by the rule of precedence of the operators. • The operator with the highest rule of precedence in an expression will be executed first. • Operators with the same precedence are executed from left to right, as described in the expression. • This order can be changed through bracketing.

  11. Concept V2.5 Operator Operand Significance Precedence ( ) Expression Bracketing 1 (highest) FUNCNAME ANY Function editing (call) 2 * * REAL, ANY_NUM Raising to a power 3 ­ ANY_NUM Negation 4 NOT ANY_BIT Complement 4 * ANY_NUM or TIME Multiplication 5 / ANY_NUM Division 5 MOD ANY_NUM Modulo 5 All operands also: Expression, literal, variable, direct address

  12. Concept V2.5 + ANY_NUM or TIME Addition 6 ­ ANY_NUM or TIME Subtraction 6 < ANY_ELEM Less than 7 > ANY_ELEM Greater than 7 < = ANY_ELEM Less or equal 7 > = ANY_ELEM Greater or equal 7 = ANY_ELEM Equality 8 < > ANY_ELEM Inequality 8 &, AND ANY_BIT Logic AND 9 XOR ANY_BIT Logic exclusive OR 10 OR ANY_BIT Logic OR 11 All operands also: Expression, literal, variable, direct address Operator Operand Significance precedence

  13. Concept V2.5 Input Output Default Data Type Possible Data Types %IX, %QX BOOL BOOL%I %Q %IB %QB BYTE BYTE %IW %QW INT INT, UINT, WORD %ID %QD REAL REAL, DINT, UDINT, TIME Example: %IX1 means address 100001 (input bit 1) %QW1 means address 400001 (output word 1)

  14. Concept V2.5 • Keywords, Separators and Comments • When entering keywords, separators and comments, there is an immediate spell check • If a keyword, a separator or a comment is detected, it is identified with a color shading. • If unauthorized keywords (instructions or operators) are entered, this will be identified through color shading as well. • Spaces and tabs have no effect on syntax, they can be used anywhere.

  15. Concept V2.5 • The Objects Menu

  16. Concept V2.5 • Example: Entering a direct function call • No declaration is required!

  17. Concept V2.5 • Example: Entering a function block IN, PT, Q, and ETare the labels of thepins on a TON timer

  18. Concept V2.5 • Handling, general • Create or open ST Section • Type or select statement, operator etc.:  Objects... • Type or select operand:  Edit  Lookup variables • Type or select FFB:  Objects  Insert FFB or click on • Insert FFB see next slide

  19. Concept V2.5 • Insert FFB • Browse and select FFB • Declaration • Invocation • Assignment

  20. Concept V2.5 • Use Expand statement to complete e.g.,VAR ... END_VAR • Use Go to counterpart to find e.g.,second bracket ( ) • Enter comments, consider Options, Preferences! • Syntax check:  Project  Analyze Section. • Any errors found are displayed in the message window. • Double click on the first line means:go to the line with the first error in ST.

  21. Concept V2.5

  22. This area used for Upload function Concept V2.5 • Before closing the ST section, go to  Project  Code generation options creates additional information forprocess diagnosis during code generation generates a runtime­optimized code Tests loops within ST (and IL) sections • Code generation together with the syntax check will be performed when the section is closed.

  23. Concept Programming in ST ST Example • Comment • FFB-Declaration • AND-Function with Allocation • FFB call with Allocation • AND-Function with Allocation • FFB call with Allocation

  24. Concept V2.5 Watch Selected Inspect Selected

  25. Concept V2.5 • Select variable with double click • Animation Selected mode or • Go to Online  Watch Selected • Repeat for next variable • Remains open until it is closed or the animation is terminated • A dialog box can be opened for each section

  26. Concept V2.5 • Select variable with double click • go to menu Online  Inspect Selected • set cursor to any position on section • click left mouse button • Set cursor into cyan field • depress right mouse button • select operation mode: • Move field to another position • Delete field or • Options... see next slide

  27. Concept V2.5 • Select operation mode options... • Enter Minimum/Maximum • Notice the color change Yellow Magenta

  28. Structured Text Demonstration and Lab

More Related