Jump to content

The difference of Function and Function Block


Recommended Posts

Posted
Hi, there. What is the main difference between Function and Function Block? (Just because of the Data Block....) Please explain or give an information in detail. Thanks for your help in advance.
Posted
A Function Block is like a function but with memory and the Data Block is the memory. There is a bit more to it, some complex parameters can be passed to a Function Block but not a Function. For a Function, if you create a parameter as type IN, you cannot turn it on and use it in that state outside the block because the IN parameter is not passed back out, similar for the OUT, you cannot use the OUT bit as memory i.e. it cannot be used to retain itself. For these above you need an IN/OUT. The FB saves the state of even IN/OUT parameters in the DB. For an FB you do not need to assign any tags to the I/O parameters, you have to with a Functions. Functions are normally used where it does something and the result is in the one call, it could for instance be used as a calculation. Functions don't need parameters if you don't want, I'd usually use Functions as a central distribution for other block calls. Having no parameters for a FB makes no sense, I have actually seen someone do this and they ended up with an empty DB. Also if you unconditionally call a FB without a DB, it automatically uses whatever DB is already used as the instance DB.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...