Passing tag values

Hi - Probably a simple problem for most - I have two PLCs both communicating just fine. Just within a Vision Panel, I would like to pass the value of one tag in PLC1 to a tag in PLC2 - something simple like PLC2/Tag10=PLC1/Tag50… can’t seem to find any scripting examples and I’m not having any success on my own… any ideas?

Thanks.

system.opc.readValue and system.opc.writeValue are probably what you are looking for.

system.tag.getTagValue and system.tag.writeToTag would probably work too.

Hi - Thanks for the info. I tried this by creating an app module - Passdata using two lines of script that compiled ok -

Test=system.tag.getTagValue("[]FX3U/M1")
system.tag.writeToTag("[]FX3U/M2",Test)

I then created a 250 msec Timer Client Event script TransferTags that simply calls app.Passdata.
Toggling M1 in my PLC changes the value of tag M1 in my application, but tag M2 doesn’t change… any idea what I’m missing here?
Once I get this working in one PLC, the real intent is to pass it to another device but I’m starting with the basics to at least get an understanding…

Thanks.

I would use a tag change script instead of a timer script. That way the script will only run when M1 changes rather than every 250 ms. You can create a tag change script in the Event Scripts (Gateway). You don’t want to create a client event script since it requires a client to be open and it will run on every client.

When you create a tag change script you want to tell it which tag to listen on. In your case the tag is FX3U/M1. The script will look like this:value = newValue.value system.tag.writeToTag("FX3U/M2", value)So whenever M1 changes it will write it to M2.

Another way you can accomplish this is outside of scripting. You can create a DB tag in the SQLTags browser through the right click menu on the Tags folder. The DB tag will be an expression (select expression mode from Expression/SQL tab). The expression will just point to the M1 tag like this:{FX3U/M1}Below you have the ability to write the value of the DB tag to another tag. You can select M2. This does the same thing as the script but easier to setup and to find.

Hope this helps. Let me know if you get stuck.

Hi - I still can’t figure out why the scripting method is not working, whether I use I timer or a change of state - but I also tried the DB tag method which is working just fine so that’s what I’ll stick with for now. Thanks for the help!