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

making library using external c code

audi0615
2020-03-19
2020-03-20
  • audi0615 - 2020-03-19

    Hi.

    I'm trying to make an external library using my own c code.
    i've found some documents about this.

    https://forge.codesys.com/forum/en/448/genmed-Creating%20own%20Runtime%20System%20Components%20and%20IO%20Drivers%20(v2.0).pdf

    https://support.crosscontrol.com/sites/default/files/documentation/Discontinued%20Products/Computers/CCpilot%20XS%2012/Documents/Creating%20and%20linking%20C%20library%20functions_IN_32Bit_E.pdf

    it seems that the external .c file is not included in codesys code but executed in the runtime system via generated m4 file.
    i found no issue in making the external library, however everytime i download a new project with the library to PLC, I get "unresolved reference" error.

    the first document above says, i would get "unresolved reference" error. but i don't understand what should i do to solve this error.

    "Now you can create a new project, add the new library to your application and call the internal and
    external functions and function blocks form the IEC code. If you download the application to a runtime
    system, you will receive errors because of unresolved external references. Unresolved external
    references appear, when there are calls to external POUs (must be implemented in the runtime),
    which are not implemented in the runtime. To solve these errors, you have to implement the POUs in
    the runtime system in your own component.
    "

    Do you have any idea what "To solve these errors, you have to implement the POUs in
    the runtime system in your own component" actually means?

     
  • eschwellinger

    eschwellinger - 2020-03-19

    Hi,
    one of these document is CODESYS V2.3 related.
    In all cases this is only possible if you have a runtime toolkit.
    https://www.codesys.com/products/codesys-runtime/runtime-toolkit.html
    This is not free of charge - this is the toolkit which the plc manufaturer purchase to create their CODESYS plc's.

    For which plc do you need this an what is the use case / function you want to archive with it?
    BR
    Edwin

     

    Last edit: eschwellinger 2020-03-19
  • audi0615 - 2020-03-19

    Thanks for the reply.

    My hardware is just a general industrial type PC, not from any PLC vendor.

    One of the use cases would be evaluating user input string math expression. (i.e. 3+(SIN(2+3)+5))

    It is very complicate to parse and evaluate this kind of string only with codesys.

    there are many C source codes can be used for this purpose.

    How can i purchase the runtime toolkit?

     
  • hence.persson - 2020-03-19

    Possible solution..

    Write a C-program using the shared memory functions with codesys.. Start the conversion of a string to a result with a bit and let the C program write it to the shared memory..

     
    πŸ‘
    2
    • audi0615 - 2020-03-20

      Thank you for your reply.
      the shared memory solution would be possible.

       

Log in to post a comment.