Libraries in CODESYS contain proven code for everyday or special tasks. For example, with an available library function you can easily realize the following things without any additional effort on your side:
- Converting variables from and to BCD format,
- A blinker or signal generator,
- A PID closed loop controller or other controllers,
- Communication commands for example using the serial interface, CAN, EtherNet/IP, or MQTT,
- Data access for JSON-, INI- or any other files.
Of course, as an experienced programmer, you can always create such blocks yourself. But why should you when there is already tested code available which can immediately be used free of charge? Why not focus on the specific part of your application! True, not all libraries from the CODESYS North America Store are free of charge. But sometimes making a small investment is still less expensive than implementing and testing the functionality yourself.
Also, with CODESYS you can pack your own code into a library. This really makes sense for a variety of reasons:
- Libraries allow a clean structuring of your application into general parts and project specific parts.
- Testing and release of the specific parts are thereby facilitated, increasing the overall quality of the application.
- You can make your own versioning for the general code parts.
- Your source code is better protected against unauthorized access.
- POUs can be documented independently of the project.
- You can easily reuse code or make it available to your colleagues.
- If you want to, you can offer the functions contained in the library to other CODESYS users in the CODESYS North America Store – for free or for sale. Your know-how remains protected!
Creating and integrating libraries in the CODESYS Development System is easy - thanks to the mature library concept in CODESYS. Define clean interfaces for calling functions and implement the desired behavior. Ideally, you can use existing libraries to easily adopt a predefined behavior model in your library. Save the desired POUs as a CODESYS library and embed them in your library repository for testing. With a consistent versioning and clear documentation stored in the source code in ReST format, the libraries are well described and easier to use.
For useful tips concerning library development and guidelines, please refer to the CODESYS Online Help. And if you need more support, we recommend the CODESYS V3 Intensive Training. Library creation is an essential part of this training.