In my Codesys 3.5.18 project, I had function blocks MyKeyboard and MyNumberPad declared from a library I had previously created (version 1.1.0) and added to the Library Manager.
PROGRAM Dummy
VAR
'some other declarations
MyKeyboard : ETN_KNP.ControlKeyboard;
MyNumberPad : ETN_KNP.ControlNumberPad;
'some other declartions
END_VAR
I made some changes to this library, and gave it version 1.1.1. I updated the placeholder version to 1.1.1 in my Library Manager. Now, I am getting an error that the function blocks are not instantiated. They clearly are - the code that did that in the variable declaration part of main project is unchanged, the only change is the new library version.
I tried restarting my laptop and Codesys, hoping the issue is some confusion in the Library Manager / Repository with the new version. Why might this be happening and how can I fix it?


As function blocks in codesys are essentially what classes are in other languages, you must call the 'constructor' to initialize an object. In codesys this initialization is done by calling the FB_Init (Function Block Initialize) method.
Codesys implicitly calls the
FB_Initmethod one first run with the arguments defined during the declaration, for example:If the
FB_Initis not explicitly called, then codesys automatically calls it without passing any arguments, in other words the below two declarations are semantically the same to codesys:There's one exception though, you can disable the implicit call to
FB_Initduring declaration by using the noinit pragma, in which case you need to explicitly callFB_Inityourself once during application initialization:Finally, you must ensure that, just like with any function call, the correct number and type of arguments are passed to the
FB_Initfunction: