Project structure
Topics:
Modular project structure
You build up a TwinCAT 3 PLC project modularly. The folder structure should be guided by the various features and objects of a PLC project. If necessary, you sort the program elements according to a fixed scheme.
Folder structure
The folder structure of a TwinCAT 3 PLC project should be modular and based on the different functions/objects of a PLC project. You divide the PLC project into module folders on the first level. On the second level you can implement a finer modularization or an order according to element type (DUTs, ITFs, POUs etc.), depending on the complexity of the modules.
- Folder names of the first level: description of the functionality/module
- Folder names of the second level: further modularization or description of program elements
Sample:
Tc3_Plc_Project
+ [Topic X]
+ DUTs
+ ITFs
+ POUs
+ [Topic Y]
+ [Topic Y, Part a]
+ DUTs
+ POUs
+ [Topic Y, Part b]
+ ITFs
+ POUs
Sorting schema in the project tree
The objects in the project tree are sorted alphabetically by TwinCAT 3. An optional scheme for sorting the objects in the project tree is therefore derived from the names of the objects.
The sorting scheme can consist of a combination of numbers, key words or their abbreviations. It is located between the prefix and the actual name of the object and is separated from the prefix and the object name by an underscore. If the sorting scheme consists of several elements (e.g. numbers with keywords or their abbreviations), the respective subelements are separated from each other with underscore characters.
The sorting scheme should be annotated at a suitable place in the program element.
Alternatively, POU subfolders can be used to sort the subitems of a POU by topic.
Example of a sorting scheme:
The methods of the following function block are sorted using abbreviations and numbers. The abbreviations arrange the methods based on their call interval ('ccl' = cyclical; 'nccl' = noncyclical, e.g. event driven call); the numbers sort the cyclical methods according to their intended call sequence. These methods are provided as an example. The keywords for sorting are freely selectable; the underscores between keywords and numbers are optional (e.g. 'ccl01_Data' or 'ccl_01_Data').
![Project structure 1:](Images/png/3153606795__Web.png)
No unused declarations/objects or useless code
Unused program elements in a project quickly lead to confusing program trees / code structures. During maintenance and extensions, the readability of the code can be greatly enhanced if the project only contains program elements that are actually used.
See also the topic No unused declarations/objects or useless code in the section Programming.