×
Siemens Industry Online Support
Siemens AG
Entry type: FAQ Entry ID: 18943009, Entry date: 10/18/2010
(0)
Rate

Why is the value not displayed correctly when you write a tag via VBS and then read it directly?

  • Entry
  • Associated product(s)

Description:  
You have, for example, the code lines below in a VBS and realize this does not always work.

HMIRuntime.Tags("NewTag_2").Write HMIRuntime.Tags("NewTag_1").Read
HMIRuntime.Tags("NewTag_3").Write HMIRuntime.Tags("NewTag_2").Read
HMIRuntime.Tags("NewTag_4").Write HMIRuntime.Tags("NewTag_3").Read
HMIRuntime.Tags("NewTag_5").Write HMIRuntime.Tags("NewTag_4").Read

In the case above the values are read and written via the tag image. In order to be sure the tag was read before it was written, you can use a synchronous read and write job. Therefore, change the read jobs from "Read" to "Read(1),1" - as in the following example.

HMIRuntime.Tags("NewTag_2").Write HMIRuntime.Tags("NewTag_1").Read(1) ,1
HMIRuntime.Tags("NewTag_3").Write HMIRuntime.Tags("NewTag_2").Read(1) ,1
HMIRuntime.Tags("NewTag_4").Write HMIRuntime.Tags("NewTag_3").Read(1) ,1
HMIRuntime.Tags("NewTag_5").Write HMIRuntime.Tags("NewTag_4").Read(1) ,1

Remark:
Synchronous read and write jobs are equivalent to GetTagxxxWait and SetTagxxxWait from the world of ANSI C. The disadvantage of these functions is that they take longer because they are dependent on the coupling and the AS. The further processing of scripts is stopped until an answer is received from the AS. Thus, they can lead to a loss in performance, and hence they should be used only in exceptional cases. Asynchronous write and read jobs are considerably more effective because these are processed via the image. Reading and updating of tags are here two procedures that run separately. 
Synchronous jobs should only be used, if it must be ensured that the tag was written or read prior to further processing of the script. 

Note:
Refer to the descriptions of GetTag and GetTagWait given in the WinCC Information System under:

  • WinCC V6.0 "Working with WinCC > ANSI-C for Creating Functions and Actions > Function Descriptions > Internal Functions >tag > get > GetTagBit > How the GetTag functions work"  
  • WinCC >= V6.2 "Working with WinCC > ANSI-C for Creating Functions and Actions > Internal Functions >tag > How the GetTag functions work"  

Security information
In order to protect technical infrastructures, systems, machines and networks against cyber threats, it is necessary to implement – and continuously maintain – a holistic, state-of-the-art IT security concept. Siemens’ products and solutions constitute one element of such a concept. For more information about cyber security, please visit
https://www.siemens.com/cybersecurity#Ouraspiration.
Rate entry
no rating
Requests and feedback
What do you want to do?
Note: The feedback always relates to the current entry / product. Your message will be forwarded to our technical editors working in the Online Support. In a few days, you will receive a response if your feedback requires one. If we have no further questions, you will not hear from us.