FP_DATA_SORT

Sort data in data table

This FP instruction sorts values (with +/- sign) in a data table in ascending or descending order.

주석

This instruction sorts 1-dimensional arrays only. It does not work with 2-dimensional or 3-dimensional arrays.

Parameters

Input

s1_Start (INT, DINT, UINT, UDINT, REAL, LREAL)

Starting area of data table to be sorted

s2_End (INT, DINT, UINT, UDINT, REAL, LREAL)

Ending area of data table to be sorted

s3_Control (INT, DINT, UINT, UDINT, REAL, LREAL)

Specifies sorting order:

  • 0 = ascending

  • 1 = descending

Remarks

  • The data are sorted via bubble sort in the order specified according to the value entered at input s3_Control. Since the number of word comparisons increases in proportion to the square of the number of words, the sorting process can take some time when there is a large number of words. When the address of the variable at input s1_Start = s2_End, no sorting takes place.

Error flags

sys_bIsOperationErrorHold (turns to TRUE and remains TRUE)
  • if the area specified using the index modifier exceeds the limit.

  • if the address of the variable at input s1_Start > s2_End

  • if s1_Start and s2_End belong to different data areas.

sys_bIsOperationErrorNonHold (turns to TRUE for one scan)
  • if the area specified using the index modifier exceeds the limit.

  • if the address of the variable at input s1_Start > s2_End

  • if s1_Start and s2_End belong to different data areas.

POU 헤더

이 펑션 프로그램 시 사용한 모든 입력과 출력 변수는 POU 헤더에서 선언되었습니다.모든 프로그래밍 언어에 같은 POU 헤더를 사용합니다.

	VAR
		bStart: BOOL:=FALSE;
			(*activates the function*)
		adiDataField: ARRAY [0..4] OF DINT:=[4,7,-32,13,5];
			(*result after a 0->1 leading
edge from start: [-32,4,5,7,13]*)
		iOrder: INT:=0;
			(*which way to sort:
0 means ascending order
1 means descending order*)
	END_VAR

POU 본문

변수 bStartTRUE로 설정되면 펑션이 실행됩니다.

LD 본문

BODY
    WORKSPACE
        NETWORK_LIST_TYPE := NWTYPELD ;
        ACTIVE_NETWORK := 0 ;
    END_WORKSPACE
    NET_WORK
        NETWORK_TYPE := NWTYPELD ;
        NETWORK_LABEL :=  ;
        NETWORK_TITLE :=  ;
        NETWORK_HEIGHT := 7 ;
        NETWORK_BODY
B(B_F,FP_DATA_SORT!,,11,1,20,7,,?DEN?Ds1_Start?Ds2_End?Ds3_Control?AENO);
B(B_CONTACT,,bStart,5,2,7,4,);
B(B_VARIN,,adiDataField[0],9,3,11,5,);
B(B_VARIN,,adiDataField[4],9,4,11,6,);
B(B_VARIN,,iOrder,9,5,11,7,);
L(1,3,5,3);
L(7,3,11,3);
L(1,0,1,7);
        END_NETWORK_BODY
    END_NET_WORK
END_BODY

ST 본문

If (bStart) then
    FP_DATA_SORT(s1_Start := adiDataField[0], 
                 s2_End := adiDataField[4], 
                 s3_Control := iOrder);
End_if;

최종 수정일: 2024-03-01이 페이지에 대한 피드백Panasonic 직통 전화