CODESYS 瀹炴垬锛氱畻鏈钩鍧囨护娉㈠櫒鐨勫疄鐜 ...-CODESYS璧勬簮涓嬭浇鍖-閰峰痉缃 - CoDeSys杞欢鏁欑▼涓嬭浇,CoDeSys宸ユ帶璧勮闂ㄦ埛
HSC6490-cn涓浗鍒堕狅紝涓浗鑺瘇
鏌ョ湅: 5|鍥炲: 0

CODESYS 瀹炴垬锛氱畻鏈钩鍧囨护娉㈠櫒鐨勫疄鐜 ...

[澶嶅埗閾炬帴]
  • TA鐨勬瘡鏃ュ績鎯
    鎿︽睏
    2019-8-13 14:13
  • 绛惧埌澶╂暟: 32 澶

    [LV.5]甯镐綇灞呮皯I

    鍙戣〃浜 鏄ㄥぉ 21:37 | 鏄剧ず鍏ㄩ儴妤煎眰 |闃呰妯″紡
    寮曡█鍦ㄥ伐涓氳嚜鍔ㄥ寲鍜屾帶鍒剁郴缁熶腑锛屾暟鎹櫔澹版槸涓涓父瑙佺殑闂銆備负浜嗗钩婊戣緭鍏ヤ俊鍙凤紝鎻愰珮鏁版嵁鐨勭ǔ瀹氭у拰鍙潬鎬э紝甯镐娇鐢ㄦ护娉㈠櫒鎶鏈傛湰鏂囧皢浠嬬粛濡備綍鍦 CODESYS 涓疄鐜颁竴涓畝鍗曠殑绠楁湳骞冲潎婊ゆ尝鍣ㄣ

    1   绋嬪簭璁捐鎬濊矾
    绠楁湳骞冲潎婊ゆ尝鍣ㄩ氳繃璁$畻涓缁勯噰鏍峰肩殑骞冲潎鍊兼潵骞虫粦杈撳叆淇″彿銆傛垜浠殑鍑芥暟鍧楁帴鏀朵竴涓緭鍏ュ煎拰閲囨牱娆℃暟锛屽苟杈撳嚭璁$畻鍚庣殑骞冲潎鍊笺備负浜嗛傚簲涓嶅悓鐨勫簲鐢ㄩ渶姹傦紝鎴戜滑鍏佽鐢ㄦ埛璁剧疆閲囨牱娆℃暟銆
    2   绋嬪簭浠g爜
    [AppleScript] 绾枃鏈煡鐪 澶嶅埗浠g爜
    FUNCTION_BLOCK PM_ArithmeticMeanFilter
    VAR_INPUT    InputValue : REAL; (* 寰呭鐞嗗 *) 
       SampleCount : INT := 5; (* 閲囨牱娆℃暟 *)
    END_VAR
    VAR_OUTPUT
        FilteredValue : REAL; (* 澶勭悊鍚庣殑鍊 *)
    END_VAR
    VAR
        Samples : ARRAY [1..100] OF REAL; (* 瀛樺偍杈撳叆鏍锋湰鍊肩殑鏁扮粍锛屽亣璁炬渶澶100娆¢噰鏍 *)
        Total : REAL; (* 鏍锋湰鍊肩殑鎬诲拰 *)
        I : INT; (* 寰幆鍙橀噺 *)
        Initialized : BOOL := FALSE; (* 鍒濆鍖栨爣蹇 *)
    END_VAR
    (*鐗堟湰璁板綍锛氱増鏈          鏃ユ湡          浣滆
     V1         2024-5-10     *)
    // 鍒濆鍖栨牱鏈暟缁
     IF NOT Initialized THEN
        FOR I := 1 TO 100 DO
            Samples[I] := 0.0;
        END_FOR
        Initialized := TRUE;
    END_IF
    // 閲囨牱娆℃暟闄愬埗鍦1鍒100涔嬮棿
    IF SampleCount < 1 THEN
        SampleCount := 1;
    ELSIF SampleCount > 100 THEN
        SampleCount := 100;
    END_IF
    // 灏嗚緭鍏ュ煎瓨鍏ユ牱鏈暟缁
    FOR I := SampleCount TO 2 BY -1 DO
        Samples[I] := Samples[I-1];
    END_FOR
    Samples[1] := InputValue;
    // 璁$畻鏍锋湰鍊肩殑鎬诲拰
    Total := 0.0;
    FOR I := 1 TO SampleCount DO
        Total := Total + Samples[I];
    END_FOR
    // 璁$畻绠楁湳骞冲潎鍊
    FilteredValue := Total / SampleCount;


    3   浠g爜瑙i噴

    杈撳叆杈撳嚭鍙橀噺锛
    InputValue锛氶渶瑕佸鐞嗙殑杈撳叆淇″彿銆
    SampleCount锛氱敤浜庤绠楀钩鍧囧肩殑鏍锋湰鏁伴噺銆
    FilteredValue锛氳緭鍑虹殑骞虫粦淇″彿銆

    鍐呴儴鍙橀噺锛
    Samples锛氱敤浜庡瓨鍌ㄦ渶杩戠殑杈撳叆鍊笺
    Total锛氳绠楄繃绋嬩腑鏍锋湰鍊肩殑鎬诲拰銆
    Initialized锛氱敤浜庢爣璁版牱鏈暟缁勬槸鍚﹀凡鍒濆鍖栥

    鍒濆鍖栵細
    鏍锋湰鏁扮粍鍦ㄩ娆¤繍琛屾椂鍒濆鍖栦负 0銆

    鏍锋湰澶勭悊锛
    纭繚SampleCount鍦 1 鍒 100 涔嬮棿銆
    鏇存柊鏍锋湰鏁扮粍锛屽皢鏈鏂拌緭鍏ュ兼彃鍏ワ紝骞剁Щ闄ゆ渶鏃х殑鏍锋湰銆

    璁$畻骞冲潎鍊硷細
    璁$畻鏍锋湰鍊肩殑鎬诲拰骞舵眰骞冲潎锛屼互寰楀埌骞虫粦鍚庣殑杈撳嚭銆

    4   搴旂敤鍦烘櫙
    绠楁湳骞冲潎婊ゆ尝鍣ㄥ箍娉涚敤浜庝俊鍙峰鐞嗐佹暟鎹噰闆嗙郴缁熷拰鑷姩鍖栨帶鍒朵腑锛屼互鍑忓皯鍣0瀵规祴閲忓拰鎺у埗鐨勫奖鍝嶃傚畠鐗瑰埆閫傚悎鐢ㄤ簬绋冲畾鎱㈤熷彉鍖栫殑淇″彿銆

    5   鎷撳睍鎬濊
    闄や簡绠楁湳骞冲潎锛屽叾浠栨护娉㈡妧鏈鍔犳潈骞冲潎銆佷腑鍊兼护娉㈢瓑涔熷彲浠ョ粨鍚堜娇鐢ㄣ傝繘涓姝ョ殑浼樺寲鍙互閫氳繃鍔ㄦ佽皟鏁碨ampleCount鎴栬呭紩鍏ユ洿澶嶆潅鐨勭畻娉曟潵鎻愰珮婊ゆ尝鏁堟灉銆

    6   寮婧愯鏄
    璇ョ▼搴忛伒寰紑婧愬師鍒欙紝浠讳綍浜洪兘鍙互浣跨敤銆佷慨鏀瑰拰鍒嗗彂姝や唬鐮併傚湪浣跨敤鍓嶅簲杩涜鍏呭垎鐨勬祴璇曪紝淇敼浠g爜鏃讹紝璇风鎸佸垎浜簿绁烇紝灏嗘偍鐨勬敼杩涘拰鎴愭灉杩涜鍒嗕韩锛屼互渚挎洿澶氫汉鍙楃泭銆

    鎬荤粨
    鎴戜滑閫氳繃涓涓畝鍗曠殑绠楁湳骞冲潎婊ゆ尝鍣紝灞曠ず浜嗗浣曞湪 CODESYS 涓钩婊戣緭鍏ヤ俊鍙枫傝繖绉嶆柟娉曚笉浠呴傜敤浜庡绉嶅簲鐢ㄥ満鏅紝杩樿兘閫氳繃绠鍗曠殑璋冩暣婊¤冻涓嶅悓鐨勯渶姹傘傚笇鏈涙湰鏂囪兘涓哄伐绋嬪笀浠彁渚涗竴涓湁鏁堢殑瑙e喅鏂规銆

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

    浣跨敤閬撳叿 涓炬姤

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

    鏈増绉垎瑙勫垯

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

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

    GMT+8, 2024-11-16 00:53 , Processed in 0.143793 second(s), 54 queries .

    閰峰痉缃

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

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