poovs

Should I Use Function Blocks?

32 posts in this topic

I have tried them and am not a fan. Having said that they would be great for complex maths and some other routines that could be written in ST - of that I am convinced. For most of my stuff (fairly simple alarm routines etc) I have gone back to good old ladder. FBs take to long to develop and have too many restrictions for me. Also take too long to program - I can do it quicker with the keyboard. I made a huge mistake as well - gave each instance a sensible name to save documantation time - ran out of FB memory in the PLC! dang, had to write all my alarm routines again (in ladder). Lost hours. Won't do that again.

Share this post


Link to post
Share on other sites
Well since i have the Ladder writen and tested on 2 different sites all i've done is just chop out the maths/compare instrustions and stick them into an FB which makes much more sense. i was just abit worried on how to build them but they are so simple to compile if you have tried and tested software! now i'm on the hunt for other parts of the program i can "compress", plus then save me some time on HMI programming by cutting down the screens i have.

Share this post


Link to post
Share on other sites
I have a love / hate relationship with function blocks. In my experience: function blocks are good for: 1. math (conversions, scaling, floating point math, etc.) 2. loops (I find it much easier to code loops in structured text) 3. repetitive tasks such as door logic, cylinder logic, stopper logic, etc. function blocks are bad because: 1. takes a lot of memory 2. adds scan time 3. hard to troubleshoot if you don't know how the FB works 4. more work up front to test and document 5. can be dangerous if you try to online edit and 'accidentally' change all instances of the block

Share this post


Link to post
Share on other sites
One other option if you do not want to use Function Blocks is to use the Address Incremental Copy function. This can be found under the Edit pulldown in newer versions of CX-Programmer. It allows you to create some code and then copy it a specified number of times. You can specify the amount to increment per address in the code. It is really a useful function when you are trying to do large chunks of repeating code. I am not sure which version of CX-Programmer this was added. Edited by Michael Walsh

Share this post


Link to post
Share on other sites
Yeah!! What a great idea that was. I use it regularly for repeat code.

Share this post


Link to post
Share on other sites

Could not download the file Simple_For_Next_Loop_Example.cxp mentioned in above conversation. How to download this file?

Share this post


Link to post
Share on other sites
On 11/12/2018 at 9:54 PM, Haveri said:

Could not download the file Simple_For_Next_Loop_Example.cxp mentioned in above conversation. How to download this file?

@Haveri I have fixed the link, you should be able to get it now.

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now