Welcome to our new forum
All users of the legacy CODESYS Forums, please create a new account at account.codesys.com. But make sure to use the same E-Mail address as in the old Forum. Then your posts will be matched. Close

How to call a function block from within CFC

dovecosa
2015-04-15
2015-04-16
  • dovecosa - 2015-04-15

    Hello everybody, I've read many documentation and I've searched the forum, but I'm not able to find out how and IF is possible to call a user FB or a user program form CFC.

    I've 4 pumps starting by 4 different levels, whe the fourth pump has started it has to run until the 3rd level switchs off, but the pump that is to be stopped is the first runned, in order to balance the usage time.

    More than this I've 5 total pumps, and I've to manage which one has to be set as spare, considering the spare always different at any new cycle starting with level 0.

    The rotation works with 1 and 2 pumps, but when the third pump starts, emptying the tank till level 2, TWO pumps stop (because only I remind the last started.

    Not willing to consider 155 different possible conditions (binary 31 for all pumps available an 5 different levels), I think that with ladder I could get crazy before get to and end, I'm trying with CFC (but I'm not a guru with).

    My question is: can I call an external user FB or user program from CFC, and if the answer is yes... HOW???
    I hadn't found any example about this, nor I've found any info within the CFC manual.

    The goal would be to evaluate the total amount of running pumps, in order to quit stopping them when the number is below three.

    Mind that the same problem would be considered with 4 running pumps...

    Thank U for any possible suggestion. I hope I made myself clear...

    Enjoy your life...

     
  • Anonymous - 2015-04-15

    Originally created by: scott_cunningham

    I believe CFC calls all blocks in the defined order. I think your only option would be to add an EN input to your FB and then in your FB, you can decide if you need to run the code or not based on the EN input.

    Or you could use ST instead - it has the most flexibility and can handle special situations (IF this AND this OR that do this unless this has happened... etc). In my opinion, LD and CFC are good for repeating the same xx steps over and over and becomes more complicated the more special situations you have to handle.

    Alternatively, maybe you should think about separating your control from the "real pumps". I mean you could have block 1 always be the master pump, block 2 is second, block 5 is spare. But these blocks only provide control outputs. In a separate code block, you can link block 1 to pump 1 or pump 2 or pump 3... based on the hours of use. Maybe this simplifies your CFC block and you add another piece of code that shifts the control to real world pump assignment.

     
  • RolandWagner

    RolandWagner - 2015-04-16

    Zitat:
    My question is: can I call an external user FB or user program from CFC, and if the answer is yes... HOW???
    I hadn't found any example about this, nor I've found any info within the CFC manual.

    Please see the attached screenshot.

    In words: You just take an element "Box" from the tool box and position it into the CFC editor. Then you choose the FB you want to call and define an FB instance for it. That is all.

    IMG: CFC_FB_Call.png

     

Log in to post a comment.