Function Block Programming

BobB

Lifetime Supporting Member
Join Date
Jun 2002
Location
Sydney
Posts
4,557
I am just venturing into FB programming. What a pain in the proverbial "A". Have played around with ST and ladder. Do not want to go there any more. The Europeans are crazy going for this stuff!!!

Maybe I am old fashioned but quite frankly I cannot be bothered with this nonsense anymore.

Refer to an ongoing topic on this forum about ST, STL etc. Painful quite frankly. Can do it quicker and easier in ladder. Will put a comment on the other topic as well. Guess it depends on the brand of PLC and software you use.

LADDER FOR EVER WITH A PLC WITH LOTS OF FUNCTIONS!!!!!
 
Sorry Bob , maybe I misunderstand you , but I find FB to be one of the most tidy and neat ways of programming repetitive tasks , once tested , no need to check again - and a very small increase in initial labour to produce the block . For S7 I now have a huge library of every sort of block , and programming is a joy .
Sometimes people substitute dislike for a failure to understand . take the trouble to stick with it , it is not all bad !!
 
Unregistered said:
Sorry Bob , maybe I misunderstand you , but I find FB to be one of the most tidy and neat ways of programming repetitive tasks , once tested , no need to check again - and a very small increase in initial labour to produce the block .

I have used a couple of PLC's with FB's in ladder (Modicon and Indramat). I really miss them when I have to use something else. The FB's in both of those cases had ladder inside them. The maintenance guys who saw them, understood them really easy.

The inputs were just ladder rungs, too.

We make machines with a lot of the same components at each station, so FB's are really useful. The big problem with cut and past is that if you have a typo or want to change the logic, you have to do each repetition. With FB's you only have to make one change.

"The wonderful thing about computers is that they let you repeat the same mistake and infinite number of times."-ME
 
Function blocks have their place, especially with instructions that require multiple inputs. Its much easier to set up an enhanced PID, or a LEAD/LAG, for example in FB rather than a couple of dozen MOV rungs just to get the data in place before you can ever execute the function.

Being an old C progrmmer, I think I more naturally gravitate towards ST. But thats because I understand it. By comparrison ladder is tedious for some things. For example, you want to turn on output1 if input1 is on, and output2 if input2 is false. That takes two rungs in ladder, two seperate tests on the condtion of input1. In ST you make only one test on the status of input1 with a IF-THEN-ELSE statement. Thats a simple example but you get the idea. ST also lets you skip all the intermediate result storage steps in complex calculations.
 
I have a function to perform where I use a DIFF UP from a pushbutton to open a motorised circuit breaker with a trip coil if it is closed. Then close it if it is open. The trip coil is easy but the motorised closure signal has to be held on for some time using a pair of timers and retries that are counted in a counter to allow the motor time to close the breaker. If the brekaer does not close after 3 tries, stop trying.

There is a fair bit of interlocking etc as you can imagine. I fiddled around for quite a while with an FB and finally got it right after about 20 minutes. Wrote the same thing in ladder (only 1 rung) in 3 minutes.

I can see it would be excellent for repetative tasks but I rarely have repetative tasks. Nearly all my code is individual stuff. Every job is quite different.

I do a lot of generator work and even the alarm routines are different. However, there are a number of alarms each time that are the same so I could use it there.

By the way, a lot depends on the PLC one uses. With Siemens for example, you have to basically have a separate rung for each output. I use Omron and there is practically no limit on a rung. I can have 20 outputs in the one rung if I wish with individual conditions in each output line, plus a load of timers, counters, compares etc etc. Some of my rungs would need between 10 and 20 rungs in a Siemens PLC.

I guess I will perservere for some tasks but I cannot see any benefit for most of my software as so much of it is individually written for each job.

I can certainly see a benifit for YD starter control for example. However, a decision has been taken to use soft start/stop in future so there will be no more YD starters in my jobs.

I guess the other thing is the re-usable code situation. I have been able to have re-usable code files in ladder with Omron PLCs for some years now so it has not been an issue. Just insert the file and change the I/O numbers, as with FB.

The other thing I find with a lot of European software is that ladder is the poor cousin. The ladder tools are pretty poor in Siemens, Modicon Unity etc. They appear to be an after thought rather than serious programming tools. Omron and AB have serious ladder tools due to their background.

I challenged a Schneider rep, who works for their systems integration division in Ozz, to get out his laptop and I would give him a race to program 20 different alarm routines. The routines were already hand written on sheets of paper and only had to be punched in to the software. I used Omron CX-Programmer and he used Unity. I beat the heck out of him by quite some time. Have not seen him since.

Will keep trying but without many repetative tasks and very little software that I can transfer from job to job, I think it will not be of much use to me really. The biggest benefit I see for me at this stage is that the FB takes up a lot less room on the screen than a large ladder rung.

but I find FB to be one of the most tidy and neat ways of programming repetitive tasks , once tested , no need to check again

We make machines with a lot of the same components at each station, so FB's are really useful. The big problem with cut and past is that if you have a typo or want to change the logic, you have to do each repetition. With FB's you only have to make one change.

Fully agree with both of you but not much use to me.

Sometimes people substitute dislike for a failure to understand

Do not have that problem at all. Quite happy writing code in ST - write Cicode in Citect all the time.

Function blocks have their place, especially with instructions that require multiple inputs. Its much easier to set up an enhanced PID, or a LEAD/LAG, for example in FB rather than a couple of dozen MOV rungs just to get the data in place before you can ever execute the function.

Fully agree there also. Hardly ever use PID control for example. Lead/lag for pumps etc I have re-usable ladder code anyway. Re-usable code files are one of the strengths of Omron CX-Programmer ladder editor. For the number of times I use lead/lag pump control (once per job) re-usable ladder files are fine but I will probably migrate them to FB in the near future as that is one place I can use it.

One of the other things I find a bit painful is that most of the software today is symbol based and defaults to symbol. One of the things I wish Omron would do with their software is to put in a switch to default to I/O number based so that one can turn symbol based off. I guess that is what I use all the time due to my evolution path as a programmer/systems integrator. Omron PLC software does not and never has required the insertion of %I, %Q etc, just a number. I find this so much easier and quicker that it is not funny. For example, input 2001.03 is just typed into the input instruction as 200103 - no % or I or X or anything else. I am quite used to working with just numbers and find having to type in anything else slows me down considerably quite frankly.

You can teach an old dog new tricks. I am always looking for quicker and easier ways to write code as my time is to precious to waste. I am sure if I had a lot of re-usable code situations I would very quickly become a convert but it is only useful if it saves time and makes life easier, as it has for very many of you. Wish it could for me.
 
Rick Densing said:
The big problem with cut and past is that if you have a typo or want to change the logic, you have to do each repetition.
Ironic... :D

I like function block for some things, ladder for others, and structured text for still more things. The best software for me integrates all three well enough to give me the CHOICE as to which I want to use for what task.

Right now, my biggest time saver is that I have function blocks written in ladder. I can call them over and over from a main FBD routine, and every instance is going to act exactly like the others. The main FBD routine is basically just a cute way for the customer to see his I/O plugged into a function that he understands. Of course, I need to test each ladder routine to make sure it does exactly what I want.

AK
 
The other thing I find with a lot of European software is that ladder is the poor cousin. The ladder tools are pretty poor in Siemens, Modicon Unity etc. They appear to be an after thought rather than serious programming tools. Omron and AB have serious ladder tools due to their background.
Right now I'm doing a CLX RSLogix5000 project and a Modicon Unity one. The CLX job is reasonably major and I budgeted about 8 weeks work. Its has been mostly done and paid for in six weeks. Made a buck on that one.

The Unity job I budgeted 4 weeks work. Well I've attended the 4 day training course at my own cost, re-written bits of it over and again, and at six weeks I've still to get onto the HMI and I'm behind delivery with the client.I'm going to take a bath on this one.

