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

new to codesys - wrapping own code in a function block?

jupe
2006-02-01
2017-05-02
  • jupe - 2006-02-01

    Hi!

    Is it possible to write a control algorithm (or something) in e.g. c-language and then wrap it as a function block in codesys?

    BR,

    JuPe

     
  • RolandWagner

    RolandWagner - 2006-02-06

    Yes, in general you can link C code as so called external library.

    See the attached file for details.

    But please note that the device has to be prepared for that method. So you can try the described method, or in case it does not work, please contact your OEM.

    C_in_CoDeSys_e.pdf [91.04 KiB]

     
  • jupe - 2006-02-07

    How about hierarchical function blocks? Can I create a new function block as a composition of other (basic or composite) blocks? Can this be saved as a new block type or re-used in some other way?

    Best Regards,

    JuPe

     
  • RolandWagner

    RolandWagner - 2006-02-07

    Yes, of course, but with some limitation.

    In CoDeSys you can call existing function blocks (no matter whether they are developed in CoDeSys or C) and create new function blocks out of them. And you can save these new function blocks in libraries.

    In a C routine implemented as a function block in an external librariy you can of course call other C routines. But you cannot call another CoDeSys function blocks out of such a C routine.

    Typically spoken you will install a set of C routines within one (or several) external libraries as a kind of C layer. In CoDeSys you will include those libraries and access to the routines as function blocks, functions or programs and combine them together in POUs. These POUs can as well be saved as a library, but this time as an (internal) CoDeSys library. As soon as you open this new CoDeSys library the referenced external libraries will automatically included into the project (of course the directory settings have to fit).

     
  • cherblot - 2017-05-02

    Hi,

    Is this method also working in Codesys V3.x ?
    Or is it only possible in V2.3 ?

    thank you.

     

Log in to post a comment.