0% found this document useful (0 votes)
6 views

Refill_Premium_Guide

Uploaded by

lamboferrarigt
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

Refill_Premium_Guide

Uploaded by

lamboferrarigt
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 52

TABLE OF CONTENTS

1 CHANGE HISTORY ...................................................................................................................................... 3


1.1 Versions ............................................................................................................................................... 3
1.2 Future Updates .................................................................................................................................... 3
2 INTRODUCTION .......................................................................................................................................... 4
2.1 How to Use this Guide ......................................................................................................................... 4
2.2 Who is this Guide for? ......................................................................................................................... 5
2.3 Why a Premium Sample Application? ................................................................................................ 5
2.4 What’s New in the Premium Application? .......................................................................................... 5
2.5 How to Get Started .............................................................................................................................. 6
3 GENERAL CHANGES................................................................................................................................... 8
3.1 Revised HMI Application ..................................................................................................................... 8
3.2 PLC Naming Conventions ................................................................................................................... 9
3.3 Language Toggle Button ..................................................................................................................... 9
Implementation ................................................................................................................................... 10
3.4 Configuration Blocks ......................................................................................................................... 12
Implementation ................................................................................................................................... 14
4 EQUIPMENT MODULES ............................................................................................................................ 16
4.1 PID Control ......................................................................................................................................... 16
Implementation ................................................................................................................................... 19
4.2 Stirrer and Drain Valve ...................................................................................................................... 25
5 MACHINE MODULES ................................................................................................................................ 27
5.1 State Handler ..................................................................................................................................... 27
5.2 Alarm Handling .................................................................................................................................. 29
Implementation ................................................................................................................................... 32
5.3 Recipe Handling................................................................................................................................. 34
Implementation ................................................................................................................................... 38
5.4 User Administration .......................................................................................................................... 39
Implementation ................................................................................................................................... 40
5.5 PLC Status and Control ..................................................................................................................... 41
Implementation ................................................................................................................................... 43
5.6 Network Status .................................................................................................................................. 43

PLCSKILLTREE.COM

Email: [email protected]

Web: www.plcskilltree.com REFILL PREMIUM APPLICATION GUIDE V1.0 | 1


Implementation ................................................................................................................................... 44
5.7 HMI Status and Control ..................................................................................................................... 45
Implementation ................................................................................................................................... 46
6 SIMULATING/TESTING THE SAMPLE APPLICATION ............................................................................ 49
7 BEFORE YOU GO ....................................................................................................................................... 52

PLCSKILLTREE.COM

Email: [email protected]

Web: www.plcskilltree.com REFILL PREMIUM APPLICATION GUIDE V1.0 | 2


1 CHANGE HISTORY

1.1 VERSIONS

Version Description Date

1.0 First Version 10/05/2023

1.2 FUTURE UPDATES

Have you checked the above change history? Yes, this application has versions! That means that
more awesome features will be added in the future. And as long as you’re a subscriber on
plcskilltree.com (which you automatically are if you signed up for this premium edition), you’ll be
informed via email when a new version of the premium application is available.

These features will most likely be added in future updates of the premium application:

• A standard block for controlling a Siemens frequency converter over Profinet - including alarm
handling, input/output tag structures, HMI parameters
(Will be used in the premium application for controlling the speed of the pumps)
• Light Tower for annunciation of different alarm types using green/yellow/red light and horn
• OB1 scan time visualized in ms on the diagnostics screen (with min/max/actual)
• OB Interrupts for network faults, program faults, and more
• A dedicated alarm class for user administration messages so user logons/logoffs can be
displayed on a separate alarm view window
• Import/export of users (usernames/passwords)
• Different alarm text colors on HMI for the different alarm types (e.g., faults = red text,
warnings = yellow text)

Interested in specific features that would be useful for your own


applications? Simply let me know by writing me an email. I will collect all
your requests and use the most popular features in a future update.

PLCSKILLTREE.COM

Email: [email protected]

Web: www.plcskilltree.com REFILL PREMIUM APPLICATION GUIDE V1.0 | 3


2 INTRODUCTION

2.1 HOW TO USE THIS GUIDE

Welcome to the Refill Premium Application guide!

So you’ve gone through all lectures of the TIA Portal - PLC Programming Basics / HMI Basics courses
and you’re hungry for more? Well, you’ve come to the right place.

In this Refill Premium Application, EVERY aspect of the original sample application (Refill_HMI.zap14)
has been expanded, updated and improved upon – with TONS of more functionality, features and
advanced PLC and HMI programming. And I am very excited to share this with you.

This guide is your “HOW-TO” document that compliments the premium sample application.
In this guide, I will explain to you in detail which concepts have been expanded and improved upon,
AND I will support you with step-by-step instructions on how to implement those new features into
your own projects.

GO EXPLORE YOURSELF
But I left some exploring for you as well… In my experience, you learn the most from trying out things
yourself. I would recommend you dig deep into the sample application, check out how it’s made, go
into the button properties, events etc… Just get your hands dirty!

If you need additional information on any functions or instructions used in the premium application,
then TIA Portal has an amazing information system. Go to the Help tab in the top bar and select
‘Show help’.

This opens a new window ‘Information system’ where you can search for any instruction/function you
would like more information about. USE THIS. I use it almost on a daily base to dive deeper into the
functionality of certain instructions or functions. There’s always more to learn.

PLCSKILLTREE.COM

Email: [email protected]

Web: www.plcskilltree.com REFILL PREMIUM APPLICATION GUIDE V1.0 | 4


LET’S MAKE THIS GUIDE AWESOME
If anything in this guide is unclear to you, please write to me at [email protected]. Let’s work
together to create the best guide possible for YOU. And with your help, we can make that happen.

Sounds good so far? Alright, let’s get started.

2.2 WHO IS THIS GUIDE FOR?

This guide is recommended for anyone who has gone through my TIA Portal - PLC Programming
Basics and TIA Portal - HMI Basics courses and is eager to add more advanced PLC and HMI
modules and features to their own applications.

You can use this guide as well without finishing my courses first, but you will miss out on a lot of basic
concepts and information taught in those courses. You might have some questions which are already
answered in those courses, so please take the above courses first before jumping on this premium
application.

2.3 WHY A PREMIUM SAMPLE APPLICATION?

The idea with this premium sample application, is to use the momentum of the skills you’ve learned in
the PLC and HMI courses to introduce you to more advanced concepts and features which you can
copy and use in your own applications. You’ve gone through the courses, and you are now familiar
with the basic concepts and structures taught in those courses. In this premium application, we will
build on this foundation, and we will expand your knowledge on basically all aspects of the standard
sample application. Get ready to grow!

2.4 WHAT’S NEW IN THE PREMIUM APPLICATION?

Tons of new features have been added in this premium sample application and I will explain each of
those features in detail in the following chapters of this guide. But to give you a sneak peek at what
you can expect, here is a quick overview of the new features included in the premium application:

GENERAL CHANGES
• A totally revised HMI look with crisp, modern graphics on a bigger 12’’ display
• A language toggle button on the HMI top bar for switching between different languages
• Configuration blocks for equipment and machine modules

EQUIPMENT MODULES
• A brand-new PID control (including a fully featured HMI screen) for controlling the
temperature inside each process tank
• A new stirrer and drain valve for each process tank

PLCSKILLTREE.COM

Email: [email protected]

Web: www.plcskilltree.com REFILL PREMIUM APPLICATION GUIDE V1.0 | 5


