WinCC dynamic table help

M4ndarr

Member
Join Date
Dec 2014
Location
Brno
Posts
9
Hello gurus,
i have a big problem with WinCC. What do i need?

I need to create, dynamic table for all valves and motors in system.
It will be better explain it on the picture.

T3k8.png


I did this table inIntouch. But i havent any experiences to do same in the WinCC.
I have one function, which returns me number of byte of item in DB.
First, it cannot be static.
In Intouch it works like this.
Code:
     MTTable_ItemAnalog.Name = "MTTable" + RowIndicator + "0";
MTTable_ItemAnalog.Reference = AccessName + ",W" + Text(index + 18, "#");
I have 10 tags for one row. MTTable010-MTTable019. After i rename help tag and change reference.
After I use two FOR loops for re-reference all table.
Can i do something simillar in the WinCC??

Another question, can you explain me what are the smarttags please?

Thank you for any help, it is for my thesis
 
I think what you need is indirect tag addressing. You can set the DB, Byte address and also Bit address of a tag to be other tags (usually internal tags). You can then use scripting to calculate values for these tags.

The attached picture shows a picture of a screen controlling 20 individual production lines; all of the tags providing the data are indirectly addressed and change based on the line number selected. Any time the Line number changes a script executes to re-calculate all the pointers to the tags of that line.

Extract of the script that calculates pointers and uses the SmartTags feature:

Code:
'NOTE: To start scripting please press <Ctrl><Space> and see the wide variety of functions.
'Write scripts by using system functions or the WinCC flexible object model. You can easily access to the
'system through the HMI runtime object. For a convenient picking of an object reference
'you can press <Alt><Right Arrow>. Design complex scripts by employing the basic features
'of the programming language VBScript and access tags directly by name e.g. tag = 5.
Dim LineNo
Dim Sizeof_Recipe			'Size of the Recipe UDT
Dim Sizeof_HydData			'Size of Hydraulic Data UDT
Dim Sizeof_RecipeMan		'Size of Recipe Manager UDT
Dim Offset_To_X_State		'Offset from the start of the UDT to the X State
Dim Offset_To_Y_State		'Offset from the start of the UDT to the Y State
Dim Offset_To_1stDES		'Offset from the start of the DB to the 1st Descaler State
Dim Offset_To_1stTT			'Offset from the start of the DB to the 1st TTable State
Dim Offset_To_1stVTUCAP		'Offset from the start of the DB to the 1st VTU Capstan State
Dim Offset_To_1stDES_DB		'Offset to the first Descaler Drive DB
Dim Offset_To_1stTT_DB		'Offset to the first Turntable Drive DB
Dim Offset_To_1stVTUCAP_DB	'Offset to the first VTU Capstan Drive DB


'Set Offsets
Offset_To_X_State = 16
Offset_To_Y_State = 18
Offset_To_1stDES = 0
Offset_To_1stTT = 80
Offset_To_1stVTUCAP = 40
Offset_To_1stDES_DB = 540
Offset_To_1stTT_DB = 520
Offset_To_1stVTUCAP_DB = 500


'Find UDT Sizes
LineNo = SmartTags("iLineNumber") 'Set Line Number
HmiRuntime.Trace "Line Number = " & LineNo
Sizeof_Recipe = SmartTags("dbCalibration.iSizeof_Recipe") 'Size of Recipe
HmiRuntime.Trace "SizeOf recipe = " & Sizeof_Recipe
Sizeof_HydData = SmartTags("dbCalibration.iSizeof_HydData") 'Size of Hydraulic Data
HmiRuntime.Trace "SizeOf Hydraulics = " & Sizeof_HydData
Sizeof_RecipeMan = SmartTags("dbCalibration.iSizeof_RecipeMan") 'Size of Recipe Manager 
HmiRuntime.Trace "SizeOf recipe Manager = " & Sizeof_RecipeMan

