Project
Table of Contents
Language
Project language is English, that means:
all the source code is in English, that includes the comments too
the project name is in English
all folders in the project are in English
the hardware configuration is in English
Archive on plc
We never ever store a project archive on the plc. So take care that ‘Auto Save’ is unchecked before activate configuration.
Programming Languages
Permitted are only:
structured text (ST) and extended structured text (ExST)
sequential function chart (SFC)
Folder Structure
Since the software of our PLC projects is modular, this should also be reflected in our folder structure. In the root directory, there is a folder called tasks. For each task, there is a subdirectory which describes the purpose of the task in the folder name. In this subdirectory, both the task and the associated program can be found. Apart from that, the folder structure is always the same:
On the top level there is a folder with the module name, below it are the folders: classes, functions, gvls, interfaces, programs, types. Types has the following subfolders: aliases, enumerations, structs, unions. A module can additionally contain any number of submodules, this can be continued recursively as desired (until the path length of 260 characters is reached). A submodule has the same folder structure as a module.
There are no empty folders, for example, if there is no global variable list and no unions in a module, then there is no empty ./gvls and ./types/unions folder. The subfolders classes, functions... are always plural even if there is e.g. only one class in ./classes.
Devices and general things that are used by multiple modules should be placed in separate libraries if possible, this enforces a programming style that increases reusability. In the library projects, the same folder structure applies as in PLC projects, only that there are no tasks.
Here is the concept how the hierarchical structure looks... Module is not a prefix but just to show what it is. Unfortunately, an expand macro is not possible here because they have no indentation.
Folder Scheme
┌─PLC Project │ ├──┬─Module FooBar │ │ │ ├──┬─Module Foo │ │ │ │ │ ├──┬─Module FooManchu │ │ │ │ │ │ │ └──┬─classes │ │ │ │ │ │ │ ├─functions │ │ │ │ │ │ │ ├─interfaces │ │ │ │ │ │ │ ├─gvls │ │ │ │ │ │ │ ├─programs │ │ │ │ │ │ │ ├─types │ │ │ │ │ │ │ └──┬─aliases │ │ │ │ │ │ │ ├─enumerations │ │ │ │ │ │ │ ├─structs │ │ │ │ │ │ │ └─unions │ │ │ │ │ └──┬─classes │ │ │ │ │ ├─functions │ │ │ │ │ ├─interfaces │ │ │ │ │ ├─gvls │ │ │ │ │ ├─programs │ │ │ │ │ ├─types │ │ │ │ │ └──┬─aliases │ │ │ │ │ ├─enumerations │ │ │ │ │ ├─structs │ │ │ │ │ └─unions │ │ │ ├──┬─Module Bar │ │ │ │ │ └──┬─classes │ │ │ │ │ ├─functions │ │ │ │ │ ├─interfaces │ │ │ │ │ ├─gvls │ │ │ │ │ ├─programs │ │ │ │ │ ├─types │ │ │ │ │ └──┬─aliases │ │ │ │ │ ├─enumerations │ │ │ │ │ ├─structs │ │ │ │ │ └─unions │ │ │ └──┬─classes │ │ │ ├─functions │ │ │ ├─interfaces │ │ │ ├─gvls │ │ │ ├─programs │ │ │ ├─types │ │ │ └──┬─aliases │ │ │ ├─enumerations │ │ │ ├─structs │ │ │ └─unions │ ├──┬─Module Baz │ │ │ └──┬─classes │ │ │ ├─functions │ │ │ ├─interfaces │ │ │ ├─gvls │ │ │ ├─programs │ │ │ ├─types │ │ │ └──┬─aliases │ │ │ ├─enumerations │ │ │ ├─structs │ │ │ └─unions │ └──┬─tasks │ └──┬─Plc Main Task │ ├─HMI Task │ └─Vision Task
Subfolders In Programs And Classes
Programs and classes can have the subfolders private, protected and internal, in which the methods and properties with the corresponding access attribute can be found.
For classes, there are additional subfolders for the interfaces they implement. Since TwinCAT has the problem with the path length, it can be that the subfolders must be omitted.