Error Writing to Tag.value:Bad

Hello,
I have a tag that is giving me this error when I try to toggle it. I have 20 other tags that are setup the same way but this one is not allowing me to toggle it. Attached is a screen shot of the issue. Any help would be greatly appreciated!

image

Did you by chance try writing to the the tag in a script from the designer? Is it in full read/write communication?

I am, I am using a gateway script to change the tag. It is the same script for all the tags. It is in full communication.

Here is the script it is just a simple read and set bit command:

#Specifiing the path.
path = ["[default]Ovens/Oven26/DEKEMA_Furnace_Status/OPC_UA_DATA_VisuStatus_Data"]
#Tag path
BitFlipper = ["[default]Ovens/Oven26/IDLE PLC/UnitId 26/26_013-26_013/26_013.value"]

qualifiedValues = system.tag.readBlocking(path)
value = qualifiedValues[0]
print path

print value.value

if value.value == "WAIT":
system.tag.writeBlocking(BitFlipper ,1)
print("Waiting")

else:
system.tag.writeBlocking(BitFlipper ,0)
print("Running")

I think I found the issue....

Now I just need to track down where this issue lies

From looking around the Forum, it seems that this error means that the tag in the device can not be written.

Which appears to have two causes:

  1. The address doesn't exist (typo or other entry error).
  2. The device is busy doing something else and has refused the write. (Specifically there have been issues seen if this is tried while logic is being updated).

On another note, I'm going to be honest, I didn't think it was possible to have a tag name that began with a number, even if it is, I would strongly suggest that you don't do that, it will eventually bite you.

If you're running this from a Gateway Script, then print doesn't print where you might think.

For what it's worth, I would write your script like this:

path =  ["[default]Ovens/Oven26/DEKEMA_Furnace_Status/OPC_UA_DATA_VisuStatus_Data"]
status = system.tag.readBlocking(path)[0].value
bitFlipper =  ["[default]Ovens/Oven26/IDLE PLC/UnitId 26/26_013-26_013/26_013"]
system.tag.writeBlocking(bitFlipper, [if status == "WAIT"])
2 Likes

Thank you Irose!

It was a typo on my end that was looking to the wrong coil. Thank you I will adjust my scripts!