'Calculate Pointers to States
X_State_Pointer = ((LineNo -1) * Sizeof_HydData) + Offset_To_X_State
Y_State_Pointer = ((LineNo -1) * Sizeof_HydData) + Offset_To_Y_State
DES_State_Pointer = ((LineNo -1) * 2) + Offset_To_1stDES
TT_State_Pointer = ((LineNo -1) * 2) + Offset_To_1stTT
VTUCAP_State_Pointer = ((LineNo -1) * 2) + Offset_To_1stVTUCAP

'Calculate Drive DB Numbers
DES_DriveDB = Offset_To_1stDES_DB + (LineNo -1)
TT_DriveDB = Offset_To_1stTT_DB + (LineNo -1)
VTUCAP_DriveDB = Offset_To_1stVTUCAP_DB + (LineNo -1)


'Return results to tags
SmartTags("iState_DES_Pointer") = DES_State_Pointer
HmiRuntime.Trace "Descaler State pointer = " & DES_State_Pointer
SmartTags("iState_TT_Pointer") = TT_State_Pointer
HmiRuntime.Trace "TT State pointer = " & TT_State_Pointer
SmartTags("iState_VTUCAP_Pointer") = VTUCAP_State_Pointer
HmiRuntime.Trace "VTUCAP State pointer = " & VTUCAP_State_Pointer
SmartTags("iState_X_Pointer") = X_State_Pointer
HmiRuntime.Trace "X State pointer = " & X_State_Pointer
SmartTags("iState_Y_Pointer") = Y_State_Pointer
HmiRuntime.Trace "Y State pointer = " & Y_State_Pointer
SmartTags("iDriveDB_DES") = DES_DriveDB
HmiRuntime.Trace "Drive DB DES = " & DES_DriveDB
SmartTags("iDriveDB_TT") = TT_DriveDB
HmiRuntime.Trace "Drive DB TT = " & TT_DriveDB
SmartTags("iDriveDB_VTUCAP") = VTUCAP_DriveDB
HmiRuntime.Trace "Drive DB VTUCAP = " & VTUCAP_DriveDB

SmartTags("iTakeup_Byte") = TakeUp_Byte
HmiRuntime.Trace "Take Up Byte = " & TakeUp_Byte
SmartTags("iTakeup_Bit") = TakeUp_Bit
HmiRuntime.Trace "Take Up Bit = " & TakeUp_Bit
SmartTags("iVTUMaster_Byte") = VTU_Master_Byte
HmiRuntime.Trace "VTU Master Byte = " & VTU_Master_Byte
SmartTags("iVTUMaster_Bit") = VTU_Master_Bit
HmiRuntime.Trace "VTU Master Bit = " & VTU_Master_Bit

SmartTags("iSpeedPointer") = SpeedPointer
HmiRuntime.Trace "Speed Pointer = " & SpeedPointer

I hope this helps,

Nick

LineXX_Motors.jpg
 
Thank you so much,
i already wrote this code, i think it same.

Code:
'Dim DB_offset , TagName  
CM_Popup_Reset
Dim pomoc_D_V


' Reading Tag name
'	TagName = HmiRuntime.ActiveScreen.ActiveScreenItem.TextOff

	SmartTags("CM_TagName")= TagName 
' Setting DB offset for pop up screen
If DB = 10 Then
	SmartTags("CM_DB") = 2
	pomoc_D_V = "CM_DD_Vlv"
Else
	SmartTags("CM_DB") = 3
	pomoc_D_V = "CM_DD_Mtr"
End If

'DB value
	'SmartTags("CM_DB") = DB
'Return value 
	SmartTags("CM_STATUS_Index") = ((CMDB_OffsetID (SmartTags("CM_TagName"), pomoc_D_V)/20)*42)+2
