The TwinCAT Core Library is used in the TwinCAT PLC project and provides the behaviour models for industrial devices as function blocks.
- Create PLC Project
- Install and add the
OC_Core
library - Install the dependencies:
- TcUnit
- Tc2_Utilities
- Tc2_Math
- Tc3_Module
- Declare and call
FB_System
in your main program
In Unity project each device has a link class, which defines the interface for communication with TwinCAT. At startup, Unity Client tries to find a TwinCAT function block for each device. The search is done by name and type. The mapping is done when all the interface variables have found the opposite side in twincat, otherwise connection for this module becomes invalid.
The main component in Open Commissioning is FB_System
.
This function block contains the system parameters and the global system variables such as fDeltatime
, which can be accessed by other FBs in the project through the static GVL_Core.fbSystem
.
FB_System
should be defined and called up once in the project so that the GVL reference is correctly assigned.
If FB_System
is not defined or there are several instances, the TwinCAT PLC project is forced into config mode with corresponding messages in the console.
The links are the basic communication blocks in open commissioning that realise the interface for data exchange.
The basic interface consists of a Control
(From TwinCAT to Unity) and Status
(From Unity to TwinCAT) byte.
The basic link is used for additional data exchange and extended with corresponding data types. The current library contains the following links:
FB_LinkDevice
FB_LinkDataByte
FB_LinkDataWord
FB_LinkDataDWord
FB_LinkDataLWord
FB_LinkDataReal
Device in Open Commissioning is a function block that represents the behaviour of the device at PLC level. If device is inherited from an FB_Link, the corresponding interface is also prepared for Unity. Devices also have the interface to the PLC side. This can be as single variables or complex structures, such as control and status words in drive systems.
An example of the abstracted FB_Drive
is shown in the following images.
The basic Function Blocks for the most frequently used devices are listed under Basic folder in Library.
FB_Button
FB_Cylinder
FB_SensorBinary
...
The Drive Folder collects the function blocks for various drives, such as simulation blocks for DS402
, SoE
, etc drives.
The community-developed FBs will be added to the core library in the next incremental releases.
We welcome contributions from everyone and appreciate your effort to improve this project. We have some basic rules and guidelines that make the contributing process easier for everyone involved.
- For non-trivial changes, please open an issue first to discuss your proposed changes.
- Fork the repo and create your feature branch.
- Follow the code style conventions and guidelines throughout working on your contribution.
- Create a pull request with a clear title and description.
Note
All contributions will be licensed under the project's license
Please follow Beckhoff Programming Conventions in your code.
- Keep changes focused: Submit one pull request per bug fix or feature. This makes it easier to review and merge your contributions.
- Discuss major changes: For large or complex changes, please open an issue to discuss with maintainers before starting work.
- Commit message format: Use the semantic-release commit message format.
- Write clear code: Prioritize readability and maintainability.
- Be consistent: Follow existing coding styles and patterns in the project.
- Include tests: It is recommended to add or update tests to cover your changes.
- Document your work: Update relevant documentation, including code comments and user guides.