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

POUs for Implicit Checks in library

tvm
2018-01-02
2018-06-06
  • tvm - 2018-01-02

    I have a library which contains a function block with some math formulas in it. I still get division by 0 exceptions, even though I have the "CheckDivReal" implicit check function installed. CheckDivReal is called if I divide two numbers in a normal POU, but if it's within a function block from the library, it is not called. I guess that makes sense because the library can't see the functions in my project, but it doesn't seem to be possible to install the implicit check function blocks in a library. Is there a way to do this?

    thanks

    Tim

     
  • eschwellinger

    eschwellinger - 2018-01-02

    Hi,
    you could only check libs in library format/source available not compiled libs.
    To do this you need to set the compiler define:
    checks_in_libs
    in your application.

    BR
    Edwin

     
  • kurvanov - 2018-06-06

    Good morning,

    I'd like to use CheckBounds for improving reliability of my library.
    I'm using Codesys V3.5SP10 Patch3

    I have inserted the compiler define checks_in_libs in my main application.
    The program aCheck of the attached library is supposed to cause the call to checkBounds function.

    I have set some breakpoints at line 3 & 5 of the generated CheckBounds function.
    When I run my application, the PLC does not call the checkBounds function.

    I don't understand what I'm doing wrong.

    Although this is a very basic use case, I cannot attach library and project code because of limited file size. Herewith the code:
    Checks.library

    PROGRAM aChecks
    VAR
        iIndex       :    INT;
        astInst      :    ARRAY [1..5] OF INT := [5(101)];
    END_VAR
    FOR iIndex := 0 TO 5 DO
       astInst[iIndex] := 234;
    END_FOR
    

    untitled1.project

    PROGRAM PLC_PRG
    VAR
        xActivate    :    BOOL;
        totot: INT;
    END_VAR
    {define checks_in_libs}
    {IF defined(checks_in_libs) }
    totot := 55;
    {ELSE}
    totot := 77;
    {END_IF}
    IF xActivate THEN
       xActivate := FALSE;
       AAA.aChecks();
    END_IF
    FUNCTION CheckBounds : DINT
    VAR_INPUT
       index, lower, upper: DINT;
    END_VAR
    // Implicitly generated code : Only an Implementation suggestion
    IF  index < lower THEN
       CheckBounds := lower;      // line 3
    ELSIF  index > upper THEN
       CheckBounds := upper;      // line 5
    ELSE  
       CheckBounds := index;
    END_IF
    

    Any help will be appreciated.

    I.kurvanov

     

Log in to post a comment.