'calculate pointer
'indMT\AL_CC.Reference = AccessName + ",X" + Text(index + 40.0,"#.#");
'indMT\AL_CC_OIL.Reference = AccessName + ",X" + Text(index + 40.3,"#.#");
'indMT\SET_OIL.Reference = AccessName + ",X" + Text(index + 40.2,"#.#");
'indMT\V_D.Reference = AccessName + ",X" + Text(index + 40.5,"#.#");
	SmartTags("CM_CMD_Index") = SmartTags("CM_STATUS_Index") + 40
'{Analog}
'indMT\D_OIL.Reference = AccessName + ",W" + Text(index + 26, "#");
	SmartTags("CM_Int_Index_01") = SmartTags("CM_STATUS_Index") + 26
'indMT\D_MT.Reference = AccessName + ",W" + Text(index + 24, "#");	
	SmartTags("CM_Int_Index_02") = SmartTags("CM_STATUS_Index") + 24
'indMT\C_OIL.Reference = AccessName + ",W" + Text(index + 22, "#");	
	SmartTags("CM_Int_Index_03") = SmartTags("CM_STATUS_Index") + 22
'indMT\C_MT.Reference = AccessName + ",W" + Text(index + 16, "#");	
	SmartTags("CM_Int_Index_04") = SmartTags("CM_STATUS_Index") + 16
'indMT\C_DATE.Reference = AccessName + ",W" + Text(index + 18, "#");			
	SmartTags("CM_Int_Index_05") = SmartTags("CM_STATUS_Index") + 18
'indMT\C_DATE_OIL.Reference = AccessName + ",W" + Text(index + 20, "#");	
	SmartTags("CM_Int_Index_06") = SmartTags("CM_STATUS_Index") + 20
'indMT\Year.Reference = AccessName + ",W" + Text(index + 28, "#");
	SmartTags("CM_Int_Index_07") = SmartTags("CM_STATUS_Index") + 28
'indMT\Month.Reference = AccessName + ",W" + Text(index + 30, "#");	
	SmartTags("CM_Int_Index_08") = SmartTags("CM_STATUS_Index") + 30
'indMT\Day.Reference = AccessName + ",W" + Text(index + 32, "#");	
	SmartTags("CM_Int_Index_09") = SmartTags("CM_STATUS_Index") + 32
'indMT\Year_OIL.Reference = AccessName + ",W" + Text(index + 34, "#");	
	SmartTags("CM_Int_Index_10") = SmartTags("CM_STATUS_Index") + 34
'indMT\Month_OIL.Reference = AccessName + ",W" + Text(index + 36, "#");	
	SmartTags("CM_Int_Index_11") = SmartTags("CM_STATUS_Index") + 36
'indMT\Day_OIL.Reference = AccessName + ",W" + Text(index + 38, "#");
	SmartTags("CM_Int_Index_12") = SmartTags("CM_STATUS_Index") + 38

'{Analog}	
'indMT\Last_NHT.Reference = AccessName + ",REAL" + Text(index, "#");
	SmartTags("CM_Real_Index_00") = SmartTags("CM_STATUS_Index")	
'indMT\Last_NHT_OIL.Reference = AccessName + ",REAL" + Text(index + 4, 
	SmartTags("CM_Real_Index_01") = SmartTags("CM_STATUS_Index") + 4
'indMT\LIM_MT.Reference = AccessName + ",REAL" + Text(index + 8, "#");	
	SmartTags("CM_Real_Index_02") = SmartTags("CM_STATUS_Index") + 8
'indMT\LIM_OIL.Reference = AccessName + ",REAL" + Text(index + 12, "#");	
	SmartTags("CM_Real_Index_03") = SmartTags("CM_STATUS_Index") + 12
...
Wmgo.png


My idea...
Now i need create a table, for example 20 rows * 10 collums.
First row, the tags will be
MTTable000, first two number will be row, third number will be colum.

in Tags table:
Name Adress
MTTable000 DB [NUMBER] DBW [INDEX0]
....
MTTable009 DB [NUMBER] DBW [INDEX9]

