minlma
Hello,
Running the simulation in the main program works fine. I added a FB and noticed that simulation is not an option as the eye glass icon is greyed out. In an attempt to circumvent, I defined the output variable in the FB as global and as external in the main program. Then the simulation in the main program can start but the value of the output variable from the FB does not change as it should. Can you enlighten me on the matter? Thanks beforehand, Marc
thiagoralves
The glasses only get greyed out if the FB is never called anywhere, which means that the block never executes. Make sure you’re calling your FB from a program or another FB
Reply 0 0
minlma
Hello Thiago, thanks for your reply, but I must admit that it puzzled me. Also in the multi language example I didn't understand where the blocks came from. Now by some chance I noticed that I can drag an FB into the main program. I've checked quite some videos on youtube but that an FB could be dragged ... didn't encounter that in the videos. So, as beginner, I progress bit by bit. Many thanks for your prompt answer!
Reply 1 0
thiagoralves
To clarify, Functions and Function Blocks should be seen as "reusable code". They exist to reduce the complexity of placing the entire source code in a single place. Good utilization of Functions and Function Blocks makes the code more compartmentalized and easier to read/fix bugs. Therefore, once your blocks are created, you can call them from your program as many times as you need, the same way you can call a TON timer, or any other block. If you never call the block, it will never be executed, so its code doesn't even exist in the program.
Reply 0 0
Reply