Blog

How to Make a Dynamically Linking Faceplate in Siemens' TIA Portal

How to Make a Dynamically Linking Faceplate in Siemens' TIA Portal

Thanks to TIA Portals development environment, laying out and linking a few objects on an HMI screen doesn’t take very much time. Though, this process starts to become tedious when there are many objects with many individual tag connections for visibility, location, and process values.

Organizing HMI objects into faceplates simplifies and organizes the process but doesn’t help reduce the amount of PLC side logic or tag connections needed, for complex animations. This situation led me to use one of TIA Portal’s most powerful features, scripts, to take faceplates one step further and create a faceplate that can dynamically relink tags to HMI objects.

Why Faceplates?

First, allow me to describe the situation that led to the need for a completely dynamic faceplate. A client gave DMC a project that needed an HMI interface that allowed operators to add, remove and edit steps in a user-defined sequence. Each step in the sequence had a type and several Boolean, integer, and floating-point values that the operator alters to change setpoints for that step. Because only some of the settings were used in each step type, and there were a lot of settings, we decided that it would be simplest if the HMI displayed only the parameters relevant to the selected step type.

The solution was to create a faceplate that interpreted a step’s mode dynamically, thus reducing the need for PLC side logic and linking countless individual tags to the ten steps we displayed on the screen.

HMI Structure

At a high level, think of the dynamic faceplate as a junction box that connects the HMI objects to different PLC tags, depending on the step type. The faceplate contains 21 objects, seven switches, seven drop-down menus, and seven IO fields, that are all linked to tags internal to the faceplate. The faceplate also has 15 interface connections, four Boolean, three Integer and eight Real, that can connect to PLC tags.

When the faceplate receives a new mode, it pulls the values from the PLC tags and places those values in the corresponding HMI objects. When the value in an HMI object is changed, the faceplate pushes that value to the PLC’s corresponding tag.

TIA portal faceplates

The step type is a 32bit integer (it uses the lower 28 bits) that the faceplate interprets as seven, four bit, nibs. Each nib contains a number from 0-15 that corresponds to either a blank space or one of the 15 interface connections.

So, for each zero the face plate receives it will display a blank space, and each number greater than zero it will display an HMI object corresponding that interface’s data type, IO fields for reals, dropdowns for integers, and switches for Booleans.

The abbreviated code snippet below controls the visibility of the screen objects and passes the data from the screen object to the conection tag.

Sub SortField7()

Dim place 
place = SmartTags("diPlace8")
Dim bVBSwitch, bSwitch, bVBTitle, sTitle
Dim bVBDropDown, iDropDown, bVBIOField, rIOField

Select Case place: ' Switch1, DropDown1, IOField1
	Case 1:	'Bool 1
		bVBSwitch = 1 								'Show Switch 1
		bSwitch = SmartTags("Properties\bBool1")		'Move Switch 1 to Bool 1
		bVBTitle = 1									'Show Title 1
		sTitle = SmartTags("Properties\sBoolTitle1")	'Move Bool Title 1 to Title 1
		
	Case 2: 'Bool 2
		bVBSwitch = 1 
		bSwitch = SmartTags("Properties\bBool2") 		'Move Switch 1 to Bool 2
		bVBTitle = 1									'Show Title 1
		sTitle = SmartTags("Properties\sBoolTitle2")	'Move Bool Title 2 to Title 1
		
	'case3-4 Bool
		
	Case 5: 'Int 1
		bVBDropDown = 1
		iDropDown = SmartTags("Properties\iInt1")			' Move DrowDown 1 to Int 1
		bVBTitle = 1										'Show Title 1
		sTitle = SmartTags("Properties\sDropDownTitle1")	'Move Int Title 1 to Title 1
		
	'case6-7 Int
		
	Case 8: 'Real 1
		bVBIOField = 1
		rIOField =  SmartTags("Properties\rReal1")		' Move IOField 1 to Real 1
		bVBTitle = 1										'Show Title 1
		sTitle = SmartTags("Properties\sIOFieldTitle1")	'Move Real Title 1 to Title 1
		
	'case9-11 Real

End Select

SmartTags("bVBSwitch7") = CBool(bVBSwitch)
SmartTags("bSwitch7") = CBool(bSwitch)
SmartTags("bVBDropDown7") = CBool(bVBDropDown)
SmartTags("iDropDown7") = CInt(iDropDown)
SmartTags("bVBIOField7") = CBool(bVBIOField)
SmartTags("rIOfield7") = CDbl(rIOField)
SmartTags("bVBTitle7") = CBool(bVBTitle)
SmartTags("sTitle7") = CStr(sTitle)

End Sub

Visual Basic Scripts

The faceplate uses two event-driven Visual Basic scripts. The first script, shown above, runs when the current step type changes and the second script runs when any of the HMI objects values' change. It’s important to note that the drop-down used to store the step type must be tied to a tag in the faceplate, not the interface tag tied to the PLC’s tag. If it’s tied to an interface tag, and the Visual Basic script uses the interface tag, then when a change event runs the script, the connection tag will have the old value from before the change.

The key is to tie the HMI object’s Process Value to an interface tag for connection to the PLC as well as to a tag in the faceplate for uses in the faceplate.

plc to hmi objects in tia portal

As mentioned, the first Visual Basic script runs when the step types' tag changes. It masks and shifts each nib to the left giving seven location modes each ranging from 0 to 15. Each location value is then passed into a switch case structure that hides the unused HMI objects, shows the used object (assuming there is one) and moves the current interface value into the HMI object’s process value.

The second Visual Basic script, run when any of the HMI objects’ tags change, move the HMI objects’ process values into the interface tags, updating the PLC tags.

Uses

Because each of the seven locations on the HMI can be linked to any one of 15 different tags or left blank, there are a lot of possible modes, 268,435,456 in fact. Finding the desired modes and copying those into a project is not a trivial task.

To simplify the process, I generated a spreadsheet, seen below, that can convert layouts into and back from step type numbers. To create a list of step types you have to fill in each row with the tags you want to appear on the HMI, and then copy the list of types and names into an HMI text list.

tags

Conclusion

This dynamic faceplate demonstrates how using Visual Basic scripts within faceplates can further increase faceplates versatility and capability, reducing project-specific complexity and needed PLC logic. With this tutorial, you should have all the ideas and information you need to make your own dynamically linked faceplate for specific or general applications speeding up complex HMI development.

Contact DMC for more information on our Siemens TIA Portal Expertise.

Learn more about our HMI & SCADA Services.

Comments

There are currently no comments, be the first to post one.

Post a comment

Name (required)

Email (required)

CAPTCHA image
Enter the code shown above:

Related Blog Posts