How I/O attributes are handled by an app engine regarding writing/reading to/from it?

Hi,

Back in the days there were power points describing how this works but I don't have access to these anymore.

My basic scenario:

1) App Engine 500ms
2) One integer attribute (e.g. MyInt) and one I/O integer attribute (e.g. MyIOInt) which is pointing to MyInt
3) Then I do have a script which switches the value of MyIOInt between 5 and 10 over and over again.
4) Two data change scripts for the MyInt and MyIOInt which just give me the value in the logger.

When executing the script I would expect the following:
Because it's an IO attribute the change of value happens not instantly and I would have expected to have the correct value in the next scan cycle but according to my tests the value switches every second.

It seems the write value of the I/O attribute is the same in the first two script executions and on the third it changes for the next two script executions.

Is there anyone who has experience with that and can give me a hint where to look at? I've tested in 2020 R2 SP1 and 2023 R2 and the behavior is identical, so I doubt this is an issue.

Thanks
Peter

Some screenshots

MyIOInt which points to MyInt

MyInt

Switch script, triggers while true

DataChangeIO Script

Result in logger to see the timing:

Parents
  • It is quite a broad question but please reefer to the following image describing the scancycle

      

    When working with OI Attributes you also have the Write interrupts that could effect the behavior.

    There are multiple things that effect the path of an IO attribute and especially if your data is coming from a PLC and not the same object.

    Also cross engine communication could also effect how data is managed.

    You could also monitor Me.MyIOInt.WriteValue to verify pending writes.
    Value of Me.MyOIInt (or Me.MyOIInt.Value) is also verified value from source.

    You can not expect a IO attribute to have the value you are writing within the same script cycle.

    Me.MyIOInt = 10;

    If Me.MyIOInt == 10 then

    'This is not expected to happen on first execution

    LogMessage("Value is 10");

    else

    LogMessage("Value is not 10, but write pending is: "+Me.MyIOInt.WriteValue);

    endif;

      

    Please describe what you are trying to achieve and then I can see if I have some better explanations. 

  • It's actually not about achieving but understanding the system.

    In my script I also tried to log the write value.

    First cycle:

    1.1 Script executed => Checks if value is 10 => Sets it to 5 (Write value is 5)

    No data change script yet fired because I/O value didn't change

    2.1 Second script execution => Now checks if value is 5 => Sets it to 10 (Write value is still 5)
    2.2 Data change scripts are running and showing the value of 5 (makes sense to me)

    3.1 Third script execution => Now checks again if value is 5 => Sets it again to 10 (Write value now 10)

    4.1 Fourth script execution => Now it checks if value is 10 => Sets it to 5 (but write value is 10)

    Rinse and repeat. Below screenshot with the 4 scan cycles.

  • Thanks for clarifying, There is also a possibility to change the Execution order of the script, Default is "Just Before outputs", You could change it to "Just after Inputs", would be interesting to see how that effects your test.

    I have to try in 2023 R2 if something has changed based on my legacy experience that effect this, before making any more statements. Slight smile

  • Hi Richard,

    Actually I did the test in 2023 R2 first and then decided to see if it was different in 2020 R2 SP1. 

Reply Children
No Data