Translate

Structured Text (ST)


Programming has been developed as a more modern programming language. It is quite similar to languages such as BASIC and Pascal.Structured Text (ST) is a high level textual language that is a Pascal like language. It is very flexible and intuitive for writing control algorithms.Structured Text (ST) is a high level textual language that is a Pascal like language. It is very flexible and intuitive for writing control algorithms.Structured Text uses operators such as logical branching, multiple branching, and loops. People trained in computer programming languages often find it the easiest language to use for programming control logic. When symbolic addressing is used, ST programs resemble sentences, making it highly intelligible to beginner users as well.ST is ideal for tasks requiring complex math, algorithms or decision-making. Its concise format allows a large algorithm to be displayed on a single.

Benefits of Structured Text



  • People trained in computer languages can easily program control logic
  • Symbols make the programs easy to understand
  • Programs can be created in any text editor
  • Runs as fast as ladder logic

Code

The following is few example to show some typical Structured Text code:

Example 1We have a level switch in a tank that indicates that the level of liquid in the tank is extremely high; Hence we want to trigger the siren when this happens.Siren := NOT Level_Switch ;

Example 2We have a light that will be turned on by 2 switches. If any of the switches is in ON position then the light will turn ON.Light := SwitchA OR SwitchB;

Examples 3We have Motor that will be controlled manually by 2 push buttons (Start Push Button, and Stop Push Button). When the Start Push Button is pushed then the Motor will be turned ON. and when the Stop Push Button is Pushed then we want to stop the Motor. (Security logic has been taken off this logic, for the purpose of domonstration.)IF StartPb THENMotor := 1;END_IF;IF StopPb THENMotor := 0;END_IF;

Introduction 

Welcome to the Structured Text training. We have worked very hard to make this document very easy and simple to understand to new programmers. Structured Text programmers guide is a comprehensive manual on programming with Structured Text

Structured Text

Structured Text programming is very powerful language. If you can do it in Ladder Logic or Function Block or any other language, then it can probably be accomplished using Structured Text. As you might guess, there is a lot to be learned before you can consider yourself a guru; but once you understand the basics of Structured Text you will find that you are very productive in no time at all.

Language Basics

Even a small program in Structured Text uses many of the traditional features of high-level language including variables, operators, and control flow statements. The code might look a little mysterious for programmers who have no knowledge in High-Level programming for now. But this trail teaches what you need to know about the nuts and bolts of the Text Structure programming language.

  • Variables : Variables in Structured Text program are used to hold data.
  • Operators : such as arithmetic and assignment operations.
  • Expressions : Is a combination of operators and variables into sequences known as expressions. Expressions are the building blocks of your code.
  • Control Flow : Programs use control flow statements to conditionally execute statements, to loop over statements, or to jump to another area in the program.

Structured Text Learning Curve

Structured Text is the fastest and easiest way to create programs in controllers. Whether you are an experienced professional or brand new to PLC programming, Structured Text provides you with a complete set of tools to simplify rapid program development.So what is Structured Text? The "Structured" part refers to the high level programming capabilities and "Text" refers to the ability to used text instead of symbols as in Ladder Logic, Function Block and Sequential Function Chard. If you've ever used any high level language such as basic, Pascal or C then you will most probably have the skills to create simple program without any difficulties in any time.Like any other high level language Structured Text contains many functions, and keywords, many of which are to do equivalent functions as in the other languages. Beginners can create useful applications by learning just a few of the keywords, yet the power of the language allows professionals to accomplish anything that can be accomplished using any other language.Whether your goal is to create a small function or to develop large and sophisticated automation programs Structured Text programming language has the tools you need. The existence of Structured Text Language is not to replace any of the other languages. Each language has it's own advantages and disadvantages. One of the main advantages in Structured Text is its ability to simplify complex mathematical equations.

OPERATORS

In Structured Text you manipulate data using operators and functions. Structured Text is very similar to Pascal, so most of these operators will be familiar to Pascal oor any High Level Programmer.An operator is a code unit that performs an operation on one or more value-returning code elements. Such an operation can be an arithmetic operation such as addition or multiplication; a comparison operation that determines which of two values is greater; a logical operation evaluating whether two expressions are both true.Comparison OperatorsComparison Operators compare two values or strings to provide a true or false result. The result of a comparison operation is a boolean value. Comparison operators generate a boolean result. They evaluate the relationship between the values of the operands.A comparison expression produces true if the relationship is true, and false if the relationship is untrue.

Logical Operators

Logical Operators let you check if multiple conditions are true or false. The result of a logical operation is a boolean value. All logical operators have one output. They are either On or Off, depending on the logic status of their inputs.

Bitwise Operators

Bitwise Operators manipulate the bits within a value based on two values. Bitwise operators allow you to manipulate individual bits in an integral primitive data type. Bitwise operators perform boolean algebra on the corresponding bits in the two arguments to produce the result.

Order of Execution - Precedence

Operator precedence defines how an expression evaluates when several operators are present. Structured Text has specific rules that determine the order of execution. The easiest one to remember is that multiplication and division happen before addition and subtraction. Programmers often forget the other precedence rules, so you should use parentheses to make the order of evaluation explicit.

CONSTRUCTS 

Flow Control Statement

Structured Text like most high level languages uses execution control statements, so if you've programmed with Pascal, C, or Java most of what you see will be familiar. Most procedural programming languages have some kind of control statements, and there is often overlap among languages.Structured Text have few flow control methods that simplifies and improve the code complexity when trying to read the code.

Iterration / Looping

In most programming applications you'll need to do the steps over and over again. This process is known as iteration. It is also frequently referred to as looping, because it usually involves setting up the program so that it will loop back and repeat itself.Depending on how a program is written, it can easily get stuck in the loop and keep on repeating itself forever causing the controller to reach its watchdog limit and to generate major fault that will halt the execution of your program.For this reason, there is usually some way to get out of the loop, where by keeping track of just how many times the loop is supposed to repeat itself, or by looping until a condition changes.Looping in Structured Text is a big step in Automation Programming. This task was also achievable with Ladder Logic except that, in Structured Text it is much simpler and very flexible.

No comments:

Post a Comment