Everything has been a battle. Even late last night I wasted about two hours before determining the very basic piece of code I was struggling to run on the built-in simulator was failing because the simulator doesn't emulate the "First Scan Bit" properly. Dreadfully basic flaws. I could go on and on. It seems a peculiar mix of quite sophisiticated in some places, and 20 years out of date in others, and this keeps throwing me off balance.

And one of the reasons why your Modicon rep was so slow is that Unity is a dreadful resource hog that takes 10's of seconds to do simple things that RSLogix does in seconds. Just asking to FBD Input Assistant to go and find the TON block can take 10-15 seconds on my Tecra. (1.6 GHz/512MB P4M). Saving the project, another 20 secs, re-building it, another 20-30 secs. Copying built FB's in and out of the Types Library is "go make a cup of coffee" time. Apparently complete re-builds on large projects take anything up to 10-15 minutes.

And if anyone thought that CLX gobbles up PLC memory, this Unity is absolutely gluttonous. My simple little pump bore pump controls, (the simplest I have ever written) are gobbling up over 120kBytes of memory.

It does one or two things well. When you edit the name of a member of a Structure, it propagates through all the code. This is quite nice if you use it properly. On the other hand you cannot just "Move Up/Down" a member in the structure. It has to be deleted and re-entered where you want it.

I anticipated a learning curve, and I've tried not to vent about it, but the Ladder editor in this software is SO bad I've just given up on it and I started just writing stuff in ST even though I know the client will not be able to support it. If the major European vendors keep doing programming software with ladder editors this bad, one can only surmise that they are WANTING to it kill off.
 
For example, you want to turn on output1 if input1 is on, and output2 if input2 is false. That takes two rungs in ladder, two seperate tests on the condtion of input1.
Tell the truth I do not have a clue about this topic in general but the above statement really has me confused.

input 1 output1
|----| |---+----------( )---|
| |
| input2 output2|
|--|/|-----( )---|


Is this considered 2 rungs? Is this what was stated? I also dont understand what you mean by separate tests, seems to me that no matter what language you use the plc has to "know" the condition of inputs before it can act on the outputs, if there is an AND involved it will always be 2 "tests".

Am I thinking too lateral?
 
Right now I'm doing a CLX RSLogix5000 project and a Modicon Unity one. The CLX job is reasonably major and I budgeted about 8 weeks work. Its has been mostly done and paid for in six weeks. Made a buck on that one.

The Unity job I budgeted 4 weeks work. Well I've attended the 4 day training course at my own cost, re-written bits of it over and again, and at six weeks I've still to get onto the HMI and I'm behind delivery with the client.I'm going to take a bath on this one.

Philip, this is getting monotonous. We agree again. Wow!!! But seriously Unity really is aweful. So is Siemens software.

You talk about memory hogs, try the Siemens stuff. It will kill your laptop stone dead. It kills my desktop and it is beast. Lots of horse power, 2 gig RAM, rocket ship nVidia display card - the works.

With Omron CX-Programmer I have a whole power station - 9 PLCs with remote I/O, networking, the lot including comments and symbols stored in a file only 351 kB in size. It takes a little while to load as the whole thing is stored in machine code and has to be decoded. Once loaded it runs very well on the desktop and the laptop with comms at 115kB to the PLC through a standard serial port. It is very efficient. I can store all my projects from the last 15 years on 1 USB drive of 256 meg with room to spare as well as run the PLC sofware very efficiently on a laptop with XP Pro O/S and only 512 meg RAM. By the way, the ladder and symbol printout for the power station program is just on a full box of US fanfold paper - all 1500 pages. That is without cross reference printout.
 
All software is potentially horrible until you get your head round it - agreed AB stuff is very easy to get something out of with no knowledge (should be a positive boon for some people) , but don't be too hard on S7 , I find it remarkably quick , and I am used to the old stuff like Omron LSS and SSS ,(remember the lack of a TON or was it a TOF ?) .
I agree sometimes that software can appear to be very complicated , but like Omron , once you learn those tricks , even you may come to appreciate S7
 
