Siemens FB & FC

douyi

Member
Join Date
Aug 2005
Location
Toronto
Posts
123
I've been using Siemens for about one year now, and finished several different projects. Because I have more experience on AB, so I cannot get how and what benefit I have using FBs, actually, I can use DB instead of IDB, and feel no difference.

I know form some SFB I have to use that, on top of that, anybody familiar with FB can tell me why you'd like to use FBs?

Can you please tell me the difference as well?

Thanks a lot!
 
the main differece between fc and fb is that you can name the stat variables and use them as marks. If you use a FC with DB, you have to use bits of a DB as marks and they haven´t name.

i.e: FC1 with DB0:

opn #DBnr
***
u #in1
u(
u #in2
o dbx0.0
)
= dbx0.0
****

i.e: FB1 with DB1:

u #in1
u(
u #in2
o out1)
= out1

(out1 is a stat variable)
regards
 
Hi Douyi

This bit about FCs and FBs comes straight out of the IEC6-1131-3 standard. This is well-known and much discussed here and pretty much dismissed by the majority.

In pure IEC-speak, an FC should have only one Return Value, usually signified by Siemens as RET_VAL. Whatever you build it to do, the answer should be expressable as a single RET_VAL. The FC should be regarded as a RET_VAL generator whose answer is only dependent on the input parameters, not stored data. The result of the FC should be completely independent of whether this is the first or hundred-and-first time it has executed.

By contrast, an FB can have multiple output parameters and has its own associated instance data block for holding static variables. An FC has no concept of static variables as jmrcalin has indicated. If you have coded something like a moving average, the result of this does very much depend on how many times it has executed. The data carried forward between successive executions should justify this as being appropriate for an FB with its IDB.

That's 'pure' IEC-speak.

Of course, you can build an FC with twenty output parameters and store loads of data in fifty different data blocks. You can write all your code as FCs, or FBs, or a mixture in-between. So the question is really why didn't Siemens (or anyone else, for that matter) stick absolutely rigidly to the IEC-spec? Commercial suicide, I suspect. I don't know any manufacturer who has signed up for this and forbidden or prevented users to do what they want. We, the customers, demand the right to be wrong sometimes. Of course evry manufacturer has taken different bits of the IEC spec and enforced them more rigidly than others. How they decided which bits were important and which bits weren't we'll probably never know.

Regards

Ken
 
Thanks for replying.

As an example of jmrcalin, the purpose for stat variable is to be accessed outside of current subroutine, but when you access from outside, the format becomes DBx.DBXxxx.xxx again. If I use an external variable, I have more flexibilities.

So, I still can't have that - what's the benefit using FB? (Except using SFB)
 
douyi said:
So, I still can't have that - what's the benefit using FB? (Except using SFB)

Hi

Here is only couple of benefit using by FB's.
1) All the parameters and variables has a memory -> you don't have to transfer data between "memory" DB's and your function.
2) If you have more complicate function -> you don't have to fill all the "parametres" of the function. Look at e.g. PID-controller FB41.
3)You can read/write the FBs parametres directly all over the program.


-Pete- 🍺
 
douyi said:
Thanks for replying.

As an example of jmrcalin, the purpose for stat variable is to be accessed outside of current subroutine, but when you access from outside, the format becomes DBx.DBXxxx.xxx again. If I use an external variable, I have more flexibilities.

So, I still can't have that - what's the benefit using FB? (Except using SFB)

The instance data of the FB is ment to be manipulated only by the FB itself.
You can exchange data by its interface.
 

Similar Topics

Hello I have a s7-1200 and I would like to read the tags present in this controller with my controllogix controller. The two controllers don't use...
Replies
4
Views
71
Hi need help why this “failure 5 emergency stop “ appears at every startup in the morning ? Have to shut off main switch at least 10 times on...
Replies
19
Views
272
i have two plc 1. s7-1212dc/dc/dc ip; 192.168.0.1 2. s7-1500 1513-1pn ip; 192.168.3.2 i need to get data from plc1 to plc2. any idea how to do...
Replies
5
Views
94
Hi everyone hope you'll well. Is it possible for me to download a Crack version of tia portal v13..sorry to say this but the software is very...
Replies
5
Views
190
I have established an online connection to a machine using an S314 processor. I am using an mpi connector and simatic manager. The online...
Replies
11
Views
197
Back
Top Bottom