PLC and HMI Development with Siemens TIA Portal - Liam Bee - E-Book

PLC and HMI Development with Siemens TIA Portal E-Book

Liam Bee

0,0
50,39 €

-100%
Sammeln Sie Punkte in unserem Gutscheinprogramm und kaufen Sie E-Books und Hörbücher mit bis zu 100% Rabatt.

Mehr erfahren.
Beschreibung

With automation requirements on the rise, Siemens’ TIA Portal development environment is almost a necessity for any automation engineer. The Totally Integrated Automation (TIA) environment helps seamlessly integrate all things automation, from PLC hardware and software design to HMI development. This book helps you understand the tools available in the TIA toolbox and shows you how to write code effectively.
The book begins by introducing you to the TIA environment, covering the layout and tools available. Once you’ve got to grips with the environment, you’ll find out how to create hardware to write programs against, including adding IO modules and assigning memory for input and output. Next, you'll develop logic in all of the languages that TIA Portal offers, such as Ladder, Function Block Diagram, and Structured Text (SCL) (note that Statement List is not covered as a deprecated language), as well as the newest language, Cause and Effect (CEM). You’ll also discover how to store standard code in libraries, creating a version control system that is easy to manage and aids standard design. Finally, following the PLC design chapters, you’ll learn how to develop HMI applications in TIA Portal’s latest unified hardware.
By the end of the book, you'll be well equipped to use all of the features that TIA Portal V17 offers.

Das E-Book können Sie in Legimi-Apps oder einer beliebigen App lesen, die das folgende Format unterstützen:

EPUB
MOBI

Seitenzahl: 342

Veröffentlichungsjahr: 2022

Bewertungen
0,0
0
0
0
0
0
Mehr Informationen
Mehr Informationen
Legimi prüft nicht, ob Rezensionen von Nutzern stammen, die den betreffenden Titel tatsächlich gekauft oder gelesen/gehört haben. Wir entfernen aber gefälschte Rezensionen.



PLC and HMI Development with Siemens TIA Portal

Develop PLC and HMI programs using standard methods and structured approaches with TIA Portal V17

Liam Bee

BIRMINGHAM—MUMBAI

PLC and HMI Development with Siemens TIA Portal

Copyright © 2022 Packt Publishing

All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.

Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing or its dealers and distributors, will be held liable for any damages caused or alleged to have been caused directly or indirectly by this book.

Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.

Group Product Manager: Rahul Nair

Publishing Product Manager: Meeta Rajani

Senior Editor: Athikho Sapuni Rishana

Content Development Editor: Sayali Pingale

Technical Editor: Arjun Varma

Copy Editor: Safis Editing

Associate Project Manager: Neil Dmello

Proofreader: Safis Editing

Indexer: Rekha Nair

Production Designer: Sinhayna Bais

Marketing Coordinator: Nimisha Dua and Sanjana Gupta

First published: April 2022

Production reference: 1080422

Published by Packt Publishing Ltd.

Livery Place

35 Livery Street

Birmingham

B3 2PB, UK.

978-1-80181-722-6

www.packt.com

To my boys, Lewis and Ryan – keep learning! I love you both very much.

– Liam Bee

Contributors

About the author

Liam Bee has worked in automation for over 16 years, after starting his career at 16 years old as an instrument technician in the water industry. He began his automation journey by maintaining PLCs and the instruments connected to them. He found very early on that he had an interest in PLCs and automation, taking the time to learn PLC programming in his own time, as well as exposing himself as much as possible to automation while working.

After 8 years of working in maintenance, Liam started his own side business, providing bespoke controls using lower-range PLC solutions. This experience proved invaluable to his progression; he learned quickly, often through failure, and his knowledge of control design improved significantly.

12 years into his career, he moved roles again; this time, he was looking for something to fill knowledge gaps and target Siemens as he was yet to use Siemens extensively. Liam started at Aquabio Ltd and quickly found himself immersed in Siemens SIMATIC Manager and TIA Portal. Over the next 3 years, he worked hard to understand Siemens' tools and development environments, calling on knowledge from other PLC environments that he had previously worked with.

Over his years working with automation, he has learned many different languages and development environments. He has worked with Siemens, Allen Bradley, Schneider, Mitsubishi, and a host of other PLC platforms, all of which have helped shape the design concepts that he uses today. Liam has also taught himself computer programming languages such as VBA, VBS, VB.NET, C#, Java, and more. Closing the space between IT and industrial automation is important as time moves forwards and he has always tried his hardest to be at the forefront of innovation.