All software is potentially horrible until you get your head round it
Unreg...I am very aware that is true. But six weeks later and I am still finding horrible bugs in this Unity stuff. I wish it were not so. It is 1:00am Monday morning here in NZ and I am STILL banging away at it in an effort to catchup lost time and look like I have made some progress when I hit site tommorrow.
 
and I am used to the old stuff like Omron LSS and SSS
That was pretty horrible stuff. I chose to use CAPS which was far easier to use and had the best online monitoring tools I have EVER seen in PLC software.

I must admit I got caught with Siemens first attempt at Windows software. It had 2 programs running an "online" program which was only any good for monitoring and an "offline" program where any "online" program changes were made. By the time one returned to the "online" program it had all happened and obviously there was no way of instantly seeing the result of one's program changes.

Even worse the whole program was downloaded to the PLC when changes were made! SCARY!!!!

No more online changes with that stuff - I was working on 2 live 11kV generators at Brisbane Hospital complete with earth switches, load shed control - the whole lot. Made sure I stopped the generators and downloaded fresh without anything running.

I would imagine their Windows software has been improved somewhat since then. I have not had to use Siemens since. The early Hitachi software must have come from the same software house as it behaved in exactly the same way. Never used it again either.
 
rsdoran said:
Tell the truth I do not have a clue about this topic in general but the above statement really has me confused.

input 1 output1
|----| |---+----------( )---|
| |
| input2 output2|
|--|/|-----( )---|


Is this considered 2 rungs? Is this what was stated? I also dont understand what you mean by separate tests, seems to me that no matter what language you use the plc has to "know" the condition of inputs before it can act on the outputs, if there is an AND involved it will always be 2 "tests".

Am I thinking too lateral?

Looks like I botched that one. I meant to say, output1 is on if input1 is true and output2 is on if input1 is false.
That takes two rungs.

input1 output1
|-----] [-------------( )
|
| input1 output2
|-----]/[-------------( )



Is ST its more like: IF input1 then ouput1 else output2.
A single test on the state if input1.

This is a simple example, but there have been times when the logic inversion has been more complex, but hopefully it conveys how LL can get tedious if you extrapolate a bit.
 
I understand your point, Alaric, but your example could indeed be done in one rung, assuming the PLC has an OUT NOT instruction:

input1 output1
|-----] [-------+-----( )
|
| output2
+-----(/)


I personally don't like (and never use) OUT NOTs though and would do it in two rungs as you have shown for clarity.

🍻

-Eric
 
I personally don't like (and never use) OUT NOTs

I do use them for signals to BMS systems and the like so that if the PLC goes off line the BMS system gets a fault signal. Also use them on generator jobs so that if the "open ACB" relay fails or the PLC goes off line, the ACB will open and not leave a stopped generator on line.

I would write that code in ladder as

always on input 1 output 1
|-------][--------] [---------()
| input 1 output 2
|----]/[--------()



Only 1 rung.
 
Last edited:

Similar Topics

I have not used function blocks much in Studio 5000. Could someone tell me the advantages compared to the dis-advantages.
Replies
2
Views
1,424
We have a trainer set up and I am trying to learn function block programming to reinforce my resume. In ladder I am pretty fast. I double click...
Replies
0
Views
2,081
I am new to function block programming and would like to know how to change setpoints for say HiLimit, LoLimit, etc. I am using RSLogix 5000
Replies
3
Views
1,905
Hi, I'm programming a Micro830 PLC and Function Block Diagram using Connected Components Workbench. I'm trying to output a analog input that has...
Replies
3
Views
3,809
Looking for some help programming a yaskawa multi axis controller. Model MP2300 SEic Need some help setting up the encoder for positioning. 1000...
Replies
3
Views
2,427
Back
Top Bottom