Reader small image

You're reading from  PLC and HMI Development with Siemens TIA Portal

Product typeBook
Published inApr 2022
PublisherPackt
ISBN-139781801817226
Edition1st Edition
Right arrow
Author (1)
Liam Bee
Liam Bee
author image
Liam Bee

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.
Read more about Liam Bee

Right arrow

Chapter 6: Creating Standard Control Objects

This chapter explores using function blocks and functions to create standardized control objects.

This approach takes the structured aspect of programmable logic controller (PLC) programming to an additional level, where data and control are brought together to act as a standard method. By utilizing this approach, confidence in the reusability of code is greatly increased, while management and maintenance of code are greatly reduced.

In this chapter, the following topics will be covered:

  • Planning standard interfaces
  • Creating control data
  • Creating HMI data
  • Structuring logic
  • Considerations that have an impact on usability

    Note

    This chapter builds on information contained in Chapter 3, Structures and User-Defined Types.

Planning standard interfaces

An interface to a function block or function is the first point at which a programmer can start to control how an object is interacted with. The interface serves as a ruleset of what is allowed to be passed in and out of this object.

You can see an example of an interface in the following screenshot:

Figure 6.1 – Basic interface example

By offering an interface, programmers (and other people who may have to maintain or modify the project) have a better chance at reducing mistakes when using the object.

Defining variables in an interface

An interface is made up of three different key areas, as outlined here:

  • Inputs
  • Outputs
  • InOut variables

Each behaves differently and performs different functions.

Inputs

Inputs are variables that are read-only. Once an input interface variable is passed into an object, it is not recommended to modify it. TIA Portal does allow input variables to be written...

Creating control data

By creating control data, programmers create a specific set of criteria or variables that all standard controls should follow. This is a dataset that should follow a requirement or process, such as the following:

  • All asset controlling function blocks should return one of the following status types:
    • Healthy status
    • Running status
    • Not available status
    • Inhibit status

The preceding status types can be added to a Struct data type called Control_Data, as illustrated in the following screenshot:

Figure 6.14 – Example of a Control_Data output

Figure 6.14 demonstrates a function with an output for the Control_Data elements. The output is a struct containing elements that go on to be used in a program for control and interlocks with other equipment.

The contents of this Control_Data struct are shown here:

Figure 6.15 – Control data output

The Control_Data_Example asset control function block is...

Creating HMI data

Just as with control data, it's usually a good idea to have a general concept of how human-machine interface (HMI) data will come together.

This is the information that is used to display statuses, control graphics, and any other specific HMI requirements. Segregating these variables from other variables helps keep the vast amount of data that HMI/supervisory control and data acquisition (SCADA) systems require clean and easy to use.

Creating a UDT to house this information makes it easy to add it into datasets for assets later on, as illustrated in the following screenshot:

Figure 6.24 – Example of HMI data for a pump asset

Each instance of a pump asset would then have its own UDT_Pump_HMI_Data instance that the HMI would interact with.

This approach, much the same as for control data, allows for each standard control object in the project to have a known and designated area for HMI interaction. This helps unrelated blocks...

Structuring logic

For standard control objects to feel familiar with each other, the logic should be laid out in roughly the same approach. By following a generic ruleset for each standard control object, code (written in any language) should be easy to pick up and read by anyone that uses the standard controls.

General layout

Control object logic can be easily planned for with a generic template, as illustrated here:

Figure 6.26 – Example of a generic template for standard control block logic

Figure 6.26 is an example of a layout for generic standard control objects. If all objects in the project follow this general paradigm, then programmers and maintainers of the project will have a much easier time reading the logic within the standard control.

Supportive methods

In large standard control objects, each area of the template (Figure 6.26) could be created as a function or function block. Each supportive object could then follow the same...

Considerations that have an impact on usability

When creating standard control objects, there are many different aspects to consider. Key items are listed here:

  • 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?

These sorts of questions can alter the approach that is taken for the control object being developed.

How flexible does the control object need to be?

A good example of a flexible control object would be an analog scaling standard control object, as illustrated in the following screenshot:

Figure 6.28 – Interface for a standard control object that controls analog scaling

The Scaling_Manager interface pictured in Figure 6.28 has many different inputs that exceed the basic requirements to scale a value. This particular control method is capable of performing the following additional methods:

  • Scaling beyond...

Summary

This chapter covered creating standard control objects, with a viewpoint of structuring data and logic layouts, as well as the management of interface variables.

The knowledge gained from this chapter should help programmers to write standard control objects that are easy to maintain, expand, and modify while retaining a standard approach to the development.

The next chapter focuses on the simulation of code so that programmers can test the inputs and outputs of the project without any hardware requirements. This includes using standard control objects to manage the mapping of information through mapping layers.

lock icon
The rest of the chapter is locked
You have been reading a chapter from
PLC and HMI Development with Siemens TIA Portal
Published in: Apr 2022Publisher: PacktISBN-13: 9781801817226
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
undefined
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime

Author (1)

author image
Liam Bee

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.
Read more about Liam Bee