WinCC Flex, Tag Updating in VBscript

Cobonweb

Member
Join Date
Jun 2009
Location
Holland
Posts
17
Hello fellow PLCTalkers,

I am having issues with Tags not updating when used in scripts.

Hardware:
HMI: MP277
PLC: Siemens CPU 315
WinCC Flex 2008

Situation:
I have writen an export script that reads data from a database in the PLC and writes this to a CSV file. Exporting works fine. The only problem is the Tags not updating when called in the script.
I can "force" the update of a tag by showing the value of the tag on screen(using an IO field). However, I have a lot of tags (600+:sick:) so showing all of these tags on the HMI screen is not an option.

Summary:
I am looking for a way to update tags (which are not visualized on my HMI) inside my script.
 
Hi Jesper,

I have tried all 3 settings; Cyclic on use, On demand and Cyclic Continious.

The only option that works is Cyclic Continious (as expected). The amount of data is too much to use this option (specially when considered that these tags are accesed only once a day)

I could use Continious if I set the cycle time higher ...however, I dont like the idea of not knowing when the tags get updated (example:if the data in the database on the PLC is edited every 10 minutes, and the tags are updated every hour...)
 
600 tags may well be a problem.
There is the system function Update Tag, but you cannot use inside the script. You can use it as a function before calling the script, but for 600 tags it is not practical.

I dont have a problem with using one tag to trigger a script, and then accessing an array inside the script.
The problem may be with 600 tags.
It should be mmuch more efficient to create a VBS variable array, and then pass the values from the Flex tag array in the start of the script, and working on the VBS array in the rest of the script.

For example if PLCTAGS is and ARRAY TAG of 10 REALS.

dim internaltags(9)
internaltags = smarttags("PLCTAGS")
'internaltag(0) has the value of smarttags("PLCTAGS")(0)
'internaltag(1) has the value of smarttags("PLCTAGS")(1)
'etc
 
Agreed, 600 tags is ugly. I only use 600 tags because of the way the database is structured;its one big db filled with 30 structures, each structure contains different data types:cry:

Your advise of copying the tags to an internal script variable seems to work! I am confused why this works though:S.

The two situations:

1: "Script writes SmartTag(TagName) to export file"

2: "Script copies SmartTag(TagName) to internal variable"
"Script writes internal variable to export file"

The tag is not updated in situation 1, a zero is written to the export file. However in situation 2, the tag is updated and the correct value is written to the file.

Siemens logic or?

:geek:
 
I think the truth is buried in the size of the array tags.
If you access an array tag in VBS code, then the entire array is read from the PLC regardles of that you onlye read one element.

So, if you have many array accesses in VBS code, you read the the entire array as many times as you access the array in VBS. For a few calls to small arrays it may not be a problem. But with lots of calls to big arrays, it can lead to unpredictable behaviour.

Reading to a temporary VBS array, means you only read the PLC array once.
 
How the hell did this work for you?

dim internaltags(9)
internaltags = smarttags("PLCTAGS")

For me it gives me the error "An array cannot be the target of an assignment"
 
That is true. An array cannot be the target of an assignment.
Is this the only way to copy an array?

For i = 0 To 9
internaltags(i) = SmartTag("PLCTAGS")(i)
Next


Or there is another more efficient way to do it?
 
https://support.industry.siemens.com/cs/document/26165877?lc=en-WW
To copy an array of process tags from the controller to a script you have to copy the array elements one by one, in a loop, for example. However, you can copy a local script array directly to a process tag array using a single instruction:

Example
' CPU_Array is an array of process tags
Dim local_array(10)
Dim i
...
' Copy from the CPU to the script:
For i = 0 To 9
local_array(i) = SmartTags("CPU_Array")(i)
Next
...
' Copy back to the CPU:
SmartTags("CPU_Array") = local_array
 

Similar Topics

Hi All, I have some WinCC flex templates that I need to duplicate in the same project but for a different connection (PLC). I cannot find any...
Replies
13
Views
4,474
I am a little confused by a program that I am looking at. So If I got this correct multiplexing is using indirect addressing (Which points to an...
Replies
4
Views
3,884
In Flex sp2 in faceplate editor, I want to make a button visible when a external tag from plc (mw100) has value 4. In the designer, I can only...
Replies
5
Views
5,245
Hi I have approx 2000 tags I need to use in a mutiplex method. I exported the tag list to csv but the mutiplex tag has no multiplex data...
Replies
5
Views
4,289
I'm programming an MP370 (for the first time) and using WinCC Flex 2008 advanced. Please excuse my ignorance because I'm used to AB PanelView +...
Replies
6
Views
4,448
Back
Top Bottom