Software for Education and Industry

   Home   Order Form   

Codesys Libraries
How to Create and Use Libraries

This tutorial will take you step-by-step through how to use Codesys libraries and how to create and use your own libraries, commonly called user libraries, that you can create for code commonly used in your business.  By encapsulating your commonly used code in a user library, you won't have to re-write the code for every project you create.  Rather, you can just call up the library and incorporate its code into your project.

How this tutorial is organized:
In this tutorial we assume you are starting a new furnace manufacturing company.  You will make lots of different types of furnaces, but the control for each furnace will have the following items in common:
  1. three fans that need to be started 10 seconds apart
  2. a pump that needs to run for 5 seconds after the third fan is started
  3. a temperature converter to convert Fahrenheit degrees to Celsius
The library you will create, called a user library, will include the above 3 items and be named Furnace Library.   It will also use a library supplied by Codesys called the Standard Library.  The control you will design for your first furnace will be named Furnace 1 and will use your Furnace Library and a library supplied by Codesys called Util Library.   Figure 1 below shows the libraries and project used in this tutorial.

Figure 1  Libraries and Project used in this tutorial

Table of Contents


1.  Introduction
How this tutorial is organized
What you should know to use this tutorial
What you need to use this tutorial


2.  Create a User Library

Start a new Library
Enter Project Information
Add a POU
Program the fans POU
Program the pump POU
Program the temp POU

Save the Library


3.  Start a New Project
Start a new Project
Add the User Library Created in Chapter 2
Program the Fans control
Program the Pump control
Program the Temperature Converter
Program the High Temp Warning Light
Run the Program
Save the Project

...image from Chapter 3...
 (after adding the fans, pump, and temp control to the project from your user library)

...image from Chapter 3...
  (after adding a high temperature light to the project from the Codesys Util libary)

What you should know to use this tutorial:

This tutorial assumes you have a working knowledge of Codesys and know how to:

If you need a refresher on any of these topics, you may want to take our tutorial PLC Ladder Ladder Logic and Function Blocks with Codesys.

You may also be interested in our other programs at including tutorials on Codesys Structured Text and Instruction List programming.

What you need to use this tutorial: