doubt on plc functional blocks

You can call FBs multiples times so you don't have to rewrite the same code again and again. You just need to change the input/output of the FB.

It's useful when, by exemple, in your application you have 10 pneumatic cylinders to command. You avoid writing 10 times the same thing.
 
FBs can be confusing to a newbie, but you will learn to love them. They are great for simplifying the code that you see. For example a timer just works. You don't really need to see the code inside a timer, but you can dig into it if you want to. Also, FBs all require a unique name (instance), so you could have timer1, timer2, timer3, etc. Each has its own values, but you don't have to write the code for it each time, just call the FB in your code. What language are you using? What PLC?
 
Timers are a bad choice for using as an example I think - depends on the PLC I guess. For common timers I just use copy and paste with increment - increment does just that with timer numbers and I/O numbers as well if you wish. Makes programming really fast.

There is a good thread running here about ST as well - have a look.

I do use FBs but rarely - quicker to use ladder for me and I do not have to stop the PLC to change/alter or modify function blocks because a contact comes in the other way around. I just simply put a slash through it in ladder and it goes from N/O to N/C that simply. With FBs you need another FB for that! Bugger!
 
Bob
you only need to negate the input to the function block
you do not need to change the function block at all
 
Will try it next time Geoff - had not tried that.By the way, finished a job a bit back with the M580 - auto allocation of a huge Modbus name for digital I/O - you cannot type in %I1.1.16 and then a symbol for this one - you have to remap the I/O to give them a symbol and description. Hopefully they will fix it - crazy idea. Latest software version - you can still type in for the M340 though. Few other quirks as well with remote I/O - proved to be a bit of a challenge.
 
I think that "function block" means something differently depending on which PLC.

In Siemens a function block is a reusable code block with memory associated with it for each call (= "instance").
I use FBs intensively with Siemens S7, and it is a huge productivity booster.
You can change the code of FBs online no problem. Changing the declaration part though may require that all instances are updated, which may be a problem on a running system.

I did also the copy-paste with PLCs that dont have reusable code (AB SLC500 and PLC5) before I switched to S7. Nothing was worse than having made 50 times copy-paste and then finding out that you have to make a modification of the copied code. And then later again maybe another modification. You get the idea.
 
FBs can be confusing to a newbie, but you will learn to love them. They are great for simplifying the code that you see. For example a timer just works. You don't really need to see the code inside a timer, but you can dig into it if you want to. Also, FBs all require a unique name (instance), so you could have timer1, timer2, timer3, etc. Each has its own values, but you don't have to write the code for it each time, just call the FB in your code.
I couldn't have said it better myself. Something else to point out is that in the CodeSys world there are Functions as well as Function Blocks. Timers and Counters are probably the most recognizable use of function blocks and math operations (add, subtract, multiply, etc.) are the most common use of functions.

Functions are simpler and do not require an instance declaration because they do not require any use of internal variables that retain their values from one program scan to the next. One way to think of a Function versus Function Block is that an output of a Function will always be the same with the same inputs. For example 2+2 always equals 4 in an Add function, but in a Function Block, inputs of 2 and 2 can equal 4 this time, but 5 another time.

Proper use of Function Blocks can truly make a program much easier to understand and maintain. Take for example a commonly re-occurring topic on here... the simple toggle. On the code snippet shown in the picture, compare rungs 1 and 2 versus rung 3. They both do the same thing, but consider how quickly you can figure out what each of these code snippets do if buried in a larger program.

ToggleCompare.png
 
My mate was with me Geoff and he uses Schneider every day of the week but the M340. He was the one who found the M580 is different and spoke to CK about it. CK confirmed. It may also only be the latest software version - not sure as the previous one I had for the M340 was quite old but functional and did what I wanted. He also has the same older version and has not seen a need to upgrade at huge expense as it does everything he wants. Then there is the DTM for remotes? Quite a change also. Interesting actually - has good and not so good but that appears to be the way these days.
 
Just keep in mind that most of these PLC system are maintained by NON-Programmers. When they get online to find a problem if they track an IO point back to a function block their going to get into a dead-zone they cant do anything about and will likely be calling YOU. Even if it's 3am.

As a programmer I see this stuff come out and it looks cool, but in reality who is going to be trouble-shooting it at 3am?

For this reason I always stick to plain old ladder logic. It's boring yes, but I don't get any 3am phone calls.
 
I agree wholeheartedly JaxGTO - bad news if a power station is shut down and no one can understand the software and soirt it out. My phone goes then anyway but I have always been able to sort it out over the phone with them. Wish they would put in a VPN for me or even slow old modem and either Norton's PcAnywhere or Team Viewer - usually paranoid IT people stop that in it's tracks!
 
Bob

Just for future reference it is possible to select standard topological addressing for an M580 (the setting shown defaults to DDT)

Capture.JPG
 
Interesting Geoff - CK did not tell us about that! They are trying to get me to go to a course but the courses are expensive and do not cover even close to what I want. They sent me an agenda - I would be there for 3 weeks and totally bored for 90% of that to get the info I require. This is the same with all the PLC manufacturers though - not just Schneider! Had to go to 4 courses with AB and 90% of it was totally useless to me - too basic. Cost me $6k! I would rather pay $5k for one on one for 2 days and get what I want - oh well! Probably never happen with any of them. By the way I work for myself and the money comes out of my pocket - the $$$$ spent have to be maximised with any training course for me - and then the lack of time because I am ridiculously busy? One on one is the only way for me really - not in a group where really basic stuff holds up the whole group because someone does has never programmed a PLC before - very frustrating!
 
Last edited:

Similar Topics

Questions about an old SAIA PLC type PLC is PCD4 - board RS422 (PCD7.F110) We sold a HMI to replace one but our HMI doesn´t communicate with the...
Replies
0
Views
1,089
Hello members, I have written a code for following program but my only doubt is about addressing of auxiliary contacts that are used for...
Replies
17
Views
4,298
Hi all, I am new to plc and new to here. I am learning PLC using the free software PSIM from learningpit.com. I want to clarify how this code...
Replies
2
Views
2,587
Hello guys, I am new to this plc programming(only 2 months), so help me out here, Can you tell me the how to use ladder logic for following...
Replies
2
Views
4,455
Dear friend Can anybody tell me what is the differenc between PLC and DCS(distributed control system).and what is the real meaning of...
Replies
6
Views
4,922
Back
Top Bottom