I would like to thank my lovely wife, Ellie, for putting up with my constant ramblings about PLCs and this book and for giving me the space and support to achieve this.

I would also like to thank everyone at Aquabio Ltd, for helping me to learn as much as I have and for allowing me the access to TIA Portal that has enabled me to write this book.

Thank you to Packt and the great team involved in this process; it's been very rewarding.

About the reviewer

Anna Goncharova lives near Boston, USA. She attended college at Vanderbilt University, where she received her degree in electrical engineering. She has over 10 years of experience working with PLCs and HMIs.

Table of Contents

Section 1 – The TIA Portal – Project Environment

Chapter 1: Starting a New Project with TIA Portal

Windows and panes – layout of the development environment

Portal view – windows and panes

Project view – windows and panes

Getting started with a new project in the Project view

Starting a new project

Changes to the project tree

Adding devices

Configuration of devices

The Reference and Details views – tools to aid development

Reference projects

Details view

Overview view mode

Instructions and libraries

Instructions

Libraries

Project library

Global library

Online testing environment

CPU operator panel

Call environment

Breakpoints

Call hierarchy

Summary

Chapter 2: Creating Objects and How They Fit Together

Creating a project's structure

Data management

Hierarchy in TIA Portal

Call structure

Dependency structure

Parent/child relationships

Instance and global data

Using instance and global data

Accessing data

Configuration options

Interfaces and the effects on running PLCs

Optimized data/non-optimized data

Mixing optimized and non-optimized data

Passing data through interfaces

Summary

Chapter 3: Structures and User-Defined Types

What are structs and UDTs?

Structs

UDTs

Creating struct/UDTs – best practices

Understanding what is required

Defining structure variables

Finding commonalities between assets

Naming conventions

Simplifying interfaces with structs/UDTs

Passing inputs as a single struct

Passing outputs as a single struct

Passing InOut data as a single struct

Structures in static and temporary memory

Creating static declarations of UDTs or structs

Creating temporary instances of UDTs or structs

Drawbacks of structs and UDTs

Libraries

Lack of open protocol support

Cross-referencing

Overusing UDTs/structs

Summary

Section 2 – TIA Portal – Languages, Structures, and Configurations

Chapter 4: PLC Programming and Languages

Getting started with languages

Available languages

Languages in program blocks

Different language types

Selecting the best language

Understanding the use case

Memory management

Differences between Siemens and other PLCs

Timers

Valid networks in ladder logic

GRAPH is not SFC

Bit access in the byte, Word, and Dword variables

Summary

Chapter 5: Working with Languages in TIA Portal

The control scenario

Control overview

Using the HMI

Languages used in TIA Portal

Ladder logic

Function Block Diagram

Structured Control Language

GRAPH

Cause and effect matrix

Summary

Chapter 6: Creating Standard Control Objects

Planning standard interfaces

Defining variables in an interface

Large variables in the interface

Planning standard control interfaces

Creating control data

Improving control data accessibility with UDTs

Example

Creating HMI data

Setpoints/parameters

Structuring logic

General layout

Supportive methods

Considerations that have an impact on usability

How flexible does the control object need to be?

How likely is it that the control object will need to be modified?

What does the control object interact with?

Summary

Chapter 7: Simulating Signals in the PLC

Running PLC/HMI in simulate mode

Starting a PLC simulation

Managing simulated inputs

Using watch tables to change inputs

Using an input mapping layer to change inputs

Creating a simulation interface

Safeguarding outputs when in simulation mode

Summary

Chapter 8: Options to Consider When Creating PLC Blocks

Extending standard functions

Extending standard data

Managing data through instance parameters

Principle to this approach

TIA Portal example

Asynchronous data access considerations

The correct method

Summary

Section 3 – TIA Portal – HMI Development

Chapter 9: TIA Portal HMI Development Environment

TIA Portal Comfort Panel

Adding an HMI to a project

HMI development environment overview

Runtime settings

Screens

Screen objects

Special objects

Elements

Controls

Graphics and Dynamic widgets

Summary

Chapter 10: Placing Objects, Settings Properties, and Events

Setting static properties

