Is it possible to define an array of function blocks? I’ve looked around for an answer and the closest thing I can find is in CODESYS: https://forge.codesys.com/forge/talk/Engineering/thread/fc16090b49/
This is a popular request that unfortunately isn’t available in PLCnext Engineer yet.
This requirement is closely related to pointers, since an array of function blocks would probably be implemented as an array of pointers to FB instances.
This was discussed last year, here:
Hi all,</p>TLDR, how do i pass a (pointer to) function block to another function block (or program) in PLCNext.</p>The longer explanation: </p>Just getting started with PLCNext engineer, but I cannot figure out to get the following to work.</p>I have am writing control software of a machine that has a tank that must be filled, for this a tank has a pump and some valves and sensors connected. A machine can have multiple of these tanks.</p>I made a function block that represents a single TANK. (and this actually contains a few function blocks it self to control the hardware)</p>Now my idea is to have a few state machines that execute a specific use case. Because I have multiple tanks, I want to pass it the pointer to a tank (like tank1 or tank2).</p>But if I create a variable in PLCNext in the variable list, I can choose ‘InOut’ to pass reference/address/pointer whatever to a basic type like int,word,etc. But if i choose function block, the only option i can select is ‘local’ (which i cannot change later on).</p>Thanks in advance, maybe my solution to handle this is wrong, but i do not want to endup with a case 1234, for every single line in my program.</p>