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 →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.
Nuances of Working with Function Block Instances by Value in TwinCAT 3 / CoDeSys
A detailed analysis of memory copying (MEMCPY) and object lifecycle (FB_Init/FB_Exit) when working with function block instances by value in IEC 61131-3.
Extending FB_Init Parameters in TwinCAT: Constructors for Derived Classes
How to extend the parameter list of the FB_Init method in derived classes for Predictable Initialization in TwinCAT and CoDeSys. Benefits and compiler limitations.
Exception Handling in TwinCAT: __TRY, __CATCH, __FINALLY
An analysis of the exception handling mechanism using TRY-CATCH-FINALLY constructs in TwinCAT 3.1.4026. Usage nuances, runtime limitations, and implementation in TwinCAT.OpenFramework.
Type Checking at Runtime in TwinCAT: __QUERYINTERFACE and __QUERYPOINTER
An exploration of runtime type safety in Structured Text, detailing how to check type compatibility using interfaces and compiler casting operators.
Abstract Class vs Interface in Structured Text
A comparison of abstract classes and interfaces in CoDeSys/TwinCAT, detailing inheritance, runtime type checking, and polymorphism safety.