Advanced
CODESYS vs TIA Portal: Structured Text Differences Every Engineer Should Know
Moving between CODESYS and TIA Portal? Learn the key Structured Text syntax differences to avoid common pitfalls.
Why This Matters
If you work in industrial automation, you'll eventually encounter both CODESYS (used by Beckhoff, Wago, ABB, and many others) and Siemens TIA Portal (S7-1200/1500). While both follow IEC 61131-3 for Structured Text, there are important syntax and behavioral differences.
Key Differences
1. Program Structure
CODESYS uses standard IEC 61131-3 POUs:
PROGRAM Main
VAR
myVar : INT := 0;
END_VAR
// Logic here
END_PROGRAM
TIA Portal wraps code in Organization Blocks (OBs):
2. Timer Syntax
CODESYS (IEC standard):
myTimer(IN := startCondition, PT := T#5s);
timerDone := myTimer.Q;
elapsed := myTimer.ET;
TIA Portal (similar but with instance DB):
// Timer called as instance in TIA Portal
"IEC_Timer_DB".TON(
IN := startCondition,
PT := T#5s
);
timerDone := "IEC_Timer_DB".Q;
3. String Handling
CODESYS:
myString : STRING(80) := 'Hello';
length := LEN(myString);
sub := MID(myString, 3, 1); // MID(string, length, position)
TIA Portal:
// TIA uses slightly different function signatures
length := LEN("myString");
// String indexing starts from 1 in both platforms
4. Data Type Differences
| Feature | CODESYS | TIA Portal |
|---|---|---|
| Strings | STRING(length) | String[length] |
| Enums | Standard IEC | Limited before V16 |
| Pointers | POINTER TO | Not available in ST |
| References | REFERENCE TO | InOut parameters |
| Arrays | ARRAY[1..10] OF | Array[1..10] of |
5. Commenting Styles
Both support:
// Single-line comment
(* Multi-line
comment *)
TIA Portal also accepts:
/ C-style comments /
What Transfers Between Platforms
The good news: core logic transfers well. These are identical on both platforms:
Best Practice: Write Portable Code
Conclusion
Learning Structured Text on a standard IEC 61131-3 platform gives you skills that transfer to both CODESYS and TIA Portal. The differences are mostly syntactic — the logic, control structures, and programming patterns are the same.
Practice writing portable ST code in our free online editor to build skills that work everywhere.