MACHINE MODULES
• State Handler
o A new initialization state for when the PLC boots up
o A new draining state for emptying the process tanks
• Alarm Handling
o A new alarm handling machine module (FB)
o 3 distinct alarm types: faults (affect the current state handler state), warnings and
messages (don’t affect the current state handler state)
o Visual indication of alarm types on the HMI template
• Recipe Handling
o A new recipe handling machine module (FB)
o Last save date & time for each data record
o Backup & recover recipes using a USB dongle
o Warning texts for failed data record load or save
o Remote loading of a data record through a PLC command
• User Administration
o A new user administration machine module (FB)
o History log of changes in user logon/logoff
• PLC Status and Control
o A new PLC machine module (FB)
o Setting the PLC date and time from the HMI
o Visualisation of PLC LED status on the HMI
• Network Status
o A new network machine module (FB)
o Displaying the status of each network node on the HMI
o Warnings for offline nodes
• HMI Status and Control
o A new HMI machine module (FB)
o Remote jumping to different screens through a PLC command

Yep, that’s quite a list. When I first started this project, I just had a couple of new features. But I got
super excited and kept adding more and more features for you to it.

In the following chapters, we’ll dive deeper into each new feature, and I’ll give you a step-by-step action
plan on how to implement these features in your own applications.

2.5 HOW TO GET STARTED

Your premium content consists of only one module titled ‘Your Premium Content’ containing 2
lessons: ‘Premium Sample Application’ and ‘HMI Graphics in SVG Format’. Short and sweet so you
don’t get lost.

PLCSKILLTREE.COM

Email: [email protected]

Web: www.plcskilltree.com REFILL PREMIUM APPLICATION GUIDE V1.0 | 6


The first thing you’ll need to do is download the premium sample application from the Downloads
section of the ‘Premium Sample Application’ lesson.

This premium application was developed using TIA Portal V14 (for optimal compatibility with all
versions out there). Hence, to work with this application, you will need TIA Portal V14 or higher. If
you’d like to simulate the PLC and HMI applications as well (which I would highly recommend), then
you would need Siemens’s proprietary simulation software S7-PLCSIM as well.

If you happen to have a higher version of TIA Portal V14, no problem. When retrieving/opening the
project, TIA will tell you that the project needs upgrading. Just accept this and you’re all set.

As I have pointed out in my courses, if you do not have the TIA Portal software, there is a solution to
this as well. You can download a 21-day free trial version of TIA Portal. Click on one of the links
below to get started.

• Get the TIA Portal V15 SP1 Trial Version


• Get TIA Portal V16 Trial Version
• Get TIA Portal V17 Trial Version
• Get TIA Portal V18 Trial Version

Alternatively, you can open a web browser and search for ‘download TIA Portal trial Vxx’.

If you decide to download a trial version, I recommend you start with TIA Portal V15 SP1. When your
trial has expired, you can continue with V16, then V17, etc…

So now that you’re all set and ready for action, let’s go and explore the new features of this premium
application in the next chapters.

PLCSKILLTREE.COM

Email: [email protected]

Web: www.plcskilltree.com REFILL PREMIUM APPLICATION GUIDE V1.0 | 7


3 GENERAL CHANGES

3.1 REVISED HMI APPLICATION

The HMI application has been rebuilt from the ground up using a larger display (Comfort Panel 12’’
instead of the 9’’ from the original application) boosting a crisp new look for all icons and graphics.

TIP – You can download all HMI graphics in the


original raw .svg (scalable vector graphics) format in
the second lesson of your premium content module.

Instead of processing water and oil in the refill tanks, we are now brewing tasty varieties of tea! The
HMI recipe is pre-configured with 3 different tea types: green tea, herbal tea, and Jasmin tea.

The new HMI application comes as well with an all new PID temperature control
screen, which you can access directly from each screen using the template button on
the right side of the screen. We’ll dive deeper into the inner workings of this PID control
in the next chapter.

The diagnostics screen has also received a major overhaul and includes now the possibility to set the
PLC date and time, a status of the LEDs on the front of the PLC (Run, Stop, Error), and a status
overview of the different network nodes.

PLCSKILLTREE.COM

Email: [email protected]

Web: www.plcskilltree.com REFILL PREMIUM APPLICATION GUIDE V1.0 | 8


3.2 PLC NAMING CONVENTIONS

The premium sample application features a new naming convention for the different blocks of the
software which adds another layer of clarity and structure to each block name.

All blocks and user-defined types related to machine modules use the acronyms ‘MM’ in the name.

E.g. FB - MM Recipe Handling


E.g. UDT_MM_Recipe_Handling

All blocks and user-defined types related to equipment modules use the acronyms ‘EM’ in the name.

E.g. FB - EM Refill
E.g. UDT_EM_Refill

I have chosen these acronyms to make it instantly clear to which type of module a certain block or
UDT belongs. As with most things, this is not an exact science. If you have a different approach that
makes more sense for the structure of your application, go ahead and use that. What’s important here
is that you are aware of the advantages of using a structured naming system for the different
components of your application. It’s all about making the application easy to understand and
troubleshoot for yourself, your colleagues, technicians, and other people that might be working with
your application.

3.3 LANGUAGE TOGGLE BUTTON

The top bar of the HMI template screen has been revamped and now includes an indication of the
current machine state and on the far right, a language toggle button.

Pressing this button toggles the displayed language on the HMI between the different languages
configured for the HMI application. For this premium sample application, English and German have
been configured.

PLCSKILLTREE.COM

Email: [email protected]

Web: www.plcskilltree.com REFILL PREMIUM APPLICATION GUIDE V1.0 | 9


An important thing to remember here is that languages are project-specific, not device specific. So if
you got a PLC application (PLC device) and an HMI application (HMI device) in your project, then your
configured languages will apply for the PLC and the HMI application.

So what does this mean practically? It means that if you write network comments and descriptions in
your PLC program in English, and switch the editing language to e.g. German, then all your comments
and description in the PLC program will switch as well to German (this typically means that there will
be no comments and descriptions anymore, unless you translated all the English ones to German).
Keep this in mind.

TIP - Be consistent and preferably always edit your PLC logic, network titles, comments,
descriptions, … in the same language.

IMPLEMENTATION
Ready to go multi-lingual? Follow these 3 basic steps to add multiple languages and a language
toggle button to your own HMI application.

1. Configure your project languages.

Select your project e.g., Refill_Premium_Vx_x, and in the top bar go to Tools -> ‘Project
languages’. Mark which languages you would like to use for your application.

In our example, we have selected English and German as project languages.

PLCSKILLTREE.COM

Email: [email protected]

Web: www.plcskilltree.com REFILL PREMIUM APPLICATION GUIDE V1.0 | 10


2. Define which languages to use in your Runtime application.

In the first step we selected which languages are being used for our PROJECT environment.
Now we need to define which of those languages we’d like to use in RUNTIME.

To define your runtime languages, go to ‘Runtime settings’ in your HMI application (tree
structure on the left) and under the ‘Language & font’ tab, select your runtime languages.

In our example, we have selected English and German as runtime languages.

3. Add a language toggle button to your HMI.

Create a new button on your HMI (I recommend placing it on the top bar of your template for
easy access).

Go to the Events tab of the button properties, and for the Press event add the function
‘SetLanguage’ (just start typing the function name in the <Add function> field) with the
Language set to ‘Toggle’.

Adding a language toggle function to your language button.

IMPORTANT – If you only have one runtime language selected,


toggling your language button will have no visible result since you
don’t have any languages to toggle between. Remember to
configure your runtime languages.

