Using libraries

Libraries are collections of reusable objects such as:

Integration of a library in a project enables the library modules to be used in a project in the same way as the other function blocks and variables, which are defined directly in the project.

Using libraries 1:

Recommendations and notes

In addition to the library use descriptions, see the application notes in Recommendations and notes.

The following steps are relevant for the application of libraries. Creation, installation and management of libraries.

If a library was already created and installed (this is the case for system libraries, for example), only the library management or integration step is required. Some libraries have to be created and installed first.

Library creation

Library installation

  • Before a library can be used in a project, the library first hast to be installed on the system. Libraries are managed on the local system in different "repositories" (directories, storage locations). Before a library can be integrated in a project, it has to be installed in such a repository with a defined version number on the local system.
    • Exception: projects referenced as library.
      See Use PLC project as referenced library.
  • If a library version is used that is not installed in the repository, this is flagged up at the reference in the project tree.
  • Libraries are installed in the Library Repository.

Library management

  • The Library Manager offers a good overview of the PLC library references used in the project and can be used to integrate libraries or placeholders in a project. The integration makes the library reference elements available for use in the project.
  • Library references, which are referenced as sub-libraries in another library, are also shown in the Library Manager. In addition, there are “hidden libraries” (see section Command Properties).
  • Whenever a library is used, a unique library version is referenced. This version is specified as the effective version. If the library was attached with a fixed version (e.g. 3.3.0.0), the project will always use this library version, even if a more recent version is or becomes available. Alternatively, the setting "Always newest"/"*" can be used to automatically ensure that the latest library version is used at all times. In this case, TwinCAT always uses the latest version of the library found in the library repository. For more information and a sample, see the Command Set to Always Newest Version.
  • It is not possible to add the same version of the same library more than once to a library manager. A version of a library can be referenced in a library manager either as a library or as a placeholder.
  • If the library is not compiled (*.compiled-library) but is instead available as a *.library file, the library elements listed in the Library Manager can be opened by double-clicking on the respective entry.
  • You can add library references in the form of a library or a placeholder to the Library Manager and include them in your application (see section Command Add library). Placeholders should be used whenever possible. Further information can be found in section Library placeholders.
  • When a library module is addressed in the project, the libraries and repositories are searched in the order in which they are listed in the Library Repository. Further information can be found in section Unambiguous access to library modules or variables.

Library documentation

TwinCAT offers a wide range of library documentation options. Further information can be found in section Library documentation.

 

 

Refer also to the following for information on these topics:

Referenced libraries

Library versions

Unambiguous access to library modules or variables

TwinCAT 2.x PLC Control libraries

External and internal library modules, late binding