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,629
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
65
Hi folks, I'm not as accustom with Siemens & WinCC, however I've been asked to increase the amount of data an existing application is logging...
Replies
2
Views
67
I have created a project in TIA Portal v16 Upd6 with S7-1200 (6ES7214-1AG40-0XB0) and WinCC Unified (PC station). The communication between the...
Replies
4
Views
145
I am creating a project with WinCC Unified v16 Upd6 (PC runtime) with an S7-1200. The communication is good between the PC and the PLC as I can...
Replies
6
Views
196
Back
Top Bottom