TIA Portal How To Open Pop-up screen with PLC Tag

in #tiaportal7 years ago

TIA Portal How To Open Pop-up screen with PLC Tag


Pop-up screens are definitely one of the more useful features in TIA Portal WinCC, altough ideally their appearance on operator's HMI should be PLC event driven. It's easy to imagine a situation when an event or a state change triggers a pop-up with an information/warning about that event. Unfortunately 'ShowPopupScreen' and 'ShowPopupScreenSizable' ('ShowPopupScreenSizable' - V14 only) functions can only be driven by an event inside HMI (like pressing a button, switching a switch, etc). There is however a way around it with the help of a VB script, which I will describe in this tutorial.

In this tutorial you're going to learn:

  • How to create a pop up screen in TIA Portal
  • How to configure a tag in TIA Portal
  • How to write a VB Script in TIA Portal
  • How to activate clock memory bits in TIA Portal
  • How to call VB Script in TIA Portal

1. Create a Pop-up screen on HMI in TIA Portal

Let's start by creating a pop-up screen:

 

TIA Portal How To Pop-up create screen TIA Portal How To Pop-up create screen

2. Create a Tag within the PLC in TIA Portal

This is the tag that will be set HIGH by the event that will trigger the pop-up screen appearance. It doesn't matter where this tag is stored (DB, Global Memory, etc) as long as it's accessible from the HMI.

3. Create a Tag within the HMI in TIA Portal

Create a Tag in the HMI and connect it with the tag created in p. 2:

TIA Portal How To Pop-up Tag TIA Portal How To Pop-up Tag

 

4. Set the acquisition cycle to 'cyclic continuous' for HMI tag in TIA Portal


In HMI's tag table highlight the tag you've just created, go to 'Properties' tab -> 'Settings' -> 'Acquisition mode' and choose 'cyclic continuous' from the drop-down menu:

TIA Portal How To Pop-up tag settings TIA Portal How To Pop-up tag settings

WHY?

TIA Portal Help:

If you want to update the tag at regular intervals as long as it is being displayed on the screen or logged, select "Cyclic in operation" as the acquisition mode.

Or:

If you want to update the tag at regular intervals even though it is not being displayed on the screen or logged, select "Cyclic continuous" as the acquisition mode.

The "Cyclic continuous" setting is selected for a tag, for example, that has a function list configured for a change of its value and that is not directly visible in a screen.

Our tag will not be used on the screen or logged therefore HMI would never query the PLC for the state of the tag if 'Cyclic in operation' was chosen.

5. Write VB Script in TIA Portal

This will show the pop-up when the tag changes it's state to high. Start by creating a new VB Script:

TIA Portal How To Pop-up VB TIA Portal How To Pop-up VB

Insert the following code:
If SmartTags("TIAPortalHowTo_tag_1") Then
ShowPopupScreen "TIA_Portal_How_To", 0, 0, hmiOn,hmiAnimationOff, hmiMedium
ElseIf Not SmartTags("TIAPortalHowTo_tag_1") Then
ShowPopupScreen "TIA_Portal_How_To", 8, 84, hmiOff,hmiAnimationOff, hmiMedium
End If
 
  • SmartTags("TIAPortalHowTo_tag_1") - > is your tag. You can type it in or drag it in from tags table by 'splitting editor space'.
  • 'TIA_Portal_How_To' -> is the name of your pop-up screen
  • '0' and '0' are X and Y coordinates (top left corner of pop-up screen) of where the screen will appear
  • 'hmiAnimationOff' or 'hmiAnimationTop' or 'hmiAnimationLeft' or 'hmiAnimationRight' or 'hmiAnimationBottom' -> turn on or off the animation of appearance
  • 'hmiMedium' or 'hmiSlow' or 'hmiFast' -> animation speed
TIA Portal How To Pop-up VB Script TIA Portal How To Pop-up VB Script

6. Activate 1Hz clock memory bit in PLC settings in TIA Portal

First we need to enable the use of 'Clock memory Byte' in the PLC. To do so go to:

PLC Properties tab -> System and clock memory -> tick 'Enable the use of clock memory byte' box

TIA Portal How To memory clock byte TIA Portal How To memory clock byte

Now let's create a Tag in the HMI and point it to 'Clock_1Hz' (%M0.5) memory bit in the PLC, and set it's acquisition mode to 'Cyclic continuous'.

The hertz (symbol Hz) is the unit of frequency in the International System of Units (SI) and is defined as one cycle per second.
Source: Wikipedia: Hertz

One cycle per second means 'Clock_1Hz' memory bit will be high for 0.5s and than low for 0.5s and then cycle repeats.

You can find more information on the subject of Memory Clock Byte in article: TIA Portal Clock Memory and System Memory

Therefore we need to change the acquisition cycle time for something else than 1s, otherwise HMI would never notice the change of memory bit's state. We'll use 500ms (0.5s):

TIA Portal How To memory clock bit TIA Portal How To memory clock bit

You can select other frequency memory bit if you wish, just remember to adjust the acquisition cycle time accordingly.

7. Call VB Script on HMI in TIA Portal


VB script needs to be called 'continuously' so we will configure 1Hz HMI tag to "call" our Vb script on value change. Click on the 'Events' tab while having 1Hz tag highlighted and select, previously created, VB script:

TIA Portal How To vb script call TIA Portal How To vb script call

That's it! When the 'tag_1' goes HIGH (logic state 1) in the PLC - Pop-up screen 'TIA_Portal_How_To' will be displayed on HMI and removed when the tag goes LOW (logic state 0).

TIP1! If it went through your mind to trigger the 'ShowPopupScreen' function on event: value change of HMI's 'Tag_1' (and by doing so not use the VB Script at all) consider this scenario:

There is a fault on the HMI (let's say power loss), but the PLC stays operational and the tag_1 (in the PLC) goes HIGH, while the HMI is off. HMI is restarted. At this point our operation is inverted - Pop-up is displayed when the tag_1 is LOW and is not displayed when tag_1 is HIGH. It's because the only available event for HMI tags is 'Value Change'. It doesn't distinguish between going HIGH or going LOW.

TIP2! If you're simulating this project on you PC make sure to have the TIA Portal window and HMI simulator window side by side, otherwise the pop-up window might remain hidden:

TIA Portal How To pop-up simulation TIA Portal How To pop-up simulation