Awesome! You have now successfully configured your project and runtime languages, and you
created a language toggle button on your HMI. The only thing left to do now is to translate your
default / editing language (e.g., English) to your other languages (e.g., German). If you got the TIA
Portal - HMI Basics course, then you’ll find a bonus lecture towards the end of the course explaining in
detail how to export/import languages in TIA Portal. Alternatively, you can go and watch a step-by-
step guide right HERE.

PLCSKILLTREE.COM

Email: [email protected]

Web: www.plcskilltree.com REFILL PREMIUM APPLICATION GUIDE V1.0 | 11


3.4 CONFIGURATION BLOCKS

While working your way through the PLC course, you might have noticed that the data type for each
module has the same setup: Module.Cfg, Module.Sts, Module.Par, Module.Flt, etc…

In the standard sample application, the configuration structure (Module.Cfg) was not being used, it
was only added to complete the overall picture of the module structure. In the premium application,
we are using the configuration area for a handful of modules to configure/initialize module variables.
The values for those configuration variables are written in configuration blocks (FCs).

Configuration blocks for machine and equipment


modules.

In the configuration block ‘FC - MM Config’, values are assigned to configuration variables of machine
modules.

Configuration variables for machine modules in ‘FC – MM Config’.

PLCSKILLTREE.COM

Email: [email protected]

Web: www.plcskilltree.com REFILL PREMIUM APPLICATION GUIDE V1.0 | 12


In the configuration block ‘FC - EM Config’, values are assigned to configuration variables of
equipment modules.

Configuration variables for equipment modules in ‘FC – EM Config’.

TIP - Your configuration blocks are only used to assign values to variables
without any other type of logic. I would highly recommend using a text-based
language like SCL for your configuration blocks instead of a more visual
language like ladder or function block diagrams. With SCL, you get a nice clean
list of variables from top to bottom.

One way we are using configuration variables in the premium application is to set the minimum and
maximum entry values for the parameters used in our application. Instead of having fixed min/max
limits in the HMI, it is now possible to configure those limits directly in the PLC.

TIP – It is always much easier to make small changes (e.g., changing values of
configuration variables) in the PLC application than making changes in the HMI
application. PLC changes can be made quickly online using very little download
time (it literally only takes a couple of seconds to apply online changes to a
running PLC application) and without production interruption. HMI changes
need to be downloaded, which typically takes 1 minute or more, with the panel
executing a reboot after the download is finished (might be not desirable during
production).

Another way configuration variables can be used, is to set timer presets (in the premium
application, we do this for the time that the initialisation state of the state handler is
active) or to define offsets for low/high warnings or faults (we do this for defining low
and high temperature warnings in the sample application). There are off course many
other uses for configuration variables and your application will require its specific set of
configuration variables.

Now here’s an interesting question: How do you decide if a variable is a ‘configuration’


variable and not a ‘parameter’ variable? What is the difference?

PLCSKILLTREE.COM

Email: [email protected]

Web: www.plcskilltree.com REFILL PREMIUM APPLICATION GUIDE V1.0 | 13


Try to think of configuration variables (Module.Cfg) as a basic configuration for your
machine which only needs to be setup once during the commissioning phase of the
project. Once the machine is up and running correctly, these variables do not change
value anymore, they are FIXED.
On the other side you have parameter variables (Module.Par). These are recipe
dependent variables, which change value according to the product or process that you
are running on your machine or line. These variables are NOT FIXED.

I make heavy use of configuration blocks in my own applications because they neatly
pack all important parameters in one place. No need to go and search through all your
blocks if you want to change a value = saves a lot of time.

IMPLEMENTATION
Add configuration variables and configuration blocks to your own application by applying
these 4 easy steps:

1. Add a configuration structure to your module data type and add your
configuration variables

2. Create a configuration block (FC), preferably in SCL


(don’t forget to call it)

3. Assign values to your configuration variables in your configuration block

PLCSKILLTREE.COM

Email: [email protected]

Web: www.plcskilltree.com REFILL PREMIUM APPLICATION GUIDE V1.0 | 14


4. Use your configuration variables in your logic or on your HMI (in case of input
entry limits)

Example of using configuration variables for defining lower


and upper entry limits for an HMI parameter.

And that’s all there is to it!

Again, if any of these steps are unclear to you, just write me and let’s make this the best guide
possible.

PLCSKILLTREE.COM

Email: [email protected]

Web: www.plcskilltree.com REFILL PREMIUM APPLICATION GUIDE V1.0 | 15


4 EQUIPMENT MODULES

Now that we have covered the general changes of the premium application, let’s continue with the
new features of the equipment modules. As I teach in my courses, the way I structure applications is
by separating general machine modules from equipment modules.

Machine modules are not specific to your machine or process, they perform general functions that
can be found on most machines. They do not include any devices or equipment you might have in
your application (like pumps, valves, temperature sensors). Examples of machine modules are recipe
handling, alarm handling, user administration, network status, setting plc date/time. These modules
can be directly copied to most types of applications with little to no change.

Equipment modules are specific to your machine or your process. They are tailored to the specific
equipment, devices, units that you have in your application and need to be programmed/adapted to
your specific machine. Examples are a fill module, a water system module, a refill/supply module, a
mould heating module.

Depending on the project, I might use the name ‘system’ modules, or ‘general’ modules instead of
‘machine’ modules. It is not an exact science, and it depends on the application. If my application
has motion, I’ll typically have at least 3 types of modules: machine modules, equipment modules, and
motion modules. If there’s upstream or downstream communication as well, those might be a
separate group. It’s all about creating a logical structure that fits your application and in which
coherent modules are grouped together. Define a proper program structure BEFORE adding logic and
you’ll be handsomely rewarded in the end.

The refill module of the premium application has received the following new features:

1. A fully featured PID control for controlling the temperature in each process tank
2. A stirrer for mixing the liquid and for even distribution of temperature in each process tank
3. A drain valve for emptying each process tank

Now let’s go and take a closer look at each one of those features in the sections below.

4.1 PID CONTROL

In the standard sample application, we just had a liquid in each process tank with no temperature
control. The premium application now features a fully fleshed-out PID control for reaching the desired
temperature in each process tank.

HOW DOES IT WORK?


A typical PID controller uses a process value (PV) and a setpoint (SP) to output a 0-100% control
value (CV). In our example, we are using a temperature sensor (PV = input) and a setpoint
temperature (SP = input) to control an analogue heating valve (CV = output).

PLCSKILLTREE.COM

Email: [email protected]

Web: www.plcskilltree.com REFILL PREMIUM APPLICATION GUIDE V1.0 | 16


Setpoint (SP), Actual Value (PV) and Control Value (CV) on the HMI.

Every PID controlled process is different. The amount and speed of changes to the control value in
relation to changes in the process value are determined by the Proportional (P), Integral (I), and
Derivative (D) actions of the PID control. In the premium sample application these P, I and D
parameters can be set from the HMI and are recipe dependent (we assume that different tea types
have different heating profiles).

P, I and D variables can be set from the HMI.

TAG MULTIPLEXING
To display multiple PID processes using only 1 set of tags, we are going to use tag multiplexing.

A multiplex tag is a tag that takes on a tag from a pre-defined list depending on the value of an index
tag (type INT).

In our premium application, we use multiplex tags to display parameters and status information for
multiple PID processes – process tank 1 or process tank 2 - with only one set of tags (= multiplex
tags). We select which PID process to visualize by using a selection list (= index tag & text list).

PLCSKILLTREE.COM

Email: [email protected]

Web: www.plcskilltree.com REFILL PREMIUM APPLICATION GUIDE V1.0 | 17


