CODESYS - the IEC 61131-3 automation software
https://forum.codesys.com/

order of initialization
https://forum.codesys.com/viewtopic.php?f=11&t=9818
Page 1 of 1

Author:  tvm [ Wed Jun 19, 2019 4:06 pm ]
Post subject:  order of initialization

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)

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

Author:  m.prestel [ Mon Jun 24, 2019 7:32 am ]
Post subject:  Re: order of initialization

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

Author:  tvm [ Wed Jun 26, 2019 3:58 pm ]
Post subject:  Re: order of initialization

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.

Author:  m.prestel [ Mon Jul 01, 2019 6:28 am ]
Post subject:  Re: order of initialization

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

Page 1 of 1 All times are UTC+01:00
Powered by phpBB® Forum Software © phpBB Limited
https://www.phpbb.com/