Generating program code

The program code is the machine code, which a controller executes when you start a PLC program. TwinCAT automatically generates the program code from the source code written in the development system before downloading the PLC project to the controller. Before the program code is generated, the system checks the assignments, data types and availability of libraries. In addition, the memory addresses are allocated when the program code is generated.

For each download, the compile log (Compile Info), which contains the code and identification of the loaded PLC project, is saved as a file on the target device.

Messages during program code generation

Due to the incremental compilation, the memory is only reassigned for new and modified function blocks and variables. It is therefore possible that gaps occur in the memory. Online changes have the same effect. This fragmentation reduces the available free memory. In this case, you can use the command Clean to re-allocate the entire memory, thus increasing the free memory. Further information on messages during code generation: syntax errors and errors detected by TwinCAT during the code generation and memory allocation appear in the message window Compile (error list). During each code generation, information about the size of the code, the size of the data (in bytes), the content of the occupied memory areas, and the highest address used (byte) is also displayed there. It depends on the PLC in which memory areas which data and the code are stored.