next row
MTTable010 DB [NUMBER] DBW [INDEX0]
....
MTTable019 DB [NUMBER] DBW [INDEX9]

Question: Do i need to create tag INDEX0-9(INDEX000) for each row in this dynamic table?
Because when i calculate pointer for first row, for example 20
INDEX0 will be 40
INDEX1 will be 42 ....
When i get information for second row, i will get, for example 80
INDEX0 will be 160
INDEX1 will be 162 ....
I rewrite everything in frist row... I think

Do you have any idea how to do it? Tell if it is understandable.
Or can I use Array for this. I dont know how much can i do in WinCC, i just intall this program last friday and i have never seen it before
And after when you click on the first colum, i have to open popup of the element, and when i click on check, i have reset alarm and to a few operations.
It cannot be just read table
 
Last edited:
I dont know how much can i do in WinCC, i just intall this program last friday and i have never seen it before

You're doing far better than many people who have used it for years!


Question: Do i need to create tag INDEX0-9(INDEX000) for each row in this dynamic table?
Because when i calculate pointer for first row, for example 20
INDEX0 will be 40
INDEX1 will be 42 ....
When i get information for second row, i will get, for example 80
INDEX0 will be 160
INDEX1 will be 162 ....
I rewrite everything in frist row... I think

It cannot be just read table

If I understand correctly then yes, you need to identify each tag to be be displayed simultaneously. Only the items being displayed (in use) need to have valid pointers.

A great deal also depends on the structure of your data in the PLC. You might be able to create a Faceplate for each row and pass a structure tag to it (not sure whether you can indirectly address a structure tag).

Nick
 
I got it.
I will create just 4 buttons and 4 TextField
EveryButton will have a click event, the script and parametrs will be (Row and number button) When i click on the button i will refresh the whole row. Get the DB_offset and rewrite one row.

to text field i can entrance
HmiRuntime.Screens("PopupMTTable").ScreenItems("MTTable"& x & y) {x row,y colum}

to buttoms i can entracance throught the tags.
MTTable000 DB [MT_DB_00] DBW [MT_Index_00]
.... but i will create less tags than before

Thank you Nick

I will try to create one row like a faceplate :)
 
Nick

Hi guys,
i have one problem and i dont know how can i manage it
the syntax of

InvertBitInTag SmartTags("MTTable_" & RowS & "9"),10

i cannot compile, there is misstake
But when i write InvertBitInTag SmartTags("MTTable_09"),10
It is without any problem
I tried to write code with local variable like
help = "MTTable_" & RowS & "9"
InvertBitInTag SmartTags(help),10
but it doesnt working too :(

For example:
Code:
			'indMT\Month_OIL.Reference = AccessName + ",W" + Text(index + 36, "#");	
			SmartTags("MTTable_" & RowS & "7") = Month(RightNow)
			'indMT\Day_OIL.Reference = AccessName + ",W" + Text(index + 38, "#");
			SmartTags("MTTable_" & RowS & "6") = Day(RightNow)
This code i can compile without any problem

Thank you for response
 

Similar Topics

HEllo, still satruggling with the curse WinCC Unified. See attached picture. I just want to change the fill colour from turqoise to grey and then...
Replies
5
Views
471
I have a Wincc project not for operating but for showing power & energy consumption with trends I have 7 trends and I want to change the trends...
Replies
1
Views
1,195
Hi everyone and happy new year. I am trying to make an objects visibility dynamic using vbs in a picture. In Screen, whenever i release the...
Replies
0
Views
2,245
Hi All, What i am trying to achieve is a dynamic tag(Device_1)[Text tag 16 bit] that monitors the state of another tag (Config_1)[unsigned 8 bit]...
Replies
1
Views
3,368
Hi All, I installed WinCC 7.0. Last time that I used WinCC, version 6.2 was the last :-). So, I tried something simple... Made an internal tag...
Replies
1
Views
3,805
Back
Top Bottom