order of initialization

tvm
2019-06-19
2019-07-01
  • tvm - 2019-06-19

    I'm trying to put together a list of when variables and function blocks are initialized on bootup, or after a download. I haven't been able to find a single document that outlines everything, but I've been able to figure some of it out from different sources. So far I have the following:

    Global Variables (undefined order unless {attribute 'global_init_slot' := '<slot>'} is specified)
    (constants first, then other variables)
    GVL
    PersistentVars (variables not always initialized - not exactly sure how Codesys decides)
    GVLs from libraries (not sure in what order)</slot>

    POUs (in order defined by TASK call, priority, and interval?) - list of tasks appears to be in alphabetical order
    VAR_STAT
    FB_Init
    VAR
    constants
    other variables
    functions marked "call_after_init"

    NOT SURE:
    visualizations
    initialization of properties in function block definition (ex. FB_Instance: TEST_FB:= (Property:= 12345);
    parameter lists in libraries

    I wonder if we can put together a single list, or if anyone knows of a document that does this already?

    Tim

     
  • m.prestel - 2019-06-24

    Hello Tim,

    the visualization uses a range of init slots for different parts of the code.
    Anything specifc you are looking for?

    Opened an issue to better documente the initialization

    Best regards,
    Marcel

     
  • tvm - 2019-06-26

    At this point I'm just trying to understand how it works. Aside from some kind of trial and error method, I'm not sure how to figure out the order of everything, and I'm not even sure that my list is correct. Initialization of properties in function block definitions is what cause me to look into it further. For example, if I define a function block like this: FB_Instance: TEST_FB:= (Property:= SomeVariable); where the property is a reference or pointer to a variable in a different program, I need to ensure that that program is initialized first, otherwise the reference is invalid. It becomes very difficult to troubleshoot, because the download simply fails and the PLC crashes without giving any feedback on where the problem is.

     
  • m.prestel - 2019-07-01

    Hello Tim,

    In short the visualization initializes all the variables/references after the normal initialization.
    Then each visu cycle these variables/references get updated again.

    Best regards,
    Marcel

     

Log in to post a comment.