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 7: Simulating Signals in the PLC

In this chapter, we'll look at different methods we can use to simulate devices and logic.

Siemens TIA Portal has a built-in simulation package that lets you simulate a variety of different CPUs and the logic within them.

In this chapter, we're going to cover the following topics:

  • Running PLC/HMI in simulate mode
  • Managing simulated inputs
  • Creating a simulation interface
  • Safeguarding outputs when in simulation mode

Running PLC/HMI in simulate mode

In TIA Portal, both PLCs and HMIs can be run in soft simulate mode. When this occurs, the hardware runtime is run from TIA Portal, instead of the hardware. This runtime then behaves in the same way it would as if it were running in the hardware.

Starting a PLC simulation

To start a PLC simulation, select the device that's required from the Project tree area and click the Start Simulation button via the toolbar at the top of TIA Portal:

Figure 7.1 – Starting a simulation PLC

Clicking the Start Simulation button will automatically switch the network connection interface to PLCSIM.

Note

When you're running the PLCSIM interface, it is not possible to connect to another physical device, even with a different instance of TIA Portal (or even SIMATIC Manager, if it is installed).

Enabling simulation support

TIA Portal automatically disables the ability to simulate new blocks in a new project. If you...

Managing simulated inputs

S7-PLCSIM does not provide a solution for managing the simulation of input signals. It is up to the programmer to choose one of the following solutions:

  • Create a watch table and modify its input signals
  • Create an input mapping layer with dedicated simulation data

These two approaches both have strengths and weaknesses, but creating an input mapping layer is the correct choice when you wish to create standard control objects and UDTs.

Using watch tables to change inputs

In the Project tree area, open the Watch and force tables folder. Double-click the Add new watch table item; a new watch table called Watch table_1 will be created:

Figure 7.9 – The watch table view

The new watch table will open with no tags to be monitored. In the Address column, an Input address can be added that you can monitor.

Note

When input cards and remote I/O are added to a CPU in the Device configuration window, input memory...

Creating a simulation interface

Having an interface for the simulation system is vital if you wish to manipulate your simulation signals with ease. When the TIA Portal project is tested, simulation signals will need to be set to particular values to test how the production code reacts to the simulated input values. While this can be done by creating a watch table, it would be far more beneficial to the users of the simulation system to create an HMI in TIA Portal that interacts directly with the simulation code:

Figure 7.17 – The input mapping layer with simulation and an associated HMI

The concept behind this approach is that each asset has a dataset defined as a UDT that's either stored in a data block or as a variable in a wider simulation data block.

Simulation Interface HMI is connected to Asset Sim Data via a standard Siemens connection interface. This enables the HMI to change values and specify what is currently being sent to the PLC...

Safeguarding outputs when in simulation mode

When any automation system is running in simulated mode, outputs should be protected and made safe so that when the simulation is running, they aren't processed.

This can be achieved with an output mapping layer. Much like the input mapping layer, if the simulation system is active, the output memory addresses are filled with data that ensures they are in a safe state:

Figure 7.26 – Setting outputs to a safe state when in simulation mode

Note

The preceding diagram shows how all the physical data, both input and output, can be stored in the asset's dedicated structured data block. Preparing output data in the asset's dataset is a good way of encapsulating the process data and segregating the input and output layers of the project.

This means that our Input Mapping Layer could be changed to a network protocol such as Modbus and our Output Mapping Layer could be changed to a remote...

Summary

This chapter explored the concepts behind using standardized structures in simulations, as well as how to get starting with the built-in simulation platforms that TIA Portal offers.

Whether programmers are building large-scale bespoke projects or small-scale standard projects, the principles behind structuring data ensure that simulating any project is easier. It also means that no additional software is required.

In the next chapter, we will highlight some of the difficulties of standardizing code and data and what can be done to ensure that flexible options are available when projects deviate from the standards. We will also look at the dangers of using InOut interfaces with HMI/SCADA data and how to mitigate those risks.

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