top of page

CoDeSys Library Management Step by Step Guide

Updated: Dec 24, 2023

In order to start Library building in CoDeSys we need to create a Library project

Project Creation

To create project Open CoDeSys IDE and got to

Step1: File-->New Project

ree

Step2: Select Type of Library you want to create

ree

Step3:Add Project Information by going to Project-->Project Information

ree

Step4:Fill the details in the Summary Tab of Project Information

Summary Tab: will have all the details of Project Information

Mandatory Items are Highlighted in Bold without which it will not allow to install the library

ree

Properties Tab : This tab is used to add any new custom properties in Project Information

ree

Statistics Tab: it will provide details of data of project i.e. Number of folder , POU Project information etc.


ree

Licensing Tab: In this Tab we set Licensing rule for the library, which means The compiled library is licensed and can not be used without License dongle

we need to perform below steps

  • Contacting 3S (store@codesys.com) in order to get firm-code, product code and a license for those

  • Entering these values in the form “Licensing” in the Project Information of the library

  • Saving the library as “compiled-library” (only possible, if the CODESYS Security Key with the above mentioned license is available on the computer on which the library gets created)

detailed description can be found in Link

Note: This features works only with Compiled Libraries

ree

Step5: Once all the details of project information is filled we can generate Library in two ways

1.Non Compiled Library

  • By Clicking on the icon

ree

  • by going to File-->Save Project and Install into Library Repository

ree

Note: In above option Library will get Installed automatically in Local repository


2.Compiled Library : This library needs to be installed and can be distributed

  • going to File-->Save Project as Compiled Library

ree

Once the Compiled Library is generated we need to install it into the project Library local Repository


Step6: Install Library in the Library repository

  • Open an Existing Project or Create a new project

  • Open Library Manager by double clicking it

ree

  • Click on the Library Repository a new popup will open

ree
  • Click on install

ree

Browse for Compiled Library-->Select the Library--> click on Open

Library will get installed

ree

Installed Library Tree Structure

ree

with above steps Library will get installed into Local Library Repository

based on the library categories it will go into Tree structure otherwise it will go in Miscellaneous tree structure



To Uninstall any library

Select the version and click on Uninstall

ree

Adding Library in Project


ree

Select Library to Add and Click OK

ree

Getting Details of Library : Released vs UnReleased

Select Library & Click on Details

ree

Click on More to get Release Details

ree

If Library is Released the Property Released =True

ree


How to Use Library Categories

In order to put the Library in custom defined structure we need to define Library categories which will create a defined structure and put the library into same


Below steps needs to be followed to define Library Categories


Step1: CoDeSys provide default Example when we install CoDeSys IDE which can be found at location

"C:\Program Files\CODESYS 3.5.xx.xx\CODESYS\Templates\Library_Template\LibraryCategoryBase.libcat"
xx=Codesys Version

With help of this file we can create our own custom libcat

Below is an example

<?xml version="1.0" encoding="UTF-8"?>
<LibraryCategories xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="LibraryCategories.xsd">
<!--   Jugaadtech   -->
	<LibraryCategory>
		<Id>799BFEAA-109B-4CC5-A5E6-7A4D552CEEA4</Id>
		<Version>1.0.0.0</Version>
		<DefaultName>Jugaadtech</DefaultName>
	</LibraryCategory>
</LibraryCategories>

For Sub Categories in existing library example

<?xml version="1.0" encoding="UTF-8"?>
<LibraryCategories xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="LibraryCategories.xsd">
<!--   Jugaadtech   -->
	<LibraryCategory>
		<Id>799BFEAA-109B-4CC5-A5E6-7A4D552CEEA4</Id>
		<Version>1.0.0.0</Version>
		<DefaultName>Jugaadtech</DefaultName>
	</LibraryCategory>
<!--   Jugaadtech/TestLib   -->
	<LibraryCategory>
		<Id>883D5913-7DF7-4910-A50D-574E2EAF815C</Id>
		<Version>1.0.0.0</Version>
		<ParentCategory>
			<!--   Jugaadtech   -->
			<Id>799BFEAA-109B-4CC5-A5E6-7A4D552CEEA4</Id>
		</ParentCategory>
		<DefaultName>TestLib</DefaultName>
	</LibraryCategory>	
</LibraryCategories>



<Id></Id> --> This is GUID which we need to create using GUID tool Generator

search in google any GUID tool generator is ok to use example GUID TOOL LINK

ree

Step2: After creating the file add it into Project Information

  • Double click on Project Information

ree
  • Project Information pop up will open click on the three dots (...) button

ree
  • Once three dots button is clicked Library Categories Pop up will open click on the Add button

ree
  • To add from Librarycategories file select "From Description File"

ree
  • Browse the file with extension of *.libcat and click on Open

ree
  • Based on the definition in the file options with check box checked will be shown Select the option and click OK

ree
ree

  • Library categories will get added in Project Information once OK is Clicked

ree

Click on Ok to close the pop up and save the project and generate the Library

in this way we can generate the Library categories for custom Library


Automate Generation of Library Categories using Python

Getting GUID of existing Library some time is tricky in that case we can use Python Automation to get all the GUID and then Library categories can also be generated automatically using Python Script


below are python the Scripts i have created for above manual example. copy and save it in .py file and run using

ree

  • To get GUID of Libraries:

from System import Guid
for library in librarymanager.categories:
   print("Library: {} V{} Guid {}".format(library.name, library.version, library.guid))

  • To add the Library "change the GUID based on library guid number"

from System import Guid
Jugaadtech = librarymanager.get_category(Guid("799bfeaa-109b-4cc5-a5e6-7a4d552ceea4"))
assert(Jugaadtech is not None, 'category does not exist')
print("Guid of Jugaadtech library category: " + str(Jugaadtech.guid))
info = projects.primary.get_project_info()
assert(info is not None, 'No project info')
libcat = info.categories
print(str(libcat))
if Jugaadtech not in libcat:
   libcat.Add(Jugaadtech)
   print('Added library category')
print("Found lib categories:")
for lib in libcat:
   print(lib.name)

Documentation in Codesys Library

Basic Text Documentation:

Library can be documented in CoDeSys by writing the text at different level

Project Information: All the details filled in the Project information will be treated as a documentation for Library Information ,


ree

POU/DUT/STRUCT : Any Comment defined before the declaration of POU,DUT,Struct etc. will be shown in Documentation , Any Comment made for Variable will be shown in documentation of Variable


ree

While checking Documentation it will appear as shown below

ree

Folder Documentation: Description defined in the Documentation tab of the "Properties" of folder will be shown as Folder documentation


ree

As shown below

ree

Using reStructureText

Step1: LibDoc Tool needs to installed


ree

Step2: Add Custom variable in Project Information


ree

Click on Add to get it added


ree

Save the project and Compile the library

The Project where library is getting installed user needs to restart the CoDeSys IDE

Same Documentation will be shown with more advance options of link of objects used and navigation will be enabled automatically


ree

ree






bottom of page