鏁扮粍澶勭悊闅撅紵鐪嬭繖涓绡囧氨澶熶簡-CODESYS璧勬簮涓嬭浇鍖-閰峰痉缃 - CoDeSys杞欢鏁欑▼涓嬭浇,CoDeSys宸ユ帶璧勮闂ㄦ埛
HSC6490-cn涓浗鍒堕狅紝涓浗鑺瘇
鏌ョ湅: 116|鍥炲: 0

鏁扮粍澶勭悊闅撅紵鐪嬭繖涓绡囧氨澶熶簡

[澶嶅埗閾炬帴]
  • TA鐨勬瘡鏃ュ績鎯
    寮蹇
    2017-11-20 22:07
  • 绛惧埌澶╂暟: 2 澶

    [LV.1]鍒濇潵涔嶅埌

    鍙戣〃浜 2024-9-6 09:04:40 | 鏄剧ず鍏ㄩ儴妤煎眰 |闃呰妯″紡

    寮曡█

    鍦ㄧ幇浠e伐涓氳嚜鍔ㄥ寲涓紝鏁版嵁澶勭悊鑳藉姏鐨勬彁鍗囨槸鎻愰珮鏁堢巼鍜屽彲闈犳х殑閲嶈閫斿緞銆傛湰鏂囧皢浠嬬粛涓涓敤浜庢暟缁勫鐞嗙殑鍔熻兘鍧 PM_ArrayProcessing_v2锛屽畠鑳藉鎵ц澶氱鏁版嵁鍒嗘瀽浠诲姟锛屽鎺掑簭銆佹渶澶у笺佹渶灏忓笺佸钩鍧囧煎拰涓綅鍊肩殑璁$畻銆傜▼搴忎娇鐢 ST 璇█缂栧啓锛屾柟渚垮ぇ瀹剁Щ妞嶅埌鑷繁浣跨敤鐨 PLC 鍝佺墝銆
    鏈枃骞舵病鏈夋繁鍏ヤ粙缁嶆瘡涓姛鑳界殑瀹炵幇鏂规硶锛屽彧鎻愪緵浜嗕唬鐮佸強閮ㄥ垎瑙i噴锛屾湁鍏磋叮鐨勫彲浠ユ牴鎹唬鐮佹繁鍏ョ爺绌朵竴涓嬨傜▼搴忎唬鐮佺殑浣跨敤 ST 璇█缂栧啓锛屽ぇ閮ㄥ垎鍝佺墝 PLC 閮芥敮鎸 ST 璇█锛屾柟渚垮ぇ瀹剁Щ妞嶅埌鑷繁浣跨敤鐨 PLC 鍝佺墝銆
    1
    绋嬪簭璁捐鎬濊矾
    璇ュ姛鑳藉潡閫氳繃澶氫釜鎸夐挳瑙﹀彂涓嶅悓鐨勬搷浣滐紝涓昏鍖呮嫭锛
    • 鎺掑簭锛氳兘澶熷杈撳叆鐨勬暟缁勮繘琛屼粠灏忓埌澶ф垨浠庡ぇ鍒板皬鐨勬帓搴忋
    • 鏈澶у煎拰鏈灏忓硷細蹇熸壘鍑烘暟缁勪腑鐨勬渶澶у煎拰鏈灏忓笺
    • 骞冲潎鍊硷細璁$畻鏁扮粍鐨勫钩鍧囧笺
    • 涓綅鍊硷細鎵惧埌鏁扮粍鐨勪腑浣嶅硷紝骞跺鐞嗗鏁板拰鍋舵暟闀垮害鐨勬儏鍐点
    閫氳繃杩欎簺鍔熻兘锛岀敤鎴峰彲浠ユ柟渚垮湴瀵规暟缁勮繘琛屽叏闈㈠垎鏋愩
    2
    绋嬪簭浠g爜
    [AppleScript] 绾枃鏈煡鐪 澶嶅埗浠g爜
    FUNCTION_BLOCK PM_ArrayProcessing_v2
    VAR_INPUT
        SortAscBtn : BOOL;
        SortDescBtn : BOOL;
        MaxBtn : BOOL;
        MinBtn : BOOL;
        AvgBtn : BOOL;
        MedianBtn : BOOL;
        InputArray : ARRAY[1..11] OF REAL;
    END_VAR
    VAR_OUTPUT
        SortedAscArray : ARRAY[1..11] OF REAL;
        SortedDescArray : ARRAY[1..11] OF REAL;
        MaxValue : REAL;
        MinValue : REAL;
        AvgValue : REAL;
        MedianValue : REAL;
    END_VAR
    VAR
        TempArray : ARRAY[1..11] OF REAL;
        I, J : INT;
        Temp : REAL;
        Sum : REAL;
        ArrayLength : UINT;
    END_VAR
    
    (*
    鐗堟湰璁板綍锛
    鐗堟湰          鏃ユ湡          浣滆
     V1         2024-3-21     宸ユ帶鑰佺帇
     V2         2024-8-09     宸ユ帶鑰佺帇
    *)
    
    // 鍔熻兘璇存槑锛
    // 瀵规暟缁勮繘琛屽鐞嗭紝鏍规嵁涓嶅悓鍔熻兘鐨勬寜閽紝杈撳嚭鎺掑簭锛堜粠灏忓埌澶э紝浠庡ぇ鍒板皬锛夈佹渶澶у笺佹渶灏忓笺佸钩鍧囧笺佷腑浣嶅
    
    ArrayLength := SIZEOF(InputArray) / 4;
    
    FOR I := 1 TO UINT_TO_INT(ArrayLength) DO
        TempArray[i] := InputArray[i];
    END_FOR
    
    IF SortAscBtn THEN
        FOR I := 1 TO UINT_TO_INT(ArrayLength) - 1 DO
            FOR J := I + 1 TO UINT_TO_INT(ArrayLength) DO
                IF TempArray[i] > TempArray[j] THEN
                    Temp := TempArray[i];
                    TempArray[i] := TempArray[j];
                    TempArray[j] := Temp;
                END_IF
            END_FOR
        END_FOR
        FOR I := 1 TO UINT_TO_INT(ArrayLength) DO
            SortedAscArray[I] := TempArray[I];
        END_FOR
    END_IF
    
    IF SortDescBtn THEN
        FOR I := 1 TO UINT_TO_INT(ArrayLength) - 1 DO
            FOR J := I + 1 TO UINT_TO_INT(ArrayLength) DO
                IF TempArray[I] < TempArray[J] THEN
                    Temp := TempArray[I];
                    TempArray[I] := TempArray[J];
                    TempArray[J] := Temp;
                END_IF
            END_FOR
        END_FOR
        FOR I := 1 TO UINT_TO_INT(ArrayLength) DO
            SortedDescArray[I] := TempArray[I];
        END_FOR
    END_IF
    
    IF MaxBtn THEN
        MaxValue := InputArray[1];
        FOR I := 2 TO UINT_TO_INT(ArrayLength) DO
            IF InputArray[i] > MaxValue THEN
                MaxValue := InputArray[i];
            END_IF
        END_FOR
    END_IF
    
    IF MinBtn THEN
        MinValue := InputArray[1];
        FOR I := 2 TO UINT_TO_INT(ArrayLength) DO
            IF InputArray[i] < MinValue THEN
                MinValue := InputArray[i];
            END_IF
        END_FOR
    END_IF
    
    IF AvgBtn THEN
        Sum := 0;
        FOR I := 1 TO UINT_TO_INT(ArrayLength) DO
            Sum := Sum + InputArray[i];
        END_FOR
        AvgValue := Sum / UINT_TO_INT(ArrayLength);
    END_IF
    
    IF MedianBtn THEN
        FOR I := 1 TO UINT_TO_INT(ArrayLength)-1 DO
            FOR J := I + 1 TO UINT_TO_INT(ArrayLength) DO
                IF TempArray[I] > TempArray[J] THEN
                    Temp := TempArray[I];
                    TempArray[I] := TempArray[J];
                    TempArray[J] := Temp;
                END_IF
            END_FOR
        END_FOR
        IF UINT_TO_INT(ArrayLength) MOD 2 = 0 THEN
            MedianValue := (TempArray[UINT_TO_INT(ArrayLength) / 2] + TempArray[UINT_TO_INT(ArrayLength) / 2 + 1]) / 2;
        ELSE
            MedianValue := TempArray[UINT_TO_INT(ArrayLength) / 2 + 1];
        END_IF
    END_IF
    3
    浠g爜瑙i噴
    • 杈撳叆涓庤緭鍑猴細杈撳叆鍖呮嫭涓涓暱搴︿负 11 鐨勬暟缁勫拰鑻ュ共鎺у埗鎸夐挳锛岃緭鍑哄垯鏄鐞嗗悗鐨勬暟缁勬垨璁$畻鍊笺傦紙鍙牴鎹渶姹備慨鏀规暟缁勫ぇ灏忥紝绋嬪簭涓墍鏈夌殑鏁扮粍鍙橀噺閮介渶瑕佷慨鏀癸級
    • 鎺掑簭鍔熻兘锛氫娇鐢ㄧ畝鍗曠殑鍐掓场鎺掑簭娉曞疄鐜版帓搴忓姛鑳姐
    • 鏈澶у煎拰鏈灏忓硷細閫氳繃閬嶅巻鏁扮粍瀹炵幇銆
    • 骞冲潎鍊硷細绱姞鏁扮粍鍏冪礌鍚庨櫎浠ユ暟缁勯暱搴︺
    • 涓綅鍊硷細鍏堟帓搴忥紝鍐嶆牴鎹暟缁勯暱搴﹀垽鏂彇涓棿鍊兼垨涓棿涓や釜鍊肩殑骞冲潎銆
    • 鎷撳睍锛氱敤鎴峰彲浠ユ牴鎹嚜宸辩殑鎯呭喌锛屽彧闇瑕佺畝鍗曞湴淇敼绋嬪簭灏卞彲浠ュ疄鐜颁笉鍚屾暟缁勫ぇ灏忕殑鏁扮粍鍒嗘瀽銆
    绋嬪簭杩愯灞曠ず
    640?wx_fmt=png&from=appmsg.jpg
    杈撳叆

    640?wx_fmt=png&from=appmsg.jpg
    杈撳嚭

    4
    搴旂敤鍦烘櫙
    璇ュ姛鑳藉潡閫傜敤浜庡伐涓氳嚜鍔ㄥ寲璁惧鐨勫疄鏃舵暟鎹鐞嗭紝濡傜敓浜х嚎浼犳劅鍣ㄦ暟鎹殑鍒嗘瀽銆佽川閲忔帶鍒朵腑鐨勬暟鎹瓫閫夌瓑銆
    5
    寮婧愮増鏈鏄
    璇ョ▼搴忛伒寰紑婧愬師鍒欙紝浠讳綍浜洪兘鍙互浣跨敤銆佷慨鏀瑰拰鍒嗗彂姝や唬鐮併傚湪浣跨敤鍓嶅簲杩涜鍏呭垎鐨勬祴璇曪紝淇敼浠g爜鏃讹紝璇风鎸佸垎浜簿绁烇紝灏嗘偍鐨勬敼杩涘拰鎴愭灉杩涜鍒嗕韩锛屼互渚挎洿澶氫汉鍙楃泭銆

    鎬荤粨

    閫氳繃 PM_ArrayProcessing_v2 鍔熻兘鍧楋紝鐢ㄦ埛鍙互楂樻晥鍦板鐞嗗拰鍒嗘瀽鏁版嵁銆傚叾璁捐绠鍗曟槗鎳傦紝閫傚悎蹇熼泦鎴愬埌鍚勭宸ヤ笟鎺у埗绯荤粺涓紝鏋佸ぇ鍦版彁楂樹簡鏁版嵁澶勭悊鐨勮嚜鍔ㄥ寲绋嬪害鍜屾晥鐜囥

    +10
    涓嶈禐涓涓紵
    鎵撹祻榧撳姳涓涓嬶紒
    鍥炲

    浣跨敤閬撳叿 涓炬姤

    鎮ㄩ渶瑕佺櫥褰曞悗鎵嶅彲浠ュ洖甯 鐧诲綍 | 绔嬪嵆娉ㄥ唽 鏂版氮寰崥鐧婚檰

    鏈増绉垎瑙勫垯

    椤堕儴qrcode搴曢儴
    鍏虫敞閰峰痉缃戣闃呭彿锛岃幏鍙栨洿澶氳祫璁紒

    QQ|灏忛粦灞|鎵嬫満鐗|Archiver|閰峰痉璁哄潧 ( 鑻廔CP澶16065247鍙-1 )|缃戠珯鍦板浘

    GMT+8, 2024-11-23 19:42 , Processed in 0.162725 second(s), 61 queries .

    閰峰痉缃

    © 2001-2013 Hicodesys. 鎶鏈敮鎸 by 閰峰痉缃

    蹇熷洖澶 杩斿洖椤堕儴 杩斿洖鍒楄〃