Problem writing tags to Siemens device

Hello,

I'm tinkering for the first time with the Maker edition of Ignition, made some simple perspective views to read/write from a siemens s7-1200 i have around.

There's a problem when writing tags i'm having. I have a couple of buttons (manu/auto) that sets one tag to True and the other one to False (OPC tags from the siemens device), normally it works fine, but sometimes when i trigger the script on mouse click, only one of the two tags changes leaving both of them with the same value until i click again.

I've tried synchronous and async writing, it happens with both, i'm sending the values at a time with the same fuction call.

This is the script right now:

def runAction(self, event):
  id = self.view.custom.id
  tags = ["[default]"+id+"/Auto","[default]"+id+"/Manual"]
  valores = ['False','True']
  system.tag.writeAsync(tags, valores)

I know i'm not using a callback function, but i'm just playing around, could the use of one avoid this? I know it could at least trigger some kind of warning, but i dont see that as a solution.

Is this normal? Is there a way to modify the poll time of the tags on the driver? Should this be double checked inside the PLC program to avoid this kind of problems?

Thanks

Are you resetting these values in the PLC logic? Did you do something like set Read After Write on the tag group settings? Have you looked at the result of the write call (easier with synchronous version)?

Hello Kevin,

thanks for your reply!

No, i'm not writing to those variables inside the PLC program, and Read After Write is false on the tag group settings.

How can i see the result of the write call? I tried opening the output console but i don't see anything there.

The call supplies the quality object for each individual write in the return value. As documented.

OK i tested it, it always returns quality Good / Code 192, even when the values are not changing

That suggests a Siemens bug. You might want to have support help you collect a wireshark capture or otherwise document what is going on.

Thanks for the idea, i just took a look at wireshark and its funny because the PLC returns code "Success" for both variables :face_with_monocle: on the ack

Send:

S7 Communication
    Header: (Job)
    Parameter: (Write Var)
        Function: Write Var (0x05)
        Item count: 2
        Item [1]: (DB 2.DBX 2.0 BIT 1)
            Variable specification: 0x12
            Length of following address specification: 10
            Syntax Id: S7ANY (0x10)
            Transport size: BIT (1)
            Length: 1
            DB number: 2
            Area: Data blocks (DB) (0x84)
            Address: 0x000010
        Item [2]: (DB 2.DBX 2.1 BIT 1)
            Variable specification: 0x12
            Length of following address specification: 10
            Syntax Id: S7ANY (0x10)
            Transport size: BIT (1)
            Length: 1
            DB number: 2
            Area: Data blocks (DB) (0x84)
            Address: 0x000011
    Data
        Item [1]: (Reserved)
            Return code: Reserved (0x00)
            Transport size: BIT (0x03)
            Length: 1
            Data: 01
            Fill byte: 0x00
        Item [2]: (Reserved)
            Return code: Reserved (0x00)
            Transport size: BIT (0x03)
            Length: 1
            Data: 00

ACK:

S7 Communication
    Header: (Ack_Data)
    Parameter: (Write Var)
        Function: Write Var (0x05)
        Item count: 2
    Data
        Item [1]: (Success)
            Return code: Success (0xff)
        Item [2]: (Success)
            Return code: Success (0xff)

Time to report to Siemens. Good luck.

Do you want to write strings to the tags, or bools? It might implicitly convert them to bools, but always better to supply the proper types. Writing inverted values to those two tags doesn't sound like a great idea either

I was trying to write bools, how would be the best way to invert two values then?

A bool in python is False or True
For modes, we use an integer value, where for example auto = 0 and manual = 1, so ignition just writes the integer value. You could also use bools to set these for example 'ManualCmd' and 'AutoCmd' which let's you then set tag permissions per action. This is actually how I do this, regardless of we have a single integer or not, by using memory tags for the commands which write to the integer tag via a tag change script,in the case we can't change the plc logic.

Writing to two tags where the states should be mutually exclusive though as you're doing is problematic

Thanks!