Types of static values

Key properties

Setting dynamic properties

Assigning tags to dynamization properties

Using scripts

Raising events

Event scripts

Summary

Chapter 11: Structures and HMI Faceplates

What are faceplates?

TIA Portal V17 faceplates

Creating a faceplate

Available objects and controls

Creating interfaces

Tag interface

Property interface

Creating and handling events in faceplates

Accessing tags

Summary

Chapter 12: Managing Navigation and Alarms

HMI navigation

Managing page changes

HMI alarm controls

Configuration of HMI alarms

The configuration of classes

Configuration of alarm controls

Setting filters on alarm controls

Alarm tags

PLC-driven alarming

Supervision categories

Types of supervision

Alarm texts

Setting global alarm class colors

Summary

Section 4 – TIA Portal – Deployment and Best Practices

Chapter 13: Downloading to the PLC

Downloading to a PLC

Initiating a download

Setting load actions

Downloads requiring the PLC to be stopped

Retaining data in optimized and non-optimized blocks

Retaining data in instance data

Downloads without reinitialization

Snapshots

Uploading from a PLC

Considerations

Data segregation

Using functions

Summary

Chapter 14: Downloading to the HMI

Connection parameters

Creating connections

Devices and networks

Downloading to an HMI

Simulating a unified HMI

Accessing a unified HMI simulation

Security considerations

Summary

Chapter 15: Programming Tips and Additional Support

Simplifying logic tips

Delay timers

AT constructor

IF statements

Serializing

Refactoring

Consolidating blocks

Sequences – best practices

Using constants instead of numerical values

Managed transitions

Managing output requests

Naming conventions and commenting

Comments in SCL

Additional Siemens support

Using TIA Portal's help system

Siemens forum

Siemens documentation archive

Further support – Liam Bee

Summary

Other Books You May Enjoy

Preface

This book is designed to teach the fundamentals behind TIA Portal as well as the latest features that V17 offers.

TIA Portal V17 is the latest installment of Siemens' flagship development environment. It is designed to encompass all parts of project development, from PLC program writing to HMI development. TIA Portal V17 offers a complete solution to manage a project through design, development, commissioning, and maintenance.

Who this book is for

This book is aimed at anyone who wants to learn about the Siemens TIA Portal environment. No prior knowledge of Siemens is required, however, a basic understanding of PLCs/HMIs would be beneficial.

What this book covers

Chapter 1, Starting a New Project with TIA Portal, shows how to get started with a new project.

Chapter 2, Creating Objects and How They Fit Together, looks at how to create new PLC objects and how to use them together in a project.

Chapter 3, Structures and User-Defined Types, gives an introduction to UDTs and structures and how they benefit projects.

Chapter 4, PLC Programming and Languages, explores PLC programming in TIA Portal.

Chapter 5, Working with Languages in TIA Portal, discusses each programming language that TIA Portal offers, including the latest Cause and Effect language.

Chapter 6, Creating Standard Control Objects, looks at the benefits of standardizing control objects.

Chapter 7, Simulating Signals in the PLC, covers a writing pattern that creates an easy method to simulate all signals in the PLC.

Chapter 8, Options to Consider When Creating PLC Blocks, takes a look at different options that require some thought before and during the writing of code.

Chapter 9, TIA Portal HMI Development Environment, gives an introduction to TIA Portal's latest HMI environment, using the new Unified hardware and design platform built into TIA Portal.

Chapter 10, Placing Objects, Settings Properties, and Events, shows how to create objects in an HMI and set their properties and events.

Chapter 11, Structures and HMI Faceplates, looks at the benefits of using structures and faceplates in the HMI.

Chapter 12, Managing Navigation and Alarms, shows how to manage navigation between pages and how to manage alarms.

Chapter 13, Downloading to the PLC, details how to download a PLC program to PLC hardware.

Chapter 14, Downloading to the HMI, shows how to download an HMI design to HMI hardware.

Chapter 15, Programming Tips and Additional Support, provides information on programming tips and where additional support from Siemens can be found.

To get the most out of this book

In order to get the best out of this book, the basic concepts of what a PLC and HMI are and what they are used for should be understood. A keen interest in advancing learning beyond what this book offers will help to solidify the learning gained from this book.

Trial licenses can be obtained from the official Siemens website. Search for TIA Portal V17 Trial License and you should find them.

