WinCC: Structured Tags in VBS-Action of Popup?

MapleMoose

Member
Join Date
Sep 2023
Location
Ontario
Posts
2
Hello,

I just started learning WinCC V8.0 3 days ago, so I'm still new to how everything works in this program.

I've created a pop-up with a button containing a VB-Action. The Popup is located in a picture window on one of my screens.

However I can't seem to figure out how to configure the action to work with structure tags.

When pressing a start button I want to increase a start counter, but only if the motor is not already running. I currently have this:

Code:
Sub OnLButtonDown(Byval Item, Byval Flags, Byval x, Byval y)

Dim Start
Dim VBVar
Set Start = HMIRuntime.Tags("Pump1.Status")
Set VBVar = HMIRuntime.Tags("Pump1.Starts")

Start.Read
VBVar.Read

If Start.Value = 0 Then
VBVar.Value = VBVar.Value + 1
VBVar.Write
Start.Write(1)

Elseif Start.Value = 1 Then
VBVar.Value = VBVar.Value
VBVar.Write
Start.Write(1)

End If
End Sub

If you could suggest how to adjust this for the use of structure tags, or a better way to achieve this I would appreciate it.
 
Welcome to forum.


There is maybe typing error on write(1). It works on older WinCC but not finding it from scripting manual.
Maybe you confuse it to read() and read(1) commands.
(Read from WinCC tag cache and directly from PLC)


For writing commands are write 1 (to WinCC tag cache)
Write 1, 1 (Write directly from script to PLC)





Instead try Write 1 (value 1 to WinCC tag cache and wincc writes to PLC afterwards)




Sub OnClick(ByVal Item)

'Create script objects'
Dim Start
Dim VBVar

'Link tags to objects'
Set Start = HMIRuntime.Tags("test2.NewTag1")
Set VBVar = HMIRuntime.Tags("test2.NewTag2")

'Read values to script objects'
Start.Read
VBVar.Read

'If start command false count start button presses. Set start command'

If Start.Value = 0 Then
VBVar.Value = VBVar.Value + 1
'Write value to back to tag'
VBVar.Write


'Write true to start command tag (cache)'
Start.Write 1


End If



End Sub
 
I realize I had the old code where I was doing two actions at once.
I did manage to figure it out myself by breaking it down into two steps. Here's what I ended up with:

Code:
Sub OnLButtonDown(Byval Item, Byval Flags, Byval x, Byval y)                                                                               

Dim VBVar
Dim Status
Set VBVar = HMIRuntime.Tags(".Starts")
Set Status = HMIRuntime.Tags(".Status")

Status.Read
VBVar.Read

If Status.Value = 0 Then 
VBVar.Write(VBVar.Value + 1)
Status.Write(1)

Elseif Status.Value = 1 Then 
VBVar.Write(VBVar.Value)

End If
End Sub
 
Last edited:

Similar Topics

Hi there, Situation: We've got several structured tags in a WinCC application. Those contain integer values which in turn contain bits that...
Replies
4
Views
5,637
is there any free trial version available for step7 professional and wincc comfort v17. i searched and downloaded TRIAL Download STEP 7...
Replies
1
Views
86
Hello. I have a db which is 1000 INT, and this db is represented in WinCC as a raw data type set of 5x 400 Bytes. This set is read with a script...
Replies
1
Views
95
Hello Experts I am working on a project with WinCC Unified v16 PC system and want to create an option on the screen to export logs to the...
Replies
0
Views
77
Does anyone happen to know how to install the graphic picture in HMI when I go into blower selection there are no graphics shown not only blower...
Replies
1
Views
112
Back
Top Bottom