Showing results 1 to 2 of 2

Thread: SCRIPT operation order

  1. #1
    Join Date

    Beitrag SCRIPT operation order

    Hello to all, I need any helps about SCRIPT operation.
    FUNCTION1 to WRITE SET ALLOCATION TRIG variable1 and FUNCTION2 to WRITE SET variable 2 are put in order in current SCRIPT (variable 1> variable 2 order).
    The desired operation is caused by ALLIGATION TARGET variable3 due to TRIG(variable1) being written before variable2. (in order of my SCRIPT FUNCTION composition)
    But at the runtime, it seems that variable2 changes first and variable3 changes after that.
    Please answer if it is a part that can be checked.

    Thanks to you.

  2. #2
    Join Date
    Salzburg, AT

    Default Re: SCRIPT operation order

    From the description I would guess that the variable1 is from some process driver writing to the PLC?

    zenon variables has always the value like received from PLC. This is not immediately the same value as the user entered; and even always the written value. Why like this? - imagine situation when the connection to the PLC breaks in the moment while user enters new value. zenon (process driver) tries to write the new value to PLC, but either the PLC never received this value or was unable to send to zenon the update. Then zenon does not know what PLC has. Or another situation - the user writes to PLC value 4 while the PLC is programmed to have in this variable the max value 3. So the PLC may refuse or scale the value, nobody knows.
    The proper behaver is to wait till PLC sends the updated value back, only then you can be sure that this is now the variable value.

    With another words: the set value function is not directly changing the variable value. The function informs (writes) the PLC to change it. Only after PLC sends the value update, then the value of zenon variable changes. Thus, if Allocation is executed in this short period - after zenon has sent to PLC the write request with new value, but before the PLC has responded with the updated value - the variable1 has still the "old" value.

    To propose you the best solution I would have to know: what is your use-case for Allocation of variable1 to variable2? What is the reason that you are using additional trigger variable? What driver are you using and how frequently variable1 changes?
    The Allocation configured to use 'Edge'-trigger type would update variable2 when variable1 changes (so after PLC updated it and informed zenon successfully); and not already when project executes the script to force the change.

Similar Threads

  1. PID revers operation
    By spn in forum straton / zenon Logic
    Replies: 1
    Last Post: 2nd November 2015, 15:04
  2. Math Drv. no modulo operation
    By alexj in forum Drivers
    Replies: 5
    Last Post: 20th May 2015, 10:39
  3. How long? Or did I order right?
    By cassie256 in forum zenon Supervisor
    Replies: 4
    Last Post: 16th November 2012, 15:01
  4. execution order of functions within a script
    By gralex in forum zenon Supervisor
    Replies: 1
    Last Post: 19th May 2011, 09:55
  5. DragDrop operation
    By altera in forum VBA
    Replies: 3
    Last Post: 22nd November 2010, 11:23

Posting Rules

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts