How to transfer or copy a Value from one Tag to another Tag in Wincc?

Iman

Member
Join Date
Jul 2010
Location
Tehran
Posts
172
Hi Guys,
Please give me some tips about scripting in Wincc. I wanna copy a value of a Tag and transfer it to another Tag. These tags are located in my PLC (S7-300) memory. I've got some tips in this link http://www.plctalk.net/qanda/showthread.php?t=65298. I don't have any information of VB scripting but by the help of that link I've written this script:
Code:
Option Explicit
Function action
Dim Tag1
Dim Tag2
Dim Tag3
Set Tag1=HMIRuntime.Tags("Bitm02")
Set Tag2=HMIRuntime.Tags("Bitm03")
Set Tag3=HMIRuntime.Tags("Bitm50")
 
Tag3.Read
Tag1.Value = Tag3.Value
Tag1.Write
 
Set Tag1 = Nothing
Set Tag2 = Nothing
Set Tag3 = Nothing
 
End Function
Bitm02 related to this address M0.2 and Bitm03 ==>> M0.3
Bitm50 ==>> M50.0

at this stage I just wanna read the value of M50.0 and write it to M0.2 by wincc. I've saved this script and put the trigger time in 250 ms but after activating the script doesn't work. I don't know what's the problem? Please guide me. If you have the script in C it's also good for me.
Thanks in advance
 
Option Explicit
Function action
Dim w,r
Set w = HMIRuntime.Tags("TAG1")
r=HMIRuntime.Tags("TAG2").read
w.value = r.value
w.Write
End Function

Maybe works : HMIRuntime.Tags("TAG1").write = HMIRuntime.Tags("TAG2").read
the above code is just from scratch, i can not check it at the moment

Maybe this link tot siemens can help you
http://support.automation.siemens.c...objaction=csview&extranet=standard&viewreg=WW
 
Last edited:
The sychronous Read also didn't work :( Maybe I have a problem with cyclic action ot trigger method, Do you have any instruction for that??
 
Option Explicit
Function action
Dim w,r
Set w = HMIRuntime.Tags("TAG1")
r=HMIRuntime.Tags("TAG2").read
w.value = r.value
w.Write
End Function

Maybe works : HMIRuntime.Tags("TAG1").write = HMIRuntime.Tags("TAG2").read
the above code is just from scratch, i can not check it at the moment

Maybe this link tot siemens can help you
http://support.automation.siemens.c...objaction=csview&extranet=standard&viewreg=WW


Non of you solution wil work the easiest way to do it is like this:

HMIRuntime.Tags("TAG1").write HMIRuntime.Tags("TAG2").read

like this won't work.

HMIRuntime.Tags("TAG1").write = HMIRuntime.Tags("TAG2").read
 
The top one will.
I've used a similar one with about 50-ish tags.
The one Koen provided will also work.

The reason why nothing happens will have to be searched in your settings.
Have you enabled global scripting?
It's a checkbox you need to tick in the Runtime Start-up section of the server configuration.
By default it is not enabled. (at least it wasn't on any project I ever started)


EDIT: It will be better if you use Koen's solution.
If you trigger the global script faster than it can execute, gscrt.exe will start allocating memory and won't be releasing it, meaning in a few weeks time your system will crash due to lack of memory.

Another hint, check if gscrt.exe is actually running. This is the process handling Global scripts.
 
Last edited:
Thank you so much guys,
I think , If I enabled the global scripting as you've said, it would work.
Any way, I've written my code (in the first post) in the Dynamic option of tags instead of writing in global scripting and it has worked. But I've a problem again: when I read a tag from OPC server and transfer it to the PLC my solution works perfectly but when I change the direction of read process,I mean, when I read a tag from PLC and transfer it to the OPC server, it takes a long time to do the job, especially when I change the value of tag in PLC in one run time. Each time it takes more time than before to read and write. For example, for the first change it takes 14s, for the second change it take 30s, for the third change it takes 55s and ...(all the changing value happens in one run time), I don't know what is the reason for this delay. The interesting thing is when I read from OPC server and write to the PLC it works in a blink but in opposite direction I've the issue.
Do you have any idea?
Thanks
 

Similar Topics

I'm trying to verify a project with a PLC. The Transfer Setup menu item is grayed out and every time I click Verify with PLC, I get an error...
Replies
1
Views
55
Hello, I need to create an automatic transfer panel that connects to the generator when the mains power is cut. I can draw up to 60kW and draw up...
Replies
0
Views
86
Does anyone know what the data transfer rate for this series of CompactLogix PLC's? 1769-L24ER-QB1B to be exact. Cheers.
Replies
1
Views
98
Hi all, Im having trouble transferring a program from one panelview 550 to an new one. I can insert a flash card into the old panelview and upload...
Replies
20
Views
357
Hi Everyone, I have a customer that needs a CQM1H (CPU51) replaced. They purchased the processor new-old-stock from a source they found online...
Replies
3
Views
354
Back
Top Bottom