On the right-hand side of TIA Portal are the Tool panes used to develop application logic. Here, we find two important tabs called Instructions and Libraries, which are outlined in more detail here:
- Instructions
- Contains instructions for use when developing code
- Contains selection methods for selecting different versions of groups of instructions
- Contains any optional package instructions that have been loaded into TIA Portal
- Libraries
- Contains access to the project library
- Contains access to global libraries
Instructions
The Instructions tab is the area in TIA Portal where programming instructions are stored. You can see an overview of the Instructions pane here:
Figure 1.15 – Instructions pane
There are a lot of items here that are organized into categories (folders).
Some categories contain a selectable version. This allows programmers to use previous versions of operations/instructions in a newer environment if required by the project. The default version will always be the most recent, and it is not advised to change it unless there is a specific reason to do so.
Adding instructions from the Instructions tab
Instructions are the objects that are used in the programming window—the building blocks of the logic. These are used together to build the logical part of the program. An example is shown in the following screenshot:
Figure 1.16 – Example of instruction added from the Instructions pane
Instructions are easily added to the program block in use through one of the two following methods:
- Double-clicking on the instruction in the Instructions pane. This will add the instruction to the current location in the Program block window.
- Dragging the instruction from the Instructions pane and placing it in the desired location in the Program block window.
Box instructions
A third option is also available for box instructions. Adding an empty box instruction (from the general category) will result in the following being added to the Program block window:
Figure 1.17 – Empty box instruction
?? can be replaced with the name of an instruction that uses the box notation, such as the previously shown MOVE
instruction, as illustrated in the following screenshot:
Figure 1.18 – Example of an empty instruction box being defined as a MOVE instruction
Adding favorite instructions
Favorites can be added to a Favorites bar in both the Instructions pane and in the Program block window below the Block interface pane, as illustrated in the following screenshot:
Figure 1.19 – Two instances of the Favorites bar
Instructions can be added to the Favorites bar by simply dragging and dropping them into place. There are some limitations to the Favorites bar, as outlined here:
- Only instructions from the basic instructions set can be added.
- Favorites cannot be re-organized once placed; however, they can be slotted between existing items. This means that if an instruction needs to be moved, it must be deleted and re-added.
Libraries
The library feature in TIA Portal is an extremely well-developed and feature-rich part of the development environment but is often underused and not appreciated by programmers.
Library management allows programmers to keep versions of program blocks so that they can be distributed throughout a project or shared between other projects. This offers the ability to use consistent and pre-tested code, wrapped up in a very well-controlled environment.
Note
It's best to start using libraries right at the beginning of a project (and throughout its life cycle) when defining a project structure is easier.
The Libraries tab consists of the following two areas:
- Project library
- This contains Types and Masters that are relative to the current project
- Can only be used by the currently opened project
- Global library
- This also contains Types and Masters that are used to update or populate the project library
- Can be updated via the project library
Types and Masters
Throughout the library system in TIA Portal, two common terms are used: Types and Masters (master copies). These refer to how objects placed inside the library behave.
Types: Program blocks placed in the Types
folder will be explicitly connected to the project library. This means that they cannot be edited without first confirming the requirement to be edited. If a type is edited, it must be saved as a new version; TIA Portal will manage this appropriately.
Masters: Any object placed in the master copies will be a copy of the object placed. Unlike Types, these serve as templates and can be edited at will in the project without updating the library. If more than one object is placed in the Master copies
folder at once, TIA Portal will group them together as a single object to ensure they are copied back together.
Project library
The Project library is a locally held collection of program blocks that directly relate to the current project, as illustrated in the following screenshot:
Figure 1.20 – Example of typed objects and master copies
This library is used to help programmers ensure that the program blocks used throughout the project are strictly version-controlled, or to provide templates in order to get started with a program block quickly.
The Libraries tab is found on the right-hand side of the TIA Portal application, below the Instructions tab.
Blocks that are used in the project library can only be opened if they are instantiated in the project itself. This means that in order to edit or open a project library object, it must at least exist in the project tree.
Note – Master Copies
Master copies cannot be opened at all from the Libraries pane and must be copied (dragged) into the project tree before an object can be opened.
Types
Types are version-controlled program blocks. Only function blocks, functions, and user-defined types (UDTs) can exist as a type in a library.
Types can be in one of the following two modes:
The following screenshot shows an example of a program block in test:
Figure 1.21 – Example of a program block in test
When a type is released, it has been added to the library, versioned, and is now available to be used in the project tree. At this point, it is protected and cannot be edited without creating a new version.
When a type is in test, it is available to be edited, versioned, and then committed back to the library. A type must be put into test to create a new version. The test version can be downloaded into the PLC via the project tree so that tests on the new version can be performed.
Editing Library Blocks (In Test)
The block to be edited must exist in the project tree before it can be edited. A block can be edited by right-clicking and choosing Edit type in the Libraries pane.
The project library should be used in order to release multiple in-test blocks at once. The status indication in the library will show the following symbols for different types of inconsistencies between the project library and project tree:
- Multiple inconsistencies: More than one object is in test (including dependents)
- Non-Default version instantiated: The project tree has an in-test version instantiated
- Default dependent not used: The default version of this block does not use the same default version of a dependent block (inconsistent versioning)
- Consistent: No inconsistencies detected
In order for library objects to be used correctly, all items should be consistent unless testing is actively occurring.
There is more than one method for releasing versions, as outlined here:
- Via the yellow information banner at the top of a typed block that is in test
- Via the right-click menu when clicking an object in test in the project library
When either is clicked, the following dialog box is presented:
Figure 1.22 – Release type version dialog box
In this dialog box, information about the type can be entered, including an author and a comment.
The version number will automatically increase the minor revision number; however, this can be overridden to make larger version increments.
Checkboxes at the bottom of the dialog box allow programmers to change the behavior of the release.
Deleting unused types is a good way of keeping the project library clean and easy to use. Setting dependent types to edit mode will be pre-selected if the block being released has dependent types that are not in test yet (these dependent blocks will need to be updated to maintain library consistency).
Discarding Changes
Be careful! Clicking Discard changes will immediately delete the test version, without confirmation!
Master copies
Master copies work very differently from types. While master copies still reside in the library, they are not version-controlled, and modifying a master copy does not cause other blocks to need to adapt.
Master copies are also not restricted to just function blocks, functions, and UDTs. Other types—such as data blocks, tag lists, and even groups of objects and folders—can have master copies.
Editing Master Copies
Unlike types, master copies cannot be edited at all. In order to update a master copy, a new instance of the object must replace it. This can be done by simply deleting the existing version and dragging the new version (with the same name) into the Master copies
folder.
Usage
A master copy serves as a template and can simply be dragged from the Libraries pane into the project tree in the position required. If the object dragged into the project tree contains more than one object (is a group of objects), all of the objects will be unpacked into their single instances, retaining any structural layout.
Icons
Different icons for master copies symbolize different meanings, as outlined here:
- Standard singular objects: Objects retain their normal icons
- Group of data blocks: A folder containing only data blocks
- Group of function blocks: A folder containing only function blocks
- Group of mixed objects: A folder containing more than one type of object
- Empty folder: A folder/group with no content (useful for templating project-tree layouts)
Global library
The global library is a library that can be used by more than one project. The global library behaves slightly differently from the project library, but still maintains a familiar approach to updating and maintaining objects within it.
Libraries Pane
Just as with the project library, the global library is found on the left-hand side of TIA Portal in the Libraries pane.
Creating a new global library
Global libraries exist outside of the project and can be saved in different directories from the active project. To create a new global library, click the icon.
A familiar dialog box will open that is similar to the one used to create a new project, as shown here:
Figure 1.23 – Create new global library dialog box
By default, global libraries are saved in the Automation
folder; however, this can be changed to any location.
It's important to note the version number of the global library—the version of TIA Portal must match in order to use the library. If an older version library is opened in a newer version of TIA Portal, a conversion to the new version takes place. You cannot downgrade TIA Portal libraries to lower versions.
Opening a global library
Just as with a project, a global library must be browsed for and opened. This can be done in the same place as when creating a new global library, by clicking the icon.
A new dialog will open that allows a global library to be browsed for and opened, as illustrated in the following screenshot:
Figure 1.24 – Open dialog for a global library
If a global library is to be edited, remember to uncheck the Open as read-only checkbox. If this is left checked, objects can be read from the global library but cannot be written to the global library.
Note
A project doesn't have to be opened to open a global library; however, without a project, the use of a global library is limited!
Using a global library
Before any objects in the global library can actually be used, it is important to understand the differences between a global library and a project library. Almost all of the differences relate only to types, with master copies still behaving as templates.
If a type is required from a global library, it will automatically be added to the project library if dragged into the project tree, as will all of its required dependents.
Upgrading a global library
A global library is easily updated from a project library by right-clicking the object to be upgraded in the project tree and selecting Update types | Library. A new dialog will open, as illustrated in the following screenshot:
Figure 1.25 – Updating types in a library
From the dropdown, the open (and writable) global library can be selected. When OK is clicked, the global library will be updated with all new versions.
This also works the other way around, for updating project library types from the global library.
The global library must be saved after updating by clicking the Save icon () in the Global library pane.
Note
Checkbox options should only be selected if there is an explicit requirement to do so. It's good practice to keep previous versions available in the global library to support older projects as time and versions progress.
Periodically, very old versions may be removed once no projects are making use of them (the project library will still contain the relative version, though, if one in use is removed from the global library).