TIA Portal how to display running timer on HMI

0

TIA Portal how to display running timer on HMI

 

In this tutorial we’ll be looking at displaying a running timer on HMI in a proper format. To do that we’ll convert LTime (which is the timers current value) to a number of strings (hours, minutes, seconds, etc) and combine them in to a single string to be displayed on the HMI.

1. Set up a timer that will be displayed on the HMI in TIA Portal

TIA Portal Timer
TIA Portal Timer

I’ve created an FB in which I’ve inserted my Timer, thus I can use a multi-instance DB type. I’ve also declared other tags as Local Statics.

Because I want to display durations longer than 24 days I’ve switched Timer data type from Time (T#-24d_20h_31m_23s_648ms to T#+24d_20h_31m_23s_647ms) to LTime (LT#-106751d_23h_47m_16s_854ms_775us_808ns to LT#+106751d_23h_47m_16s_854ms_775us_807ns).

2. Create FC for converting LTime to String in TIA Portal

In this FC we take out days, hours, minutes, seconds and miliseconds out of LTime. Convert them separately to Strings and then combine them with all together placing separators in between.

I’ve skipped the nanoseconds and microseconds as we would not be able to note their change on the HMI anyway, due to connection delays, human eye response time, screen refresh rate, etc.

TIA Portal Conversion FC
TIA Portal Conversion FC

You can either download the block from our DOWNLOAD SECTION or Copy-Paste the code from here:

And don’t forget to define Local Variables:

TIA Portal FB Local Variables
TIA Portal FB Local Variables

3. Call the conversion FCwithin PLC software in TIA Portal

TIA Portal Conversion FC Call
TIA Portal Conversion FC Call

Call the conversion Function that will enable us to display timer on HMI.

4. Insert Timer on HMI’s screen in TIA Portal

Drag&Drop I/O Field on to the screen:

TIA Portal IO Field
TIA Portal IO Field

Configure I/O Field:

Highlight the I/O Field and go to: Properties » General » Display Format and choose ‘String’ from the drop-down menu. Change the field length to at least ’22’ to accommodate the long string we’ve created. Change the mode to: ‘Output’ and most importantly point to the correct tag in the PLC:

TIA Portal IO Field Timer
TIA Portal IO Field Timer

 

 

 

64 Shares