问题描述:

I'm learning CoDeSys (using V3.5 SP2) and I'm stuck with a rather beginner-level problem that I can't seem to find any resources for.

I have defined a simple Function Block (by going to Add Object -> POU -> Function Block and using the FBD language). The FB isn't abstract, nor does it extend another FB or implement an interface. (Its implementation consists only of some very basic boolean logic FBs.)

The problem is that I can't place this FB in my program. The FB does show up in the toolbox on the right under the POUs submenu, but when I try to drag it into my program, no Start here handle appears. I can properly place any of the built-in FBs, but not any custom ones.

What can I do? I suspect that I'm misunderstanding the way a program should be structured or the way FBs should be defined in it, but I can't tell for sure. Any help would be greatly appreciated.

网友答案:

Not sure about v3.5 but generally you instantiate a function block like this:

VAR
    fb_instance: MyFB;
END_VAR

where MyFB is the name you assigned to your custom function block.

As for built-in FBs, you probably confused function blocks with functions. AND, NOT, OR, GT — these are functions, not function blocks.

网友答案:

You need to drag in a "Box" from the "General" tools. Then in the box click the "..." and assign the FB you wanted.

网友答案:

I know I'm a little late to the party but you can press F2 for the input assistant. Using this tool will allow you to find you go to the function block section on the left hand side and find your function block. Once inserted it will prompt you to name the instance and put it in your variable declarations.

相关阅读:
Top