TwinCAT Engineering Notes
TwinCAT is a software suite by Beckhoff that transforms a PC into a real-time controller. An industrial automation standard adopted by Tesla, SpaceX, BMW, and ASML.
Here you will find deep dives into the architecture, edge cases, and undocumented behavior of such systems.
What is TwinCAT in detail▸ Recent writing
All posts →Why FB_exit of a Local FB Is Silently Skipped on an Exception
Why TwinCAT/CODESYS skips FB_exit for stack-allocated local function blocks when an exception leaves a method
Calling Virtual Members from FB_Init in TwinCAT
What happens when you call a virtual method or property from FB_Init in TwinCAT / CoDeSys? Exploring polymorphic constructor behavior and uninitialized fields.
Ignoring Method Parameters Using Special Values
Elegant approaches to ignore parameters or retain previous values in TwinCAT / CoDeSys using REFERENCE TO and quiet NaN (Not a Number).
REFERENCE TO properties in TwinCAT 3 / CoDeSys
Key nuances of working with REFERENCE TO properties: `REF=` vs `:=` operators, getters, setters, and online monitoring of complex types.
Methods with optional arguments
Uses of method arguments with default values, their features and limitations in TwinCAT/CoDeSys.
Working with Variable-Length Collections in Structured Text Using IEnumerator
How to bypass the limitations of fixed-size arrays in TwinCAT and CoDeSys. Implementing the IEnumerator interface for flexible dynamic sequence iteration.