Structure Text Programming - Codesys 3
Structure Text Programming - Codesys 3
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
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