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.
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
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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).
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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
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]
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
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).
Hi,
Is this method also working in Codesys V3.x ?
Or is it only possible in V2.3 ?
thank you.