Download the color images

We also provide a PDF file that has color images of the screenshots/diagrams used in this book. You can download it here: https://static.packt-cdn.com/downloads/9781801817226_ColorImages.pdf.

Conventions used

There are a number of text conventions used throughout this book.

Code in text: Indicates code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles. Here is an example: "If On_Rising_Edge is True and Data.Status_Data.Light_Flashes is over 100000, then Data.Status_Data.Maintenance_Required will be True."

A block of code is set as follows:

(((Max Tank Level - Min Tank Level)

/

(Max Valve Position – Min Valve Position))

*

(Current Tank Level - Min Tank Level))

+

Min Valve Position

Bold: Indicates a new term, an important word, or words that you see onscreen. For example, words in menus or dialog boxes appear in the text like this. Here is an example: "Double-click Add new device in the Project tree pane. This will open the Add new device window, as illustrated in the following screenshot."

Tips or Important Notes

Appear like this.

Get in touch

Feedback from our readers is always welcome.

General feedback: If you have questions about any aspect of this book, mention the book title in the subject of your message and email us at [email protected].

Errata: Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you have found a mistake in this book, we would be grateful if you would report this to us. Please visit www.packtpub.com/support/errata, selecting your book, clicking on the Errata Submission Form link, and entering the details.

Piracy: If you come across any illegal copies of our works in any form on the Internet, we would be grateful if you would provide us with the location address or website name. Please contact us at [email protected] with a link to the material.

If you are interested in becoming an author: If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, please visit authors.packtpub.com.

Share Your Thoughts

Once you’ve read PLC and HMI Development with Siemens TIA Portal, we’d love to hear your thoughts! Please click here to go straight to the Amazon review page for this book and share your feedback.

Your review is important to us and the tech community and will help us make sure we’re delivering excellent quality content.

Section 1 – The TIA Portal – Project Environment

Learn about the TIA Portal development environment and how to get started with the basics of programming with Siemens PLCs.

This part of the book comprises the following chapters:

Chapter 1, Starting a New Project with TIA PortalChapter 2, Creating Objects and How They Fit TogetherChapter 3, Structures and User-Defined Types

Chapter 1: Starting a New Project with TIA Portal

This chapter covers the core requirements to get started with TIA Portal. This includes the physical layout of the environment and different viewpoints, available tools, adding/configuring devices, and library management. The differences between online and offline views are also covered.

After reading this chapter, programmers should feel comfortable with the basic navigation of TIA Portal and have enough knowledge to be confident about the following:

Adding devices to a new projectKnowing where instructions and other tools are locatedUsing the project libraryUsing a global libraryViewing online and offline views of connected devices

The following topics will be covered in this chapter:

Windows and panes – layout of the development environmentGetting started with a new project in theProject viewThe Reference and Details views – tools to aid developmentInstructions and librariesOnline testing environment

Windows and panes – layout of the development environment

Before jumping in and creating a project, let's get familiar with the development environment. In TIA Portal Version 17 (V17), there are two different ways to view and use the application, as outlined here:

Portal viewAllows for the quick setup of hardwareEasy navigation of all TIA areas of developmentEasy access to diagnostic and other online toolsProject viewMore familiar Block & Code viewRequired for programmable logic controller (PLC) programmingRequired for access to more advanced setting dialogs

Depending on the view that TIA is running in, this changes the look and feel of the development environment and also where/how objects are interacted with.

When opening TIA Portal for the first time, the Portal view will be presented, as illustrated in the following screenshot:

Figure 1.1 – Portal view

The Portal view is TIA's default setting and will be the mode that is in use every time TIA Portal V17 is opened (unless changed in the settings).

This view is best for quickly gaining access to different areas of a project.

When required, TIA will automatically switch from the Portal view to the Project view. The following screenshot shows the Project view:

Figure 1.2 – Project view

Note

The Project view is required in order to actually program information in program blocks.

Portal view – windows and panes

The Portal view is much more simplistic than the Project view. This view is for high-level tasks such as adding equipment, and the layout of the view does not change much between different areas.

The windows in the Portal view can be split up into three different key areas, as illustrated in the following screenshot:

Figure 1.3 – Portal view key areas

The three areas are described in more detail here:

