Largest 5 values from set of Values

Hi, 

Currently i am working on college project, where i am getting 30  field values as input signals for DeltaV.

I want to compare those 30 values and get 5 largest values from those 30 values.

Is there any standard block which can help me to get the above mentioned results.

I know Calc block can help but i am not good with the coding.

Please kindly let me know in case if someone can help.

Thank you for your help and time. 

  • In reply to Ashish P:

    Very Close... Here is my suggestion:

    IF IN1 = 1 THEN

    I:= 1 (* Initialize I *) 

       I := '^/I.CV' + 1 ;

       J := '^/J.CV' + 1 ; (* Not Yet *)

       RANK := 16; (*Not Yet *)

    WHILE I <= 16 DO

             RANK := 16

             J := 1 (* Initialize J *)

      WHILE J <= 16 DO

    IF I <> J  (* Don't compare value against itself *)

      IF '^/FEILD_VALUE'Idea[1] >= '^/FEILD_VALUE'[J][1] THEN (* or equal to *)

    RANK := RANK-1

            END_IF;

    END_IF (*close the IF I added *)

                      J := J+1;

      END_WHILE;

            '^/FEILD_VALUE'Idea[2] := RANK;

                      I := I+1;

    END_WHILE ;

    ENDIF;

    The only problem so far is that if 2 numbers are identical, then the following rank will not exist, i.e. if 2 numbers are ranked 3rd because they are identical, then there will be no 4th ranked number...there will be a fifth ranked number. 

    You can probably handle that in the presentation logic through looping as well. 

  • In reply to Youssef.El-Bahtimy:

    Many Thanks  Youssef.El-Bahtimy for your modifications. The above code worked.

    Just a slight modification at :

    IF I <> J THEN

    Otherwise code works perfect for all unequal values.

    I am working on that part now.

    Really appreciate a lot for all your help. Smile

    Thank you very much.