compare bool arrays

nikk4s
2017-03-20
2017-03-21
  • nikk4s - 2017-03-20

    I have 2 bool arrays
    key_alarms: ARRAY[0..0] OF ARRAY[0..15] OF bool;
    no_alarms: ARRAY[0..0] OF ARRAY[0..15] OF bool;
    no_alarms is an empty array -all false or all 0's
    I would like to compare that if any bool of key_alarms is high/true/1, set another bit.
    I have tried GT and NE functions with these 2 arrays as inputs and receive an error as below.

               ------ Build started: Application: Device.Application -------
                typify code ...
    

    [ERROR] garagepi: key_faults Device: PLC Logic: Application: C0068: Compare not possible on objects of type 'ARRAY [0..0] OF ARRAY [0..15] OF BOOL'

    What function would allow me to compare these 2 arrays of inputs within a ladder program?

     
  • rickj - 2017-03-20

    Correct declaration of bool array may help.

    key_alarms: ARRAY[0..15] OF bool;
    no_alarms: ARRAY[0..15] OF bool;
    
     
  • nikk4s - 2017-03-21

    rjafrate hat geschrieben:
    Correct declaration of bool array may help.

    key_alarms: ARRAY[0..15] OF bool;
    no_alarms: ARRAY[0..15] OF bool;
    

    I declared as you said. Still have the same issue. In logix I think this is a file bit compare FBC function. Cannot seem to find the similar functiion for codesys.

     
  • Anonymous - 2017-03-21

    Originally created by: scott_cunningham

    A BOOL is not a BIT (BOOLs in CoDeSys are byte-sized by default). So you are really trying to compare a structure (a chunk of bytes). IF Struct1 = Struct2 will not work - you cannot also do Struct1 := Struct2. You have to compare each element. Your hardware source or the system libraries should have a function (for copy, I know there is a SysMemCopy or something like that). Sorry, I am not in front of my PC, so I cannot give you the exact item.

     
  • nikk4s - 2017-03-21

    Thank you. I changed array[0..15] of Bool to array[0..0] of INT. These I can compare with math operators.

     

Log in to post a comment.