This solution of creating just one set of tags on one screen with a selection list is easily scalable and
reduces setup time.

For more information on multiplexing, go and check out this support post from Siemens RIGHT HERE.

TREND VIEW
To visualizes the effect of changing P, I or D values in relation to PV/SP/CV, a PID control can be
equipped with a trend view. A PID trend view typically plots setpoint, process value and control value
continuously over time.

A trend view displaying process value, control value and setpoint in different colours.

For the premium application, I have created a trend view which plots setpoint and process value -
using the 20-100°C scale on the right side of the trend - and control value - using the 0-100% scale on
the left side of the trend.

From the screenshot example above, you can pinpoint the exact moment where
I enabled the PID control. At this point, the control value starts to increase
(=heating valve starts to open) from 0% all the way to around 45-46% where it
stabilizes because the actual temperature (process value) has reached the
setpoint temperature.

PLCSKILLTREE.COM

Email: [email protected]

Web: www.plcskilltree.com REFILL PREMIUM APPLICATION GUIDE V1.0 | 18


To complete the PID control screen, I have added switches to enable/disable the PID controller for
each tank, and to turn on/off the stirrer for each tank.

IMPLEMENTATION
Wow, that was a lot of theory to start with. Now let’s get practical! This is how you implement the PID
control feature from the premium application into your own application.

PLC INTEGRATION

1. Integrate the PID control block

Copy the data type ‘UDT_PID_Control’ (PLC data types -> Library -> User) to your application.
Copy the block ‘FB - PID - Control’ (Program blocks -> Library -> User) to your application.

PLCSKILLTREE.COM

Email: [email protected]

Web: www.plcskilltree.com REFILL PREMIUM APPLICATION GUIDE V1.0 | 19


NOTE – The PID control block ‘FB - PID - Control’ uses the instruction
CONT_C for PID control. This instruction is not compatible with S7-
1200 PLCs. If you’re using a S7-1200, I would recommend using the
PID_Temp instruction for temperature PID control or PID_Compact
for any other PID control.

2. Add variable ‘PID’ (data type UDT_PID_Control) to your module data type

3. Call ‘FB - PID - Control’ inside your module and add tags to the inputs/outputs of the block
call

PLCSKILLTREE.COM

Email: [email protected]

Web: www.plcskilltree.com REFILL PREMIUM APPLICATION GUIDE V1.0 | 20


The block interface of ‘FB - PID - Control’ contains the following inputs and outputs:

Parameters Declaration Data Default Description


Type Value

i_rProcess_Value INPUT REAL 0.0 The measured value that


needs to be regulated (e.g.,
temperature, flow, pressure,
speed).

i_xEnable INPUT BOOL FALSE FALSE PID control is


disabled.
TRUE PID control is
enabled.
i_xReverse_Action INPUT BOOL FALSE FALSE Direct acting
controller (control
value increases
as process value
increases e.g.,
cooling).
TRUE Reverse acting
controller (control
value decreases
as process value
increases e.g.,
heating).
i_xTimeBase_Bit INPUT BOOL FALSE Frequency pulse bit equal to
the time interval between
each execution of the PID
control block.
i_tTimeBase_Period INPUT TIME T#1s Time interval between each
execution of the PID control
block.
iq_stFlags INOUT UDT_MM_SYSTEM_FLAGS - System flags data structure

iq_stPID INOUT UDT_PID_CONTROL - PID control data structure

q_wControl OUTPUT WORD 16#0 Control value between 0 and


27648.
q_rInfo_CV OUTPUT REAL 0.0 Control value between 0 and
100% (info only).

For the premium application, we are using a heating type control. This
means that a negative error (actual temperature < setpoint) increases
the heating valve opening (=more heating). This is called a reverse
acting controller. The opposite is called a direct acting controller. In
this case a positive error will increase the control value. This is for
example the case in a cooling type control where the cooling valve
opening increases (=more cooling) if actual temperature > setpoint.

PLCSKILLTREE.COM

Email: [email protected]

Web: www.plcskilltree.com REFILL PREMIUM APPLICATION GUIDE V1.0 | 21


Timebase bit and timebase period are used to define the frequency of execution of the
Siemens PID control block inside ‘FB - PID - Control’ and should be configured congruently.
E.g., if the timebase BIT is configured with a 1 second pulse (e.g., 500ms high 500ms low),
then the timebase PERIOD must be configured as 1 second.

HMI INTEGRATION
1. Create multiplex tags

Copy the ‘Local PID Tags’ (HMI tags -> Local Tags) from the premium application to your own
application.

For each tag (except the index tag), go to the ‘Multiplexing’ property, and add the Index tag and
a tag for each value of the Index (e.g., if you have 2 PID processes, add 2 tags).

If _iPID_Index has the value “0”, the tag ‘DB - Equipment_Refill_Process_1.PID.rControl_Value’ will be used.
If _iPID_Index has the value “1”, the tag ‘DB - Equipment_Refill_Process_2.PID.rControl_Value’ will be used.

2. Integrate the PID screen

Take over all content from the ’30 PID Control’ screen of the premium application to your own
application. Check which tags are used, how the layers are setup, etc.

3. Setup the Trend Views

Define a Layer for trend views and add as many trend views as you have PID processes.

PLCSKILLTREE.COM

Email: [email protected]

Web: www.plcskilltree.com REFILL PREMIUM APPLICATION GUIDE V1.0 | 22


A dedicated Layer with a Trend View for each PID process.

For each trend view, configure the visibility animation using the index tag. Each trend view
must be configured with a unique value for the index tag and will only be visible for that
specific value of the index tag.

Visibility for Trend View process 1 is configured ‘Visible’ for index value “0”.

For each trend view, add the different PID variables that you want to plot.

Configuration of Trend values.

Notice that you can decide which ‘Side’ (= which Y-axis scale) the variable will use. By
selecting ‘Right’, that variable will be plotted using the right Y-axis scale, and by selecting ‘Left’,
the variable will be plotted using the left Y-axis scale.

You configure the scales for left and right under Properties -> ‘Left/Right value axis’.

PLCSKILLTREE.COM

Email: [email protected]

Web: www.plcskilltree.com REFILL PREMIUM APPLICATION GUIDE V1.0 | 23


E.g., Left value axis is configured from 0 to 100.

4. Optional - Add PID information to your process overview screen

You can add PID control information (process value, setpoint, control value) to your process
overview screen or to any other screen where you think it could be of use to the operator. In
our premium application, we have added the actual temperature, setpoint temperature, and
control value on the process overview screen for each process tank.

And to put the cherry on the cake, add an invisible screen jump button on top of the PID
control information (use a different layer for this). Pressing this button will set the PID index
to the relevant value for that PID process and releasing it will jump to the PID control screen
where to correct process will be visualized.

PLCSKILLTREE.COM

Email: [email protected]

Web: www.plcskilltree.com REFILL PREMIUM APPLICATION GUIDE V1.0 | 24


5. Optional - Create alarms for sensor fault, low/high temperature warnings

It’s essential for an operator to know if a certain PID process is working the way it should. To
start with, you should have a warning or fault for when your input signal is faulty. This can for
example be due to wire break or due to an incorrect setup of the hardware configuration (e.g.,
using a 4-20mA sensor and configuring the analogue input card for Voltage instead of
Current).

Secondly, your PID controlled application looks more advanced if it includes warnings that
indicate that your setpoint is not being reaching within a certain time period.

