How Could FB and FC Make Me Professional PLC Programmer?

Siemens, one of the best Automation vendors all over the world for many reasons and over long decades, Today we are going to deal with its software platform which is called TIA Portal (Totally Integrated Automation).

This software is the leading one that used in Europe as it’s reliable, very easy to use and one of the best features in this software that is combined between every Automation components that can be used by siemens (PLCs, Drives, HMI….), So you can commission and program all your project with just one software.

Structural Programming VS Linear Programming

In the Automation world there are two methods of programming Linear programming which, we can call it as basic programming, and structural programming or advanced one.

It’s really important to know that any PLC programmer can use the two methods to operate or program any plant or function, but for advanced programmers, it’s not the only problem for them “that the mission is accomplished or not”, but the big point that “How The Mission Accomplished” advanced programmers do not focus just on finishing the project but they are also considering about:

•   Does my code is really unique and organized?

•   Avoiding repeated and boring programming.

•   The sequence of the code.

•   Does my code help the PLC itself to operate with all of its power?

•   If we are back again, is it easy to modify?

So, organizing the code is very important for such DCS systems or other complex plants or systems, I just want to say please please Do NOT REFLECT THE COMPLEXITY OF THE PLANT INTO YOUR CODE.

Simply now I can say that is why we are using FB and FC into our code just for simplicity and organizing our codes, FB and FC can sorting your long project also can help you with repeated routines.

Think of that you have a plant that has 100 motor what is easier for you to write 100 coding programs to control these motors or just you can Write one code into a function and call it 100 times, think of it ….

The Difference Between FB & FC

How Could FB and FC Make Me Professional PLC Programmer

It sounds that the difference between function and function block seems to be slightly simple, but it’s never as simple as you imagine, the only notable difference is that Functions has not Static Memory to save its data.

So when you call it you will not need data block for each function that you have called, unlike function blocks it has a static memory inside, so for each time you call it you will need its instance data block to be attached with it.

Simply FC does not have memory block while FB requires instance Data Block for execution…. During every cycle FC loss its contents while the FB gets its memory to its associated block… So, if the idea is not clear for you till now this example would really help you.

Example

We are in a project that has multiple Level sensors that operate and control the action of our motors and conveyors.

Note that in a real field the level sensor reading might be stuck for just a few milliseconds and come live again after some brief interval.

Again, that is happened due to some field issues and there are some critical sensors that we could not allow that to happen with, so we need to make a delayed reaction to ensure that is the real level signal.

We can do that with timer but with a lot of level switches you will consume with every switch a separate timer from your plc, and that is really not professional way to deal with such a problem.

So here we can use a function that can make for us that delay and call it with every switch to allow a path for these switches through the same function to make your desired process (delay).

Example Function Program: Click Here

Example Call Program: Click Here

In the above example, the function logic is named “ONDLY-TMR” which is a timer program that provides some time delay wherever we use it.

In call program, we have different networks for level switches and motors. We call the function “ONDLY-TMR” in each network to provide the required time delay.

Note that for this situation you do not need any variable data to be stored, it’s just a delay that can be made easily without the need for static memory so here we can use FC.

Another usage of the FC is just for organizing the project and collecting similar instruction together to make your project tidy and easy to follow and troubleshoot your program

In the other hand we have a project that contain TANK FARM, this tank farm consists of eight tanks each tank has four mixers, three level switches, some of temperature transmitter and some valves.

The process might be complex but it’s really complex for just one tank and this process is just repeated, so my process for any tank must have some memory I really need some space for each tank in the memory to save some desired data such as (Tank Temp – Level – Valves state …).

So here I can not use FC because it does not support me with Separated memory for each tank, and if I made that with FC 100% there would be data conflict between tanks, here is the power of FB, I can make one FB and program it with the desired sequence then I will call it with every tank to allow a path for these tanks through the FB and also each tank will have its own data stored in its own data block (Instance Data Block)

I really hope that you got it ….

Summary

Now after you got the idea, we can summarize that with a little point

  • FC used to organize your program and to make it tidy
  • FC and FB used to save your effort for repeated coding
  • FC do not have the access to save your data in separate memory for each call, it losses its data every scan cycle
  • To call a function block you will need to tight with-it data block for each calling as it can store and separate data for each time you call it.

Finally, you will never get 100% of understanding till you try something by your self so please try to make it on your TIA and feel free to send me back to discuss that.

If you liked this article, then please subscribe to our YouTube Channel for PLC and SCADA video tutorials.

You can also follow us on Facebook and Twitter to receive daily updates.

Read Next:

Don't Miss Our Updates
Be the first to get exclusive content straight to your email.
We promise not to spam you. You can unsubscribe at any time.
Invalid email address

Leave a Comment