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

Structure Text Programming - Codesys 3

The document outlines the rules for defining variable names in Structured Text (ST) programming, emphasizing that names must start with a letter and can include letters, numbers, and certain symbols, while being case insensitive. It details valid and invalid variable names, as well as various declarations such as VAR_INPUT, VAR_OUTPUT, and RETAIN, which define the scope and behavior of variables. Additionally, it provides examples of variable declarations to illustrate proper usage.

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)
21 views1 page

Structure Text Programming - Codesys 3

The document outlines the rules for defining variable names in Structured Text (ST) programming, emphasizing that names must start with a letter and can include letters, numbers, and certain symbols, while being case insensitive. It details valid and invalid variable names, as well as various declarations such as VAR_INPUT, VAR_OUTPUT, and RETAIN, which define the scope and behavior of variables. Additionally, it provides examples of variable declarations to illustrate proper usage.

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

331

19.2.1 Elements of the Language

ST programs allow named variables to be defined. This is similar to the use of symbols when
programming in ladder logic. When selecting variable names they must begin with a letter, but after
that they can include combinations of letters, numbers, and some symbols such as ’_’. Variable names
are not case sensitive and can include any combination of upper and lower case letters. Variable names
must also be the same as other key words in the system as shown in Figure 263. In addition, these vari-
able must not have the same name as predefined functions, or user defined functions.

Invalid variable names: START, DATA, PROJECT, SFC, SFC2, LADDER, I/O, ASCII,
CAR, FORCE, PLC2, CONFIG, INC, ALL, YES, NO, STRUCTURED TEXT

Valid memory/variable name examples: TESTER, I, I:000, I:000/00, T4:0, T4:0/DN,


T4:0.ACC

Figure 263 Acceptable Variable Names

When defining variables one of the declarations in Figure 264 can be used. These define the
scope of the variables. The VAR_INPUT, VAR_OUTPUT and VAR_IN_OUT declarations are used for
variables that are passed as arguments to the program or function. The RETAIN declaration is used to
retain a variable value, even when the PLC power has been cycled. This is similar to a latch application.
As mentioned before these are not used when writing Allen Bradley programs, but they are used when
defining tags to be used by the structured programs.

Declaration Description

VAR the general variable declaration


VAR_INPUT defines a variable list for a function
VAR_OUTPUT defines output variables from a function
VAR_IN_OUT defines variable that are both inputs and outputs from a function
VAR_EXTERNAL
VAR_GLOBAL a global variable
VAR_ACCESS
RETAIN a value will be retained when the power is cycled
CONSTANT a value that cannot be changed
AT can tie a variable to a specific location in memory (without this vari-
able locations are chosen by the compiler
END_VAR marks the end of a variable declaration

Figure 264 Variable Declarations

Examples of variable declarations are given in Figure 265.

You might also like