Force an OPC tag to update its value in a script

I have 5 OPC tags (from a PLC) in a tag group updating every 5 minutes,
what I want is to get the most recent value when a button is pressed.
I can’t get the most recent value from the PLC, I keep getting the old value and I need to wait for the 5 minutes to refresh.
how can I force a tag to get the most recent value from the PLC when I press a button?
I tried system.tag.scan(“provider”,“Group name”) but that didn’t refresh the values…
any ideas… Thanks!


You didn’t say but I’m assuming by using system.tag.scan your using version 7.9? If so system.tag.scan should force the scan class to run. If your in 8.0 then I think you should use system.tag.requestGroupExecution(). Depending on what your doing with the data you can also look at using system.opc.readValues(). What are you trying to do with the values when you update them?

Use system.opc.readValues, and optionally write the results back to the tags if you care to.

Unless your scan class or tag group is in OPC Read Mode then forcing an execution does nothing for the OPC tags in it.

I’m using v8.0.
I’m just trying to insert the values in a SQL table, but just when the user press the button, but I’d like to have the most recent ones when this happens…thanks for the help!

Hi Kevin,
system.opc.readValues took care of my issue.
That worked fine!! Thanks for your help!!