o Example 1: Let’s assume that your setpoint is 30 and your process value is 15. By
enabling your heating PID control, you would expect that your process value will climb
up to 30 after a certain time period. If your process value remains low and is barely
climbing up, this could mean that your output device (e.g., heating valve) is not
operating correctly -> operator low level warning.
o Example 2: Let’s assume that your setpoint is 30 and your process value is 45. By
enabling your cooling type PID control, you would expect that your process value
would cool down to 30 after a certain time period. If it remains high, it might be that
your cooling valve is not opening -> operator high level warning.

The premium sample application contains alarm texts for sensor fault and low/high
temperature for refill process 1 and 2. To add those to your application, copy the alarms logic
from the Refill module ‘FB - EM Refill’, and create the alarm texts for the HMI application.

Execute all 5 steps above, and you’ll have added an impressive fully featured PID control to your PLC
and HMI application. Let’s DO this!

4.2 STIRRER AND DRAIN VALVE

Each refill process tank has been upgraded with a stirrer and a drain valve.

PLCSKILLTREE.COM

Email: [email protected]

Web: www.plcskilltree.com REFILL PREMIUM APPLICATION GUIDE V1.0 | 25


The stirrer is used to evenly distribute the desired temperature inside the tank. The operator can
enable the stirrer for each tank from the PID control screen.

The drain valve is used to drain each process tank. This is part of a new state handler process state
‘Draining’ which is described in more detail right here: 5.1 State Handler.

By pressing the ‘Drain Tanks’ button on the overview screen, the drain valves are opened.

Open the drain valves by pressing the ‘Drain Tanks’ button.

So that was it for the equipment modules. If any of these implementation steps are unclear, write me
an email, and we’ll make this guide even better.

Ready for more? Let’s move on to the exciting new features of the machine modules!

PLCSKILLTREE.COM

Email: [email protected]

Web: www.plcskilltree.com REFILL PREMIUM APPLICATION GUIDE V1.0 | 26


5 MACHINE MODULES

5.1 STATE HANDLER

In the standard application, the state handler had the following 4 states: Ready, Running, Faulted, and
Reset.

The premium application expands upon this and now features 5 states: Init, Ready, Production,
Draining, and Faulted.

These states are also displayed in the top bar of the application.

State displayed on the top bar (top left side of the HMI screen).

The INIT state is an initialization state that is triggered as soon as the PLC boots up. This state can
be used to initialize certain variables in your application or to wait a certain time after boot-up before
any operations with the application are allowed. Upon completion, the init state transitions to the
ready state.
The initialization time (=duration of the init state) can be configured in ‘FC - MM Config’ using the
configuration variable ‘DB - Machine.StateHandler.Cfg.tInit_Time’. For more information on
configuration blocks, check section 3.4 Configuration Blocks.

The READY state is the default state when the application is not running and not faulted. It indicates
that the application is ready to run production or ready for draining.

The PRODUCTION state is active when the application is running production, after the operator has
pressed the start button on the process overview screen (requires ready state). When the operator
presses stop, the application goes back into the ready state.

The DRAINING state is a new process state that is triggered when the operator presses the ‘Drain
Tanks’ button on the process overview screen (while in ready state). This state is used to drain both
process tanks. This is useful for example before a cleaning of the tanks takes place.

PLCSKILLTREE.COM

Email: [email protected]

Web: www.plcskilltree.com REFILL PREMIUM APPLICATION GUIDE V1.0 | 27


Press the ‘Drain Tanks’ button to open drain valves for process tanks 1 & 2.

To inform the operator that the drain state is active, the alarm view displays an information message.

The FAULTED state is active when a fault occurs. When all faults are cleared, the faulted state
transitions to the ready state.

You might have noticed that the RESET state did not make it to the premium
application. Resetting faults has been moved to a dedicated alarm handling
module (see 5.2 Alarm Handling) that takes care of all application alarms, including
resetting them.

PLCSKILLTREE.COM

Email: [email protected]

Web: www.plcskilltree.com REFILL PREMIUM APPLICATION GUIDE V1.0 | 28


5.2 ALARM HANDLING

The standard sample application just had one alarm type - a fault. Any module fault forced the state
handler into the ‘faulted’ state. All processes of the application were stopped, and restart was only
possible after all faults were cleared.

But what if you do not want to stop your application for every fault?
What if you could have some kind of hierarchy in the alarms of your application?

The premium application got you covered.

A dedicated alarm handling module (FB - MM Alarm Handling) now takes care of processing different
alarm types for the equipment and machine modules of the application. For the premium application,
3 different alarm types have been implemented - faults, warnings and information messages.

• Faults
o have priority 1
o interrupt the application (= state handler goes into ‘faulted’ state)
o should be followed by immediate action from the operator
o are indicated by a red blinking triangle around the alarm icon of the alarm screen
button

Example of a pump fault.

• Warnings
o have priority 2
o do not interrupt the application immediately but could cause production failure further
down the line if the operator does not take notice
o do not affect the state handler
o are indicated by a yellow blinking triangle around the alarm icon of the alarm screen
button

Example of a high temperature warning.

PLCSKILLTREE.COM

Email: [email protected]

Web: www.plcskilltree.com REFILL PREMIUM APPLICATION GUIDE V1.0 | 29


• Information messages
o have a low priority
o do not interfere with any process (e.g., production or draining)
o are for information only

Example of a user administration information message.

Each machine/equipment module outputs these 3 alarm types in 3 networks using a summary
variable (Module.Flt.iSummary). Faults are summarized using the .%X0 bit of the Flt.iSummary
variable, warnings are summarized using the .%X1 bit, and information messages are summarized
using the .%X2 bit. You can find these summary networks by looking for the network titles ”SUMMARY
- Module Fault/Warning/Information”.

Three networks are used in each module to summarize faults, warnings, and information messages.

The advantage of addressing the Flt.iSummary variable bitwise (instead of just creating a
Flt.xFault/xWarning/xInformation) is that you are flexible and can configure up to 16 different alarm
types (.%X0 to .%X15) which you can define without any constrains = No need to change the module
UDT structure if you’d like to implement more/less alarm types.

Example from my own projects: I typically work with servo application where
there’s a difference between faults that cause a normal cyclic stop of the line, and
faults that execute a quick stop of the line (= all servo’s need to be stopped as
quickly as possible e.g., after Estop). This can be easily configured with the above
structure by using iSummary.%X0 for quick stop faults (priority 1), iSummary.%X1
for normal stop faults (priority 2), iSummary.%X2 for warnings (priority 3), and
iSummary.%X3 for information messages.

PLCSKILLTREE.COM

Email: [email protected]

Web: www.plcskilltree.com REFILL PREMIUM APPLICATION GUIDE V1.0 | 30


The alarm handling module ’FB - MM Alarm Handling’ has 3 main functions:

1. Reset any faults, warnings, information messages


2. Process all summary variables from each module
3. Display alarm type status on the HMI

FB - MM Alarm Handling.

TIP - You cannot show alarm texts in alphabetically order under ‘HMI alarms’. But
what you can do, is display IDs in ascending or descending order. Make it a habit to
incorporate a number system for alarms in your projects. Use the ‘ID’ tab for this.
The ID is also displayed on the HMI. You might have a customer who writes you
about a fault on the HMI in a foreign language - so you don’t understand the fault.
Simply ask that customer for the ID number. This number is always unique and the
same for the English version of the alarm text = easier troubleshooting.

PLCSKILLTREE.COM

Email: [email protected]

Web: www.plcskilltree.com REFILL PREMIUM APPLICATION GUIDE V1.0 | 31


IMPLEMENTATION
Are you ready to upgrade your application with multiple alarm types? Just follow these 4 steps below,
and you’ll have it up and running in no time.

1. Define which types of alarms your application needs.

Before you start programming, you should think about which alarm structure makes sense for
your application. In my experience, faults, warnings, and informational messages are a very
good basis to start with and this structure can be used for most applications out there. So
start with this if you are in doubt.

2. Add a summary variable to your module UDT structure.

In your module UDT structure, add a new integer variable for summarizing the different alarm
types in your module block. In the premium sample application, I have added an iSummary
variable the .Flt structure of each module.

3. Summarize your different alarm types in each module block.

For each module, create some new networks where you summarize the different alarm types.
In doubt, go and check how it’s done in the premium application.

PLCSKILLTREE.COM

Email: [email protected]

Web: www.plcskilltree.com REFILL PREMIUM APPLICATION GUIDE V1.0 | 32


4. Integrate the alarm handling module from the sample application.

Copy the alarm handling data structure ‘UDT_MM_Alarm_Handling’


(PLC data types -> 00 Machine)

Copy the alarm handling block ‘FB - MM Alarm Handling’


(Program blocks -> 00 Machine -> Modules)

Why not take on an extra challenge and create the alarm handling module from
scratch!

Call your alarm handling block in your main machine module block.

In your alarm handling block, summarize the different alarm types for your modules.

Are you having difficulties with these steps? Write me!

PLCSKILLTREE.COM

Email: [email protected]

Web: www.plcskilltree.com REFILL PREMIUM APPLICATION GUIDE V1.0 | 33


5.3 RECIPE HANDLING

The premium application comes with the following new recipe handling features:

• Custom buttons for saving, loading, creating new, renaming, and deleting a data record
• Backup and recovering recipes by using a USB dongle
• Saving the data record ‘last save date and time’ in the recipe and visualizing it on the HMI
• Remotely loading a data record using a PLC command
• Dedicated warnings on the alarm screen for when saving/loading a data record fails

CUSTOM BUTTONS
So why use custom buttons for Load, Save, New, Rename and Delete? You could just use the build-in
buttons of the recipe view object, right (as we did in the standard sample application)? YES you can,
that’s why they are there. But you’ll miss out on some awesome advanced functionality which is only
possible by creating your own custom buttons.

The first thing you can do with custom buttons, is configure a specific Security level for each recipe
button. Let’s assume for example that operators only should have clearance to load data records
where saving, creating new, renaming, or deleting actions are only allowed by administrators.

Custom buttons allow for individual Security settings.

With custom buttons, you can set the Security level for the Load button to ’Operation’, and the Security
level for the Save, New, Rename and Delete buttons to ’Supervision’. This is not possible with the
build-in buttons of the recipe view object.

Furthermore, you can add specific functions and scripts to the press, release, or any other event of
the recipe buttons. In our sample application, we are using a combination of functions and scripts
(together with a recipe handling module in the PLC) to save the ‘last save date and time’ to the data
record, and to create warnings for when loading/saving a data record fails. This advanced
functionality is not possible with the build-in buttons.

PLCSKILLTREE.COM

Email: [email protected]

Web: www.plcskilltree.com REFILL PREMIUM APPLICATION GUIDE V1.0 | 34


Example: custom functions and scripts of the Press event of the ‘Save Data Record’ button.

BACKUP/RECOVERY
Backing up and recovering data records by using a USB dongle (typically inserted at the bottom of the
HMI panel) can be a powerful tool. Sometimes panels go broke (or SD cards go missing…) and taking
regular backups of the data records of the application should be a standard practice for a machine
operator. There are 2 dedicated buttons on the recipe screen for backing up and recovering data
records.

TIP - Do not save your data records to the flash memory of the HMI panel. Always
save on an external SD-card or on an external server. The problem with the flash
memory is that when your panel breaks down -> recipe and data records are gone.
In case of an SD-card, you install the new panel, move the SD-card from the
broken panel to the new panel, and you’re up and running again with your recipes.

In our premium application, pressing the backup button will backup all data records, and
pressing the recover button will recover all data records. In both cases overwriting existing
records are only possible after confirmation.

PLCSKILLTREE.COM

Email: [email protected]

Web: www.plcskilltree.com REFILL PREMIUM APPLICATION GUIDE V1.0 | 35


LAST SAVE DATE/TIME
Some applications out there make heavy use of recipes and data records, and knowing when a recipe
data record has been saved last (most likely due to changes) can be very valuable information when
troubleshooting an application. That’s why I’ve incorporated the ’last save date and time’ feature in the
recipe handling module.

With this feature, every time the operator saves a data record, the current date and time is saved
together with the other parameters. And every time the operator successfully loads a data record, this
saved date and time is displayed on the recipe screen of the HMI.

IMPORTANT - This feature is only possible by creating custom buttons for loading
and saving data records. If you would only use the build-in buttons of the recipe
view object, this feature could not be implemented. The reason being that this
feature uses custom functions and a VB script.

REMOTE DATA RECORD LOAD


If you are working with more complex applications where many separate machines can be part of a
bigger setup, then remotely loading data records can contribute to faster production switchovers (=
time between producing one type of product to producing another type).

• Example 1: 5 smaller stand-alone machines execute a process on a main production line (e.g.,
moving belt or chain). If the operator loads a new data record on the main line, the 5 stand-
alone machines automatically switch over to a new data record as well.
• Example 2: A turn-key line consists of an upstream machine, a main machine, and a
downstream machine - each with separate HMIs and recipe handling. If the operator loads a
new data record on the upstream machine, the main machine and downstream machine
automatically switch data records as well.

The premium application uses a command bit from the PLC "DB -
Machine".Recipe.Cmd.xRemote_Load together with a VB script ‘RECIPE_Remote_Change’ to enable
remote data record loading.

PLCSKILLTREE.COM

Email: [email protected]

Web: www.plcskilltree.com REFILL PREMIUM APPLICATION GUIDE V1.0 | 36


DEDICATED WARNINGS
Finally, I have created 2 warning texts for when saving or loading a data record fails. Sometimes the
SD-card might be missing or is locked for writing, or the connection to a server might be interrupted.
In this case informing the operator that loading or saving the recipe went wrong, is very valuable
information and can prevent a lot of downtime.

Recipe handling warnings.

NOTE -The default recipe view object does come with a standard message bar
that informs the operator when there is a problem with saving or loading a data
record, but in my experience, operators do not really notice this text here and
ignore it due to its location at the bottom of the recipe view object. I prefer to have
a dedicated warning on the alarm screen accompanied by a yellow warning
indicator on the screen (= yellow triangle in the premium application).

TIP – Every module in the premium application has an input ‘i_xFlt_Test’. By


setting this input to TRUE, all alarms of this module will be displayed on the HMI.
This is an easy tool to check if all alarms for that module have been created under
‘HMI alarms’ (HMI application) and if all alarms have been translated (in case of
multiple languages.

PLCSKILLTREE.COM

Email: [email protected]

Web: www.plcskilltree.com REFILL PREMIUM APPLICATION GUIDE V1.0 | 37


IMPLEMENTATION
Now for the fun part!

Copy the custom buttons for Load, Save, New, Rename, Delete new data records from the premium
sample application to your recipe screen.

To implement the ‘last save date and time’ feature, you will need the following 2 things:

1. the recipe handling module ’FB - MM Recipe Handling’ (don’t forget the UDT)
2. the VB script ’RECIPE_Get_DateTime’

You can either copy those over from the premium application, or you can try and create them yourself,
using the premium application as a reference (=best way to learn!). Afterwards, see which functions
and scripts are added to the Press and Release events of the Load and Save buttons and integrate
those in your own application.

To integrate backing up and recovering data records to/from a USB dongle in your own application,
copy both buttons from the recipe screen to your application.

• To export/import all data records, use the value ‘0’ in the function
• The file name includes the storage location as well (= you can change this)
• To prevent automatic overwrite of any existing data records, select the ‘After confirmation’
option

To add the remote data record loading feature, copy the VB script ‘RECIPE_Remote_Change’ and add
this script to the Change value of the "DB - Machine".Recipe.Cmd.xRemote_Load variable.

If you want to test the remote data record change feature, use the watch table ’Remote Recipe
Change’. Simply change the value of the ‘xxx.Cmd.iRemote_RecordNumber’ (1) to your desired data
record. Afterward set the ’xxx.Cmd.xRemote_Load’ (2) to TRUE and… pure magic.

PLCSKILLTREE.COM

Email: [email protected]

Web: www.plcskilltree.com REFILL PREMIUM APPLICATION GUIDE V1.0 | 38


Use the watch table ‘Remote Recipe Change’ to remotely load a new data record.

If you need a refresher on how to use Watch tables, go and check


out the section ‘Simulation & Testing’ of the TIA Portal - PLC
Programming Basis course.

To add the warnings for data record load/save failed to your application, make sure you have copied
the ‘FB - MM Recipe Handling’ block. Don’t forget to add the 2 warnings to the HMI alarms of your
HMI application.

5.4 USER ADMINISTRATION

In the standard refill sample application, you could log on with 3 types of users: operators, technicians,
and administrators. Could you tell from the HMI panel which user had logged on/off at which
date/time? No.

That changes now. The premium application logs every user that logs-on/off on the HMI panel. For
this purpose, I have programmed a user administration module ‘FB - MM User Admin’ which detects
each user change and uses that information to generate an information message on the alarm screen.

Because we have an alarm history screen in the application which saves all past alarms, those user
changes are logged over time. This can be very valuable information for troubleshooting an
application and keeping track of WHO operated the machine WHEN.

PLCSKILLTREE.COM

Email: [email protected]

Web: www.plcskilltree.com REFILL PREMIUM APPLICATION GUIDE V1.0 | 39


Examples:

• Which technician made changes to the PID temperature control of process tank 1 which caused
an unstable PID control 30 minutes ago?
• Which operator executed a draining process last Friday?

IMPLEMENTATION
Take these simple steps to create a history for your user logons:

• Copy the data type ‘UDT_MM_User_Admin’ to your application


(PLC data types -> 00 Machine)
• Copy the block ‘FB - MM User Admin’ to your application
(Program blocks -> 00 Machine -> Modules)
• Create the HMI alarm for user logged on

The Alarm text has an integrated tag (type string) which outputs the username depending on
which user is logged on (this tag is written to in ‘FB - MM User Admin’).

Finally, to log the different user changes in an alarm view window, add an alarm view to your
application and set it up as an ‘Alarm buffer’ (If you cannot remember how to add and configure one in
your application, go back and revisit section ‘Alarm Handling’ of the TIA Portal - HMI Basics course).

Alarm view configured as an ‘Alarm buffer’.

PLCSKILLTREE.COM

Email: [email protected]

Web: www.plcskilltree.com REFILL PREMIUM APPLICATION GUIDE V1.0 | 40


5.5 PLC STATUS AND CONTROL

A brand-new PLC machine module takes care of:

• Setting the PLC date and time from the HMI settings screen
• Displaying the PLC LED status on the HMI settings screen

Both new features are visualized on the HMI diagnostics screen.

SETTING PLC DATE AND TIME


Most clients I work with require for their machines that PLC date and time can be set from the HMI.
The alternative of manually setting the date and time via the TIA Portal software or directly on the
front panel of the PLC is more time-consuming and requires experience.

So how does it work...? Each of the 6 input fields on the HMI is configured with an ‘Input finished’
event that sets a command bit to TRUE in the data structure of the PLC machine module.

PLCSKILLTREE.COM

Email: [email protected]

Web: www.plcskilltree.com REFILL PREMIUM APPLICATION GUIDE V1.0 | 41


This command bit is then used in the PLC machine module ‘FB - MM PLC Control’ to set the time-of-
day in the PLC using the instruction ‘WR_SYS_T’. For more information on this instruction, search for
it in the Information system (Help -> Show help).

PLC LED STATUS


If you look at the front of a Siemens S7 PLC, then you’ll notice that are different LEDs (e.g., Stop, Run,
Fault, Network Status…). Typically, the PLC is installed in a closed cabinet, so unless you open the
cabinet door, you won’t be able to see/validate the LEDs. Well, there’s a solution for that. You can add
an ‘LED’ instruction to your PLC logic to read out the status of a particular module LED which you can
then display on the HMI. And that’s exactly what I’ve done in the PLC machine module.

You’ll need a hardware ID to tell the LED function which module you are reading the LED status from.
For the PLC module, the hardware ID is assigned to the system constant tag “Local~Common”.

TIP - System constants like hardware identifiers can be found in the


‘Default tag table’ (PLC tags) under the ‘System constants’ tab = no need
to search for those values in the hardware configuration (=time-
consuming).

PLCSKILLTREE.COM

Email: [email protected]

Web: www.plcskilltree.com REFILL PREMIUM APPLICATION GUIDE V1.0 | 42


IMPLEMENTATION
Here’s how you add the features ‘Setting PLC date/time’ and ‘Displaying PLC LED status’ to your own
application:

1. Copy the block ‘FB - MM PLC Control’ (don’t forget the UDT_MM_PLC_Control)
2. Copy the PLC Status area from the HMI screen ’07 Diagnostics’

Remember to setup your HMI as a time slave to the PLC to avoid incorrect timestamps of alarm
events. This is explained in more detail in the TIA Portal - HMI Basics course, so go check that out if
you’re in doubt.

5.6 NETWORK STATUS

If you go and check out the hardware configuration of the premium sample application, you’ll notice
that it contains multiple IO device nodes (the standard sample application has none).

When working with larger applications, you’ll most likely have to deal with nodes of different types on
your network - IO devices, frequency converters, other PLCs, 3rd party device like vision systems,
robots, heating controllers… just to name a few. Knowing the status of those network nodes can be
invaluable for troubleshooting and for checking the overall network health in runtime.

For this purpose, I have a added a dedicated Network machine module ‘FB - MM Network’ to the
premium application which includes logic to read out the status for each node, displaying that
information on the HMI, and generating warnings for when a specific node is offline.

PLCSKILLTREE.COM

Email: [email protected]

Web: www.plcskilltree.com REFILL PREMIUM APPLICATION GUIDE V1.0 | 43


IMPLEMENTATION
Are you ready to get more serious about your network status and the health of your nodes? Then
follow these simple steps.

1. Copy the network machine module ‘FB - MM Network’ from the Premium application
(don’t forget the UDT)
2. Define device numbers for all your network nodes in the hardware configuration

Open your hardware configuration, and in the ‘Network view’ click on the Profinet interface for
each node (green square). Go to the ‘Ethernet addresses’ tab and scroll down to the bottom to
configure your device number.

TIP - The PLC instruction ‘DeviceStates’ which is used to read out


network nodes works with device numbers, NOT with IP addresses.
What I normally do is that I use the last number of the IP address as the
device number. E.g., if the IP address is 192.168.1.30, I will assign the
number 30 to the device. By using this method, you will always know
the device number by looking at the IP address (and it is easier to find
the IP address for a node than to find the device number).

PLCSKILLTREE.COM

Email: [email protected]

Web: www.plcskilltree.com REFILL PREMIUM APPLICATION GUIDE V1.0 | 44


3. Adapt the alarms in the network machine module to your own device numbers

Open ‘FB - MM Network’, go to the networks where the alarms are being generated, and adapt
the alarms for your own application.

4. Copy the network status section from the Diagnostics screen

In the premium HMI application, open the diagnostics screen, copy the complete network
status section, and adapt it to your own application.

5. Adapt/add network alarms

Open the HMI alarms in the tree structure of the HMI application, and change/add network
alarm texts and trigger bits according to your own network configuration.

And that’s it!

5.7 HMI STATUS AND CONTROL

In TIA Portal, every HMI screen has a unique screen number which can be found by clicking
somewhere on the screen (make sure you are not clicking on an object) and going to the Properties.

The Overview screen has been configured as screen number 1.

PLCSKILLTREE.COM

Email: [email protected]

Web: www.plcskilltree.com REFILL PREMIUM APPLICATION GUIDE V1.0 | 45


This screen number can be sent to the PLC as status information, and it can also be commanded from
the PLC to force a screen change. This feature comes in real handy when you want to jump away
from a screen or jump to a specific screen if conditions in the PLC logic are met.

• One example could be that if no user is logged on anymore, you force the HMI (through a PLC
command) to jump to a neutral screen, like for example the process overview screen.
• Another example could be that your customer would like to have a log of which screens were
accessed during the last 24 hours of production. You could create a database (DB) where
each new entry contains the screen number and a timestamp when that screen number was
accessed.

IMPLEMENTATION
To implement the screen number status/command feature in your own application, follow these 3
easy steps:

1. Copy the machine module ’FB - MM HMI Control’ from the premium application (don’t forget
the data type ‘UDT_MM_HMI_Control’)
2. Add the tag for screen number command

Open up the Connections window in your HMI application.

Under ‘Area pointer’, configure a PLC tag (data type “Array[1..4] of Int”) for the ‘Job mailbox’
area pointer. The first array position (e.g. aiJobMailBox[1]) is used for the job type. For
screen selection, the job type is 51. The second array position (e.g. aiJobMailBox[2] is used
for the requested screen number.

For more information on this job mailbox area pointer, search


for “job mailbox area pointer” in the Information system (Help ->
‘Show help’).

PLCSKILLTREE.COM

Email: [email protected]

Web: www.plcskilltree.com REFILL PREMIUM APPLICATION GUIDE V1.0 | 46


3. Add the tag for screen number status

Open up the Connections window in your HMI application.

Under ‘Global area pointer of HMI device’, add a PLC tag (data type “Array[1..5] of Int”) to the
‘Screen number’ area pointer. The current screen number is stored in the second array
position e.g. “DB - Machine”.HMI.Sts.aiScreenNo[2].

For more information on this screen number area pointer,


search for “screen number area pointer” in the Information
system (Help -> ‘Show help’).

Want to try out the ‘Remote Screen Change’ feature for yourself?

• Open the Watch table ‘Remote Screen Change’


• Change the value of ‘xxx.Cmd.iScreenNo’ to your desired screen number
• Set ’xxx.Cmd.xChangeScreen’ to TRUE
• The variable ‘xxx.Sts.iScreenNo’ displays the current screen number

TIP – in the premium application, I have written the screen


number in the beginning of the name for each screen e.g. ’20
SETTINGS’. This way all screens are automatically listed with
screen numbers in ascending order.

PLCSKILLTREE.COM

Email: [email protected]

Web: www.plcskilltree.com REFILL PREMIUM APPLICATION GUIDE V1.0 | 47


UP FOR A CHALLENGE?
In the Premium application - the way the template buttons on the right are animated and the way the
correct screen name is being displayed on the top bar - is different than from the standard application.
Can you spot the differences?

PLCSKILLTREE.COM

Email: [email protected]

Web: www.plcskilltree.com REFILL PREMIUM APPLICATION GUIDE V1.0 | 48


6 SIMULATING/TESTING THE SAMPLE APPLICATION

Simulating a PLC or HMI device in TIA Portal is extremely straight forward using the S7-PLCSIM
software. It is described as well in detail in the PLC and HMI courses, but in case you need a reminder,
here is how it’s done.

SIMULATING THE PLC APPLICATION


1. Select the PLC device (PLC_Refill_Premium) in the tree structure on the left
2. Press the simulation icon (top bar)

3. Load the application

4. Start the application

PLCSKILLTREE.COM

Email: [email protected]

Web: www.plcskilltree.com REFILL PREMIUM APPLICATION GUIDE V1.0 | 49


SIMULATING THE HMI APPLICATION
1. Select the HMI device (HMI_Refill_Premium) in the tree structure on the left
2. Press the simulation icon (top bar)

After a short compilation, your simulated HMI application will appear in all its beauty.

TIP - After making bigger changes to an HMI application in TIA Portal, execute a
‘Compile -> Software (rebuild all)’ before downloading the application to a panel.
In my experience, TIA Portal can sometimes create unwanted artifacts, or
move/hide certain objects on the panel if you do not perform a complete software
rebuild before downloading.

SIMULATING THE INPUTS OF THE APPLICATION


(circuit breakers, local isolators, tank levels/temperatures...)

1. Open the Force table in your PLC application (Watch and force tables)

2. Go online by pressing the icon with the glasses and the play button (click somewhere in the
force table first, else the button will be greyed-out)

PLCSKILLTREE.COM

Email: [email protected]

Web: www.plcskilltree.com REFILL PREMIUM APPLICATION GUIDE V1.0 | 50


3. Add values to the ‘Force value’ tab for each input

4. Activate forcing by pressing the icon with the capital ‘F’ and the play button^

If you like a more detailed video explanation on how to go online with your application and how to use
the force table, go and revisit the PLC and HMI courses and watch the videos there (final chapters of
those courses).

Now you’re good to go, so start testing!

PLCSKILLTREE.COM

Email: [email protected]

Web: www.plcskilltree.com REFILL PREMIUM APPLICATION GUIDE V1.0 | 51


7 BEFORE YOU GO

I really hope you enjoyed this guide and that the instructions on how to use these new features in your
own applications were clear to you.

CONTACT ME
If you have any questions or recommendations regarding the premium sample application or this
guide, any questions regarding how to implement these features in your own applications? Don’t
hesitate, just write me an email ([email protected]) and I will reply. Your feedback is very
important and will help me to create a more complete software package and a better guide for you.

Just keep in mind, the quality of my answers dependent on the quality of your questions. Please be
detailed in your descriptions and send me screenshots if they help to clarify the questions.

SHARE YOUR STORY


Could I ask you for a small favour? If you liked this premium content and were able to use some of
the features and concepts in your own applications, please share your enthusiasm with your social
networks (e.g., LinkedIn, Facebook, Instagram), with your friends and colleagues, or whomever might
benefit from content like this (including a link to www.plcskilltree.com will help people find the content).
By sharing your story, other people can learn as well from this content and start creating more
structured PLC and HMI applications.

THANK YOU
Finally, I’d like to say a big THANK YOU for your trust in my products and courses. There’s always lots
of hours and late evenings involved in creating content like this. So if it actually helps you become a
better PLC programmer and deliver higher quality automation software to your clients, then it’s all
worth it. I am very grateful for this opportunity to share my experiences with you.

Until next time!


- Hans

PLCSKILLTREE.COM

Email: [email protected]

Web: www.plcskilltree.com REFILL PREMIUM APPLICATION GUIDE V1.0 | 52

You might also like