Main menu: These are the top-level areas of TIA Portal. Nearly all aspects of development fall into one of these categories.Submenu: These are the navigational items that relate to the main menu area. For example, switching between Start and PLC programming would change the options available in this menu.Activity area: This is the area in which interaction with selected processes occurs, such as creating a new project or navigating PLC programming blocks.

Note

Be careful in the submenu area of the Portal view! In some locations (such as PLC programming), a device must also be selected. It's very easy to accidentally leave the last selected item when returning. Make sure to check which device is active when in these types of menus!

Project view – windows and panes

The Project view is a little more involved than the Portal view. It is not as simplistic, and the menus and navigation can change depending on which area of the project is in view.

Note

The Project views shown in Figure 1.4 are shown with the default layout. In TIA Portal, windows/panes can be moved around in the Project view to create a custom environment.

You can select the default layout by navigating to Window | Default Window Layout. The screen should then look like this:

Figure 1.4 – Project view key areas

The four key areas are outlined here:

Project tree: This is the pane in which navigation of devices and associated objects (such as function blocks) is done. The addition of new devices and objects is also started here.Main activity area: This area is where activities such as PLC programming and network configuration are completed.Supportive tools: This pane contains a collection of tabs that offer tools relative to the activity that is being undertaken. The tabs that are offered also depend on the current activity.Properties, Info, and Diagnostics pane: This pane changes often and has a multi-tab approach to display information in different categories. During development, this pane will most often be displaying information such as Compilation Status and Properties, which allow the setup of different objects. Details view pane—mini-project tree that only shows details of the object currently selected in the main project tree.Details view: This area lists child objects when an object is selected in the project tree. It is also a useful method of exploring variables within a data block or tag list without having to open the object itself.

Getting started with a new project in the Project view

The Project view is the view that most programmers will spend their time in. While the Portal view has its advantages in simplicity, the Project view is a necessity and offers methods to do almost everything that the Portal view can do.

With this in mind, creating a brand-new project in the Project view may be easier for people new to TIA Portal as it follows similar steps to other development platforms.

Note

Remember, on a clean install with default options, TIA Portal will open in the Portal view. In order to get into the Project view, click the text (Project view) in the bottom left of the screen to change modes.

This shows the view that will be switched to when clicked, not the current view.

Starting a new project

When in the Project view, TIA expects a project to be available in order to show anything project-related. At this point, though, no project is available, as none has been created.

A new project can be started by clicking the New project icon in the toolbar at the top of the window, as illustrated in the following screenshot:

Figure 1.5 – New project in the Project view

Once the New project icon has been clicked, the following dialog box is presented:

Figure 1.6 – Create a new project dialog box

This allows the setting of the project name, save path, and author, as well as some comments about the project.

Once the Create button has been clicked, TIA Portal will create (and save) the new project.

Changes to the project tree

Now that a project has been loaded into TIA (the one just created), the project tree is updated with additional objects that relate to the project, as shown in the following screenshot:

Figure 1.7 – Project tree differences when a device is added (left) compared to no device added (right)

These objects relate only to this project and may affect any devices or further objects that are added to the project (Security Settings, for example).

Adding devices

In the Project view (once a project has been opened), a device such as a PLC can be added by double-clicking the Add new device option in the project tree.

By double-clicking the Add new device option, a new dialog box will open, allowing the selection of supported devices. This is illustrated in the following screenshot:

Figure 1.8 – Add new device

Once a suitable device has been selected and a name assigned, the OK button can be clicked, and the new PLC (or other hardware) will appear in the project tree, as illustrated in the following screenshot:

Figure 1.9 – Project tree with new device expanded

If the new device is expanded, all of the available child objects that are relative to the device are displayed.

Note

This is a necessary step to complete before software programming takes place.

The Programming Blocks object (where software such as ladder logic is written) is not available until a device has been added.

Configuration of devices

Every device that is added in TIA Portal will require some basic level of configuration, such as setting the network Internet Protocol (IP) address or adding slave modules.

This can be accessed by right-clicking the new device in the project tree. The Properties item will be available at the bottom of the context menu.

The Properties dialog will open—this is where the configuration of the device can take place, as illustrated in the following screenshot:

Figure 1.10 – Configuration dialog

The same configuration settings can also be accessed by opening the device configuration from the project tree. Once the Device view opens, the properties are displayed in the Properties, Info, and Diagnostics pane, as illustrated in the following screenshot:

Figure 1.11 – Configuration dialog via the Device view

This pane then allows for the configuration of the device's properties and options.

The Reference and Details views – tools to aid development

TIA portal has some handy views that aren't immediately obvious as to their usefulness. Two views are particularly useful, as outlined here:

Reference project viewAllows TIA to open a second project in Read-Only mode, to be used as a reference or guide to the current projectBlocks and other objects can be copied from the reference projectDetails viewOffers a quick-peek-style view of the selected object in the project treeAllows the selection of internal object data for dragging and dropping into the programming view

Both of these views appear as panels on the left-hand side of the TIA Portal view.

Note

By default, TIA Portal has the Reference projects panel disabled. Both panels can be enabled (or disabled) by clicking View from the top menu and then checking the panels to be made visible.

Reference projects

Making use of a previous project as a template is a great way to maintain consistency between projects. Loading two instances of TIA Portal should be avoided if possible as TIA Portal can be resource-hungry; lighter development machines may lack the resources to maintain two or more instances of TIA Portal. You can see the Reference projects panel in the following screenshot:

Figure 1.12 – Reference projects panel

With reference projects, multiple projects can be open at the same time in Read-Only mode.

Reference projects can be opened and closed via the buttons immediately below the title banner.

Once the project is expanded in the reference project view, it resembles exactly the same view as the project tree, with all objects available as they would be if the project were to be opened normally.

Once a reference project is open and expanded, items within it (such as program blocks) can be opened and read as normal; however, a gray hue will appear on the object icon to indicate it is a reference object, as illustrated in the following screenshot:

Figure 1.13 – Reference object indication example

The difference is very subtle—ensure that the correct blocks are being worked with (although it is not possible to write to a reference block).

Uses of reference projects

There are many different reasons why a reference project may be used to aid development. In most cases, a reference project is used to serve as a guide; however, the following functionalities are also available:

Copying information between the reference project and main project: Objects from the reference view can be copied and pasted into the main project tree or dragged and dropped. This is a useful way to move blocks quickly between two projects.Comparison of objects: Objects can be compared between the reference project and the main project.mp file. This is a useful feature that allows programmers to quickly check the differences between two offline projects.

Note

To compare the reference project with the main project, right-click on an object and select Quick compare | Select as left object. Then, select the object to compare with and right-click, and then select Quick compare | Compare with <previously selected left object>.

TIA Portal will then compare the objects and display any differences.

Details view

The Details view pane is best described as a mini-project tree that shows only the child objects of the currently selected object in the project tree.

This is particularly useful when programmers want to drag and drop objects into the main activity area, as in the following screenshot example:

Figure 1.14 – Example of Project tree and Details view displaying the same child objects

Note

Not all options are available for an object when selected in the Details view. For example, an object can be opened, but cannot be renamed from the Details view pane.

Right-click options are also unavailable.

Uses of the Details view

The Details view pane is only capable of showing child objects and will not show any information when there are no child objects available.

The Details view pane would typically be used to do the following:

Preview child objects in a selected parent object.Directly open child objects in a selected parent object.Check basic details such as the block number or comments assigned to objects.

Overview view mode

The Details view pane also works in the Overview view mode, behaving in the same manner as if the object had been selected from the project tree directly.

The Overview view mode is similar to the Details view but uses the main activity area to display the results and shows all objects within the previously opened object.

The Overview view mode is entered by clicking the persistent Overview button at the bottom left of TIA Portal.

Note

Users of SIMATIC Manager (Siemens older development software) may find the Overview mode familiar when in the Details view (using the tabs at the top of the view). This displays blocks in a familiar way to how SIMATIC Manager displays blocks in the Details view.

Instructions and libraries

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:

InstructionsContains instructions for use when developing codeContains selection methods for selecting different versions of groups of instructionsContains any optional package instructions that have been loaded into TIA PortalLibrariesContains access to the project libraryContains 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 libraryThis contains Types and Masters that are relative to the current projectCan only be used by the currently opened projectGlobal libraryThis also contains Types and Masters that are used to update or populate the project libraryCan 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:

ReleasedIn test

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 instantiatedDefault 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 testVia 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 iconsGroup of data blocks: A folder containing only data blocksGroup of function blocks: A folder containing only function blocksGroup of mixed objects: A folder containing more than one type of objectEmpty 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