Structure Text Programming - Codesys 12
Structure Text Programming - Codesys 12
Function Description
Control programs can become very large. When written in a single program these become con-
fusing, and hard to write/debug. The best way to avoid the endless main program is to use subroutines
to divide the main program. The IEC61131 standard allows the definition of subroutines/functions as
shown in Figure 282. The function will accept up to three inputs and perform a simple calculation. It
then returns one value. As mentioned before ControlLogix does not support overloading, so the func-
tion would not be able to have a variable size argument list.
....
D := TEST(1.3, 3.4); (* sample calling program, here C will default to 3.14 *)
E := TEST(1.3, 3.4, 6.28); (* here C will be given a new value *)
....