First Out for more than 16 Alarms

How I can calculate First Our for more than 16 Alarms?

6 Replies

  • It is possible to use several BF blocksI, for instance two BFI (BFI1 and BFI2) in parallel to receive up to 32 inputs. Then BFI1 and BFI2 OUT_D should be conected to a third BFI (BFI3) IN_D1 and IN_D2 inputs respectively.

    BFI3 tells if BFI1 or BFI2 OUT_D became active first. Then, BFI1 has first out of 1 to 16 conditions and BFI2 has first out of 17 to 32.

    With that info a calc block can be used to provide first out of 1 to 32 conditions. The trick is to use LOG2 funtion in calc block:

    Having

    - BFI3 FIRST_OUT conected to CALC IN1  (conditions group first_out)

    - BFI1 FIRST_OUT conected to CALC IN2  (conditions 1 to 16 first_out)

    - BFI2 FIRST_OUT conected to CALC IN3 (conditions 17 to 32 first_out)

    Expresion providing 1 to 32 condition first out into CALC block OUT2 will be:

    out2:=(in1=1) ? (log2(2,in2)+1):(in1=2) ? (log2(2,in3)+17):-1;

    NOTE: When more than one condition becomes active at same time(same scan cycle) not first out is calculated, a -1 value is set instead.

     

    This can be extended to 16 inputs of BFI3, just adding more BFI blocks and changing CALC expression; giving a maximim of 16*16=256 conditions.

     Regards

     

  • In reply to gamella:

    Hi Gamella,
    I'm also interested in this solution. I tried and it works for the first 8 bits (for both BFI), but from 9 to 16 (or 25 to 32 in BFI2) it doesn't work.
  • In reply to Samuel Bandeira:

    It works for me, including  9 to 16 and 25 to 32 conditions.

     

    Regards

  • In reply to gamella:

    Sorry Gamella, my bad. I made a mistake, instead of connecting BFI1/OUT_D (and BFI2) into BFI3/IN_D1 (and IN_D2) I used FIRST_OUT. Now it works fine.
  • In reply to gamella:

    This is a very old post, so I am not sure if this question will be seen. The code works for the most part, but if more than one condition occurs on a BF1 block, I can't seem to get the -1 value for my result. Any suggestions on how to make this part work?

    From original post:
    out2:=(in1=1) ? (log2(2,in2)+1):(in1=2) ? (log2(2,in3)+17):-1;

    NOTE: When more than one condition becomes active at same time(same scan cycle) not first out is calculated, a -1 value is set instead.
  • In reply to Greg Bayne:

    based on the description, -1 will only appear when BFI1/FIRST_OUT and BFI2/FIRST_OUT are both non zero. when multiple conditions in a BFI/FIRST_OUT are set (e.g. BFI1/FIRST_OUT = 12), out2 will include decimal places that are non zero. seems like a truncation, integer division, or passing into an integer parameter may be missing or is taking place outside the calc block if the intent is to only indicate 1 condition as the first out.

    I read the OP's question differently: I thought they were asking how to trap a first out pattern from multiple BFIs, not determine which condition number was first out. this would be done differently:
    1) if all FIRST_OUTS are zero, clear the holding parameters and the "trap" flag.
    2) else If the combined first out has not been trapped yet, copy the BFI FIRST_OUTs to holding parameters and set the "trap" flag

    If the intent is combining two BFIs into one 32 integer FIRST_OUT32:
    1) If both FIRST_OUTs are zero, clear FIRST_OUT32
    2) else if FIRST_OUT32 is zero, set a variable to the second BFI FIRST_OUT value, bit shift it over 16 places, add the first BFI FIRST_OUT value, and then store the result in FIRST_OUT32.

    I didn't code them up, but I hope you find this helpful