Refill_Premium_Guide
Refill_Premium_Guide
PLCSKILLTREE.COM
Email: [email protected]
PLCSKILLTREE.COM
Email: [email protected]
1.1 VERSIONS
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)
PLCSKILLTREE.COM
Email: [email protected]
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]
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.
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!
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]
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.
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]
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.
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]
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.
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]
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.
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.
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]
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.
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.
PLCSKILLTREE.COM
Email: [email protected]
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.
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’.
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]
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).
In the configuration block ‘FC - MM Config’, values are assigned to configuration variables of machine
modules.
PLCSKILLTREE.COM
Email: [email protected]
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.
PLCSKILLTREE.COM
Email: [email protected]
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
PLCSKILLTREE.COM
Email: [email protected]
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]
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.
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.
PLCSKILLTREE.COM
Email: [email protected]
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).
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]
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]
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
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]
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]
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]
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.
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.
Define a Layer for trend views and add as many trend views as you have PID processes.
PLCSKILLTREE.COM
Email: [email protected]
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.
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]
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]
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!
Each refill process tank has been upgraded with a stirrer and a drain valve.
PLCSKILLTREE.COM
Email: [email protected]
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.
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]
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]
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]
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?
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
• 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
PLCSKILLTREE.COM
Email: [email protected]
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]
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]
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.
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.
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]
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.
PLCSKILLTREE.COM
Email: [email protected]
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.
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]
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]
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.
• 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]
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).
PLCSKILLTREE.COM
Email: [email protected]
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]
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.
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]
• 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:
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).
PLCSKILLTREE.COM
Email: [email protected]
• Setting the PLC date and time from the HMI settings screen
• Displaying the PLC LED status on the HMI settings screen
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]
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”.
PLCSKILLTREE.COM
Email: [email protected]
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.
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]
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.
PLCSKILLTREE.COM
Email: [email protected]
Open ‘FB - MM Network’, go to the networks where the alarms are being generated, and adapt
the alarms for your own application.
In the premium HMI application, open the diagnostics screen, copy the complete network
status section, and adapt it to your own application.
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.
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.
PLCSKILLTREE.COM
Email: [email protected]
• 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
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.
PLCSKILLTREE.COM
Email: [email protected]
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].
Want to try out the ‘Remote Screen Change’ feature for yourself?
PLCSKILLTREE.COM
Email: [email protected]
PLCSKILLTREE.COM
Email: [email protected]
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.
PLCSKILLTREE.COM
Email: [email protected]
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.
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]
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).
PLCSKILLTREE.COM
Email: [email protected]
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.
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.
PLCSKILLTREE.COM
Email: [email protected]