0% found this document useful (0 votes)
13 views1 page

Structure Text Programming - Codesys 2

The document discusses the flow control in structured text (ST) programming for PLCs, emphasizing the importance of avoiding infinite loops to prevent dangerous situations. It outlines the structure of ST language, which consists of statements separated by semicolons, and highlights best practices for readability. Additionally, it provides examples of good and bad coding practices in ST programming.

Uploaded by

edlistianto
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views1 page

Structure Text Programming - Codesys 2

The document discusses the flow control in structured text (ST) programming for PLCs, emphasizing the importance of avoiding infinite loops to prevent dangerous situations. It outlines the structure of ST language, which consists of statements separated by semicolons, and highlights best practices for readability. Additionally, it provides examples of good and bad coding practices in ST programming.

Uploaded by

edlistianto
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

330

program flow control. A ST program will be run from beginning to end many times each second. A tra-
ditional program should not reach the end until it is completely finished. In the previous example the
loop could lead to a program that (with some modification) might go into an infinite loop. If this were
to happen during a control application the controller would stop responding, the process might become
dangerous, and the controller watchdog timer would force a fault.

ST has been designed to work with the other PLC programming languages. For example, a lad-
der logic program can call a structured text subroutine.

19.2 THE LANGUAGE

The language is composed of written statements separated by semicolons. The statements use
predefined statements and program subroutines to change variables. The variables can be explicitly
defined values, internally stored variables, or inputs and outputs. Spaces can be used to separate state-
ments and variables, although they are not often necessary. Structured text is not case sensitive, but it
can be useful to make variables lower case, and make statements upper case. Indenting and comments
should also be used to increase readability and documents the program. Consider the example shown in
Figure 262.

FUNCTION sample
GOOD INPUT_VAR
start : BOOL; (* a NO start input *)
stop : BOOL; (* a NC stop input *)
END_VAR
OUTPUT_VAR
motor : BOOL;(* a motor control relay
*)
END_VAR
motor := (motor + start) * stop;(* get the motor output *)
END_FUNCTION

FUNCTION sample
BAD INPUT_VAR
START:BOOL;STOP:BOOL;
END_VAR
OUTPUT_VAR
MOTOR:BOOL;
END_VAR
MOTOR:=(MOTOR+START)*STOP;END_FUNCTION

Figure 262 A Syntax and Structured Programming Example

You might also like