Closed Kronosson closed 3 years ago
it should work with datavalue! is the plc clock set to correct date and time?
S7-1500:
from opcua import Client, ua
url = "opc.tcp://192.168.10.1:4840"
client = Client(url)
client.session_timeout = 30000
client.connect()
print(f"Connected: {url}")
node = client.get_node('ns=3;s="TEST"."TestUint"')
print("before: ", node.get_value())
node.set_value(ua.DataValue(ua.Variant(5, ua.VariantType.UInt16)))
print("after: ", node.get_value())
client.disconnect()
print("Disconnected")
Connected: opc.tcp://192.168.10.1:4840
before: 200
after: 5
Disconnected
dv.ServerTimestamp = datetime.datetime.now()
this is done from the set_value() method!
Thank you very much. That solved this problem. Now i have the next. The Value is not set to the new value. There is no difference in the operation of my device. I checked, if the nodes are set to writeable in TIA Portal and they are. But i can't change the values, neither with my script, nor with UA Expert. UA Expert even says, the write to node was succesful.
Is it possible, that something overrides my new value?
PLC itself maybe! Does the Value get written cyclic somewhere in the PLC-Program? Check Cross-References in TIA.
You were right about that. Thank you very much. The PLC overwrites every change. A collegue of mine was able to fix the issue within in PLC. Now i'm able to change the values, as it should be.
@Kronosson Perhaps this issue should be closed?
It seems, that this case should have been closed a while ago -- Case closed 🕵️
I'm completely new to OPC UA and i'm having a problem with my client code. I'm using Windows 10 64-bit and i'm coding in Spyder. I'm trying to write a new value on an existing node in my Siemens S7 1200. Reading it is easily done, but changing the value always gives me the following error:
My code looks like this
After this issue I searched a bit and found a few others who had similar problems, so tried adding in the following lines, as it seemed to fix the problem for some people.
Unfortunately i'm still getting the same error message.