楂樻墜甯哥敤鐨勶紤锛愬ぇ婊ゆ尝鏂规硶锛岄檮璧犵ず渚嬬▼搴忥紝鎷垮幓鐩存帴鐢-CODESYS璧勬簮涓嬭浇鍖-閰峰痉缃 - CoDeSys杞欢鏁欑▼涓嬭浇,CoDeSys宸ユ帶璧勮闂ㄦ埛
HSC6490-cn涓浗鍒堕狅紝涓浗鑺瘇
鏌ョ湅: 235|鍥炲: 0

楂樻墜甯哥敤鐨勶紤锛愬ぇ婊ゆ尝鏂规硶锛岄檮璧犵ず渚嬬▼搴忥紝鎷垮幓鐩存帴鐢

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

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

    鍙戣〃浜 2024-8-30 15:50:00 | 鏄剧ず鍏ㄩ儴妤煎眰 |闃呰妯″紡
    鍦ㄤ俊鍙峰鐞嗗拰鏁版嵁鍒嗘瀽棰嗗煙锛屾护娉㈢畻娉曟壆婕旂潃鑷冲叧閲嶈鐨勮鑹层傚畠浠府鍔╂垜浠粠鍢堟潅鐨勬暟鎹腑鎻愬彇鏈夌敤淇℃伅锛屽钩婊戞暟鎹尝鍔紝棰勬祴鏈潵瓒嬪娍锛岀敋鑷冲疄鐜扮郴缁熺姸鎬佺殑绮剧‘浼拌銆備粖澶╋紝鎴戜滑灏嗗甫鎮ㄦ帰绱㈠崄澶х粡鍏告护娉㈢畻娉曪紝杩欎簺绠楁硶鍦ㄥ伐绋嬪疄璺靛拰绉戝鐮旂┒涓兘鏈夌潃骞挎硾鐨勫簲鐢紙鑾峰彇妗堜緥绋嬪簭鐨勬柟娉曡鏂囨湯锛夈

    锛.銆闄愬箙婊ゆ尝锛
    • 鏂规硶锛



      • 濡傛灉鏂伴噰鏍峰间笌鍓嶄竴閲囨牱鍊间箣宸皬浜庢垨绛変簬A锛屽垯璁や负鏈閲囨牱鏈夋晥銆
      • 濡傛灉鏂伴噰鏍峰间笌鍓嶄竴閲囨牱鍊间箣宸ぇ浜嶢锛屽垯璁や负鏈閲囨牱鏃犳晥锛岀敤鍓嶄竴娆$殑鏈夋晥閲囨牱鍊兼浛浠f湰娆¢噰鏍峰笺

    • 浼樼偣锛



      鎶楄剦鍐插共鎵帮細 鑳藉鏈夋晥璇嗗埆骞舵帓闄ょ敱浜庣灛鏃跺共鎵伴犳垚鐨勫紓甯搁噰鏍峰硷紝浠庤屼繚鎸佹暟鎹殑绋冲畾鎬с

    • 缂虹偣锛



      • 鍛ㄦ湡鎬у共鎵版姂鍒朵笉瓒筹細 瀵逛簬鍏锋湁鍛ㄦ湡鎬х殑骞叉壈锛岃绠楁硶鍙兘鏃犳硶鏈夋晥璇嗗埆鍜屾姂鍒讹紝鍙兘瀵艰嚧鏁版嵁涓瓨鍦ㄥ懆鏈熸х殑娉㈠姩銆
      • 骞虫粦搴︿笉瓒筹細 鐢变簬绠楁硶鍦ㄩ亣鍒拌緝澶у亸宸椂鐩存帴浣跨敤鍓嶄竴鍊兼浛浠o紝鍙兘鏃犳硶骞虫粦澶勭悊鏁版嵁涓殑娉㈠姩锛屽鑷磋緭鍑烘暟鎹殑骞虫粦搴︿笉楂樸

    [AppleScript] 绾枃鏈煡鐪 澶嶅埗浠g爜
    //闄愬箙婊ゆ尝
    //濡傛灉鏂伴噰鏍峰间笌鍓嶄竴閲囨牱鍊间箣宸皬浜庢垨绛変簬A锛屽垯璁や负鏈閲囨牱鏈夋晥銆
    IF ABS(lrSignalIn - lrTemp) > lrDifference AND lrTemp <> 0 THEN
        Filter_limit := lrTemp;
    ELSE  //濡傛灉鏂伴噰鏍峰间笌鍓嶄竴閲囨牱鍊间箣宸ぇ浜嶢锛屽垯璁や负鏈閲囨牱鏃犳晥锛岀敤鍓嶄竴娆$殑鏈夋晥閲囨牱鍊兼浛浠f湰娆¢噰鏍峰笺
        Filter_limit := lrSignalIn;
    END_IF
    lrTemp := lrSignalIn;



    锛.銆绠楁湳骞冲潎婊ゆ尝
    • 鏂规硶锛



      • 鍙栨牱锛杩炵画閲囬泦鏁版嵁N娆★紝骞跺杩欎簺鏁版嵁姹傚钩鍧囧
      • 姹傚钩鍧囨暟锛氬钩鍧囧肩殑閫夊彇鍙栧喅浜嶯鐨勫ぇ灏

    • 浼樼偣锛



      • 鎶楀共鎵拌兘鍔涳細 閫傜敤浜庡瓨鍦ㄩ殢鏈哄共鎵扮殑绯荤粺锛岄氳繃澶氭閲囨牱姹傚钩鍧囷紝鑳芥湁鏁堥檷浣庨殢鏈哄櫔澹扮殑褰卞搷銆
      • 绋冲畾鎬э細 閫氳繃骞虫粦澶勭悊锛屾彁楂樹簡鏁版嵁鐨勭ǔ瀹氭у拰鍙潬鎬с

    • 缂虹偣锛



      • 澶勭悊閫熷害锛 鐢变簬闇瑕佽繛缁噰闆嗗苟澶勭悊澶氭鏁版嵁锛岀畻娉曠殑鎵ц閫熷害杈冩參銆
      • 璧勬簮鍗犵敤锛 闇瑕佸瓨鍌ㄥ娆¢噰鏍锋暟鎹紝鍥犳鍗犵敤杈冨鐨勯殢鏈哄瓨鍙栧瓨鍌ㄥ櫒锛圧AM锛夈

    [AppleScript] 绾枃鏈煡鐪 澶嶅埗浠g爜
    //绠楁暟骞冲潎婊ゆ尝娉
    //杩炵画閲囬泦鏁版嵁N娆★紝骞跺杩欎簺鏁版嵁姹傚钩鍧囧
    FOR i := 0 TO iNumberOfSamples - 1 DO
        aSampleBuffer[i] := lrSignalIn;
    END_FOR
    //杈撳叆鍊兼眰鍜
    FOR j := 0 TO iNumberOfSamples - 1 DO
        lrTempSum := lrTempSum + aSampleBuffer[j];
    END_FOR
    //姹傚钩鍧囧
    Filter_average := lrTempSum / iNumberOfSamples;



    3.銆涓綅鍊婊ゆ尝
    • 鏂规硶锛



      • 鎺掑簭锛氬皢鏁版嵁鐐规寜鐓уぇ灏忛『搴忚繘琛屾帓搴
      • 閫夋嫨涓綅鍊硷細浠庢帓搴忓悗鐨勬暟鎹腑閫夋嫨浣嶄簬涓棿浣嶇疆鐨勬暟鍊间綔涓轰腑浣嶅笺傚鏋滄暟鎹偣鏁伴噺鏄鏁帮紝涓綅鍊煎氨鏄涓棿鐨勬暟鍊硷紱濡傛灉鏄伓鏁帮紝鍒欎腑浣嶅奸氬父鏄腑闂翠袱涓暟鍊肩殑骞冲潎鍊
      • 鏇挎崲寮傚父鍊硷細鐢ㄤ腑浣嶅兼浛鎹㈡墍鏈夊紓甯稿兼垨绂荤兢鐐

    • 浼樼偣锛



      • 瀵瑰紓甯稿间笉鏁忔劅锛氫腑浣嶅兼护娉㈡硶瀵瑰紓甯稿煎叿鏈夊緢濂界殑鎶垫姉鍔涳紝涓嶄細鍍忓潎鍊兼护娉㈤偅鏍峰彈鍒版瀬绔肩殑褰卞搷銆
      • 閫傜敤浜庨潪绾挎ф暟鎹細瀵逛簬闈炵嚎鎬ф垨闈為珮鏂垎甯冪殑鏁版嵁锛屼腑浣嶅兼护娉㈡硶浠嶇劧鏈夋晥銆

    • 缂虹偣锛



      • 骞虫粦鑳藉姏鏈夐檺锛氫腑浣嶅兼护娉㈡硶涓昏鐢ㄤ簬鍘婚櫎寮傚父鍊硷紝瀵逛簬骞虫粦鏁版嵁娉㈠姩鐨勮兘鍔涙湁闄愩
      • 瀵瑰懆鏈熸у櫔澹颁笉鏁忔劅锛氫腑浣嶅兼护娉㈡硶涓昏閽堝闅忔満鍣0鏈夋晥锛屽浜庡懆鏈熸ф垨鏈夌粨鏋勭殑鍣0鍙兘涓嶅鏈夋晥銆

    [AppleScript] 绾枃鏈煡鐪 澶嶅埗浠g爜
    //涓兼护娉㈡硶
    //鍙栨牱
    FOR icount :=0 TO iN DO
      aSampleBuffer[icount]:= lrSignalIn ;
    END_FOR
    
    //瀵规牱鏈紦鍐插尯杩涜鍐掓场鎺掑簭锛屼互鎵惧埌涓綅鏁 
    //澶栧眰寰幆鎺у埗鎺掑簭鐨勬昏疆鏁帮紝姣忚疆閮戒細灏嗘渶澶х殑鏁扮Щ鍔ㄥ埌搴忓垪鐨勬湯灏
    FOR j:=0 TO iN-1 DO 
      //鍐呭眰寰幆鐢ㄤ簬姣旇緝鐩搁偦鍏冪礌骞惰繘琛屼氦鎹紝浠ュ疄鐜版帓搴
      FOR i:=0 TO iN-j DO
        //濡傛灉褰撳墠鍏冪礌澶т簬涓嬩竴涓厓绱狅紝鍒欎氦鎹㈠畠浠
        IF aSampleBuffer[i]> aSampleBuffer[i+1] THEN
          lrTemp := aSampleBuffer[i];
          aSampleBuffer[i]:= aSampleBuffer[i+1];
          aSampleBuffer[i+1]:= lrTemp ;
        END_IF
      END_FOR
    END_FOR
    //瀵逛簬濂囨暟涓厓绱狅紝鐩存帴鍙栦腑闂村厓绱;瀵逛簬鍋舵暟涓厓绱狅紝鍙栦腑闂翠袱涓厓绱犵殑骞冲潎鍊硷紝浣嗚繖閲屽彧鍙栦簡绗竴涓腑闂村
    Filter_mid := aSampleBuffer[TO_INT((iN-1)/2)];



    锛.銆闄愬箙骞冲潎婊ゆ尝
    • 鏂规硶锛



      • 鏁版嵁棰勫鐞嗭細瀵规瘡涓噰鏍风偣鐨勪俊鍙峰艰繘琛屾鏌ワ紝濡傛灉瓒呭嚭闄愬箙鑼冨洿锛屽垯灏嗗叾璁剧疆涓洪檺骞呭硷紙鍙互鏄笂闄愭垨涓嬮檺锛屽彇鍐充簬璁捐锛夈
      • 绱姞闄愬箙鍚庣殑鏁版嵁锛氬皢缁忚繃闄愬箙澶勭悊鍚庣殑淇″彿鍊艰繘琛岀疮鍔犮
      • 璁$畻骞冲潎鍊硷細灏嗙疮鍔犵殑缁撴灉闄や互閲囨牱鐐圭殑鏁伴噺锛屽緱鍒伴檺骞呭悗鐨勫钩鍧囧

    • 浼樼偣锛



      • 鎶戝埗寮傚父鍊硷細鏈夋晥鎶戝埗瓒呭嚭闄愬箙鑼冨洿鐨勫紓甯稿兼垨灏栧嘲鍣0銆
      • 骞虫粦淇″彿锛氶氳繃绠楁湳骞冲潎鐨勬柟寮忓钩婊戜俊鍙凤紝鍑忓皯闅忔満鍣0鐨勫奖鍝嶃
      • 淇濇寔淇″彿鐗瑰緛锛氬湪鍘婚櫎鍣0鐨勫悓鏃讹紝鑳藉杈冨ソ鍦颁繚鎸佷俊鍙风殑鍘熷鐗瑰緛

    • 缂虹偣锛



      • 鍙兘寮曞叆澶辩湡锛氶檺骞呭鐞嗗彲鑳戒細瀵艰嚧淇″彿鐨勯儴鍒嗕俊鎭涪澶憋紝寮曞叆涓瀹氱▼搴︾殑澶辩湡銆
      • 瀵归檺骞呭兼晱鎰燂細闄愬箙鍊肩殑閫夋嫨瀵规护娉㈡晥鏋滄湁寰堝ぇ褰卞搷锛屼笉閫傚綋鐨勯檺骞呭煎彲鑳藉鑷存湁鏁堜俊鍙疯閿欒鍦伴檺骞呫
      • 瀵瑰揩閫熷彉鍖栦俊鍙峰搷搴旀參锛氱敱浜庡钩鍧囩殑浣滅敤锛屾护娉㈠櫒瀵逛俊鍙风殑蹇熷彉鍖栧搷搴旇緝鎱紝鍙兘鏃犳硶鍙婃椂璺熻釜淇″彿鐨勭湡瀹炲彉鍖栥

    [AppleScript] 绾枃鏈煡鐪 澶嶅埗浠g爜
    // 濡傛灉杈撳叆淇″彿lrSignalIn涓庝复鏃跺彉閲弆rTemp鐨勫樊鐨勭粷瀵瑰煎ぇ浜庤瀹氱殑闃堝
    IF ABS(lrSignalIn - lrTemp) > lrDifference AND lrTemp <> 0 THEN
        aSampleBuffer[i] := lrSignalIn;//灏嗗綋鍓嶇殑杈撳叆淇″彿lrSignalIn瀛樺偍鍒版牱鏈紦鍐插尯aSampleBuffer鐨勭i涓綅缃
      i := i+1;
    END_IF
    IF i >= iN THEN
      // 濡傛灉绱㈠紩i杈惧埌鎴栬秴杩囨牱鏈紦鍐插尯鐨勬渶澶х储寮昳N锛
        // 鍒欏皢i閲嶇疆涓0锛屽疄鐜板惊鐜紦鍐茬殑鏁堟灉銆
      i := 0;
    END_IF
    lrSum := 0;
    FOR j:=0 TO iN DO
      // 鍒濆鍖栨眰鍜屽彉閲弆rSum涓0锛屽噯澶囪绠楁牱鏈紦鍐插尯鎵鏈夊厓绱犵殑鎬诲拰銆
        // 寰幆閬嶅巻鏍锋湰缂撳啿鍖猴紝浠庣储寮0鍒癷N锛岀疮鍔犳瘡涓厓绱犵殑鍊煎埌lrSum銆
      lrSum := lrSum + aSampleBuffer[j];
    END_FOR
    // 灏嗗綋鍓嶇殑杈撳叆淇″彿lrSignalIn璧嬪肩粰涓存椂鍙橀噺lrTemp锛屽噯澶囩敤浜庝笅涓娆″惊鐜殑姣旇緝銆
    lrTemp := lrSignalIn;
    // 璁$畻鏍锋湰缂撳啿鍖烘墍鏈夋牱鏈殑骞冲潎鍊
    Filter_limitav := lrSum / iN;



    5.銆娑堟姈婊ゆ尝
    • 鏂规硶锛



      • 杩炵画閲囨牱锛氬淇″彿杩涜杩炵画閲囨牱锛岃幏鍙栦竴绯诲垪鏁版嵁鐐广
      • 璁板綍鏈夋晥鍙樺寲锛氬鏋滆繛缁噰鏍峰间箣闂寸殑宸紓瓒呰繃闃堝硷紝鍒欒褰曡繖娆″彉鍖栵紝骞舵洿鏂版护娉㈠悗鐨勮緭鍑恒
      • 杈撳嚭婊ゆ尝缁撴灉锛氭牴鎹湁鏁堝彉鍖栨洿鏂版护娉㈠悗鐨勪俊鍙疯緭鍑恒

    • 浼樼偣锛



      • 鎶楀共鎵拌兘鍔涘己锛氳兘鏈夋晥婊ら櫎鐢变簬鎺ヨЕ涓嶈壇鎴栦紶鎰熷櫒鍣0寮曡捣鐨勫揩閫熷皬骞呭害鎶栧姩銆
      • 淇濇寔淇″彿杈圭紭锛氱敱浜庡彧蹇界暐灏忓箙搴﹀彉鍖栵紝娑堟姈婊ゆ尝閫氬父鑳戒繚鎸佷俊鍙风殑蹇熶笂鍗囨垨涓嬮檷杈圭紭銆
      • 閫傜敤浜庡紑鍏充俊鍙凤細鐗瑰埆閫傜敤浜庡鐞嗗紑鍏充俊鍙锋垨鎸夐挳杈撳叆锛屼互娑堥櫎璇Е鍙戙

    • 缂虹偣锛



      • 鍙傛暟閫夋嫨鍏抽敭锛氶槇鍊肩殑璁惧畾瀵规护娉㈡晥鏋滆嚦鍏抽噸瑕侊紝涓嶆伆褰撶殑闃堝煎彲鑳藉鑷存湁鏁堜俊鍙疯杩囨护鎺夋垨鍣0琚繚鐣欍
      • 鍙兘寤惰繜鍝嶅簲锛氱敱浜庨渶瑕佺瓑寰呰秴杩囬槇鍊肩殑鍙樺寲锛屾护娉㈠櫒鍙兘浼氬紩鍏ヤ竴瀹氱殑寤惰繜銆
      • 瀵瑰ぇ淇″彿鍙樺寲鏁忔劅锛氬鏋滀俊鍙风殑瀹為檯鍙樺寲瓒呰繃闃堝硷紝鍙兘浼氶敊璇湴璁や负鏄櫔澹拌屽拷鐣ワ紝灏ゅ叾鏄湪淇″彿鍙樺寲澶嶆潅鐨勬儏鍐典笅銆
      • 涓嶉傚悎楂橀淇″彿锛氬浜庨珮棰戜俊鍙凤紝娑堟姈婊ゆ尝鍙兘鏃犳硶鏈夋晥宸ヤ綔锛屽洜涓哄畠涓昏閽堝灏忓箙搴︾殑闅忔満鍙樺寲銆

    [AppleScript] 绾枃鏈煡鐪 澶嶅埗浠g爜
    //娑堟姈婊ゆ尝
    //// 濡傛灉褰撳墠淇″彿鍊糽rSignalIn涓嶇瓑浜庢湁鏁堝糽rValid
    IF lrSignalIn <> lrValid THEN
      //灏嗙储寮昳澧炲姞1锛岀敤浜庤窡韪俊鍙峰彉鍖栫殑娆℃暟鎴栨椂闂
      i := i + 1;
      IF i > iN THEN
        i := 0;
        Filter_ditel := lrSignalIn;
       END_IF
    ELSE  // 濡傛灉褰撳墠淇″彿鍊糽rSignalIn绛変簬鏈夋晥鍊糽rValid
      i := 0;
      // 灏嗘湁鏁堝糽rValid璧嬪肩粰婊ゆ尝鍣
      Filter_ditel := lrValid;
    END_IF



    锛.銆闄愬箙娑堟姈婊ゆ尝
    • 鏂规硶锛



      闄愬箙娑堟姈婊ゆ尝鍦ㄦ秷鎶栫殑鍩虹涓婂鍔犱簡闄愬箙鍔熻兘锛岄氳繃璁剧疆涓婇檺鍜屼笅闄愰槇鍊兼潵闄愬埗淇″彿鐨勬尝鍔ㄨ寖鍥淬傚彲浠ユ姂鍒舵洿澶ц寖鍥寸殑鍣0锛屽寮轰俊鍙风ǔ瀹氭э紝閫傚簲鎬ф洿寮猴紝鏈夋晥闃叉淇″彿澶辩湡锛屾彁楂樹俊鍙疯川閲忥紝搴旂敤鍦烘櫙鏇村箍娉涖
    [AppleScript] 绾枃鏈煡鐪 澶嶅埗浠g爜
    //闄愬箙娑堟姈婊ゆ尝
    //// 濡傛灉宸煎ぇ浜庨槇鍊硷紝鍒欏皢涓存椂鍙橀噺lrTemp璁剧疆涓烘湁鏁堝糽rValid
    IF ABS(lrSignalIn - lrValid) > lrDifference THEN
      lrTemp := lrValid;
    ELSE
      lrTemp := lrValid;
    END_IF
    // 濡傛灉璁℃暟鍣╥瓒呰繃璁惧畾鐨勬渶澶у糹N锛屽垯閲嶇疆i涓0
    IF lrTemp <> lrSignalIn THEN
      i := i + 1;
      IF i > iN THEN
        i := 0;
        Filter_limitditel := lrValid;
      END_IF
    END_IF



    7.銆閫掓帹骞冲潎婊ゆ尝
    • 鏂规硶锛



      • 瀹炴椂鏇存柊锛氬浜庢瘡涓涓柊鐨勮緭鍏ユ暟鎹偣锛屼娇鐢ㄤ互涓嬮掓帹鍏紡鏇存柊婊ゆ尝缁撴灉锛
        640?wx_fmt=png&from=appmsg.jpg
      • 杩炵画搴旂敤锛氬皢涓婅堪閫掓帹鍏紡杩炵画搴旂敤浜庢柊鐨勬暟鎹偣锛屼互瀹炴椂鏇存柊婊ゆ尝缁撴灉銆

    • 浼樼偣锛



      • 瀹炴椂鎬э細閫掓帹骞冲潎婊ゆ尝娉曞彲浠ュ疄鏃舵洿鏂版护娉㈢粨鏋滐紝閫傚悎鍦ㄧ嚎鏁版嵁澶勭悊銆
      • 璁$畻鏁堢巼楂橈細鐢变簬鍙渶瑕佷繚鐣欏墠涓涓护娉㈠硷紝璁$畻閲忓皬锛岄傜敤浜庤祫婧愬彈闄愮殑绯荤粺銆
      • 骞虫粦鏁堟灉锛氳兘澶熷钩婊戞暟鎹腑鐨勯殢鏈哄櫔澹帮紝浣夸俊鍙锋洿鍔犵ǔ瀹氥

    • 缂虹偣锛



      • 绱Н璇樊锛氶暱鏈熷簲鐢ㄩ掓帹鍏紡鍙兘瀵艰嚧璇樊绱Н锛屽奖鍝嶆护娉㈢簿搴︺
      • 瀵瑰垵鍊兼晱鎰燂細婊ゆ尝鍣ㄧ殑鍒濆鍊煎鏈缁堢粨鏋滄湁涓瀹氬奖鍝嶏紝闇瑕佸悎鐞嗛夋嫨銆
      • 鏃犳硶澶勭悊绐佸彉锛氬浜庝俊鍙蜂腑鐨勭獊鍙樻垨璺冲彉锛岄掓帹骞冲潎婊ゆ尝娉曞彲鑳芥棤娉曞強鏃跺搷搴斻

    [AppleScript] 绾枃鏈煡鐪 澶嶅埗浠g爜
    //閫掓帹骞冲潎婊ゆ尝
    // 灏嗗綋鍓嶇殑淇″彿鍊糽rSignalIn瀛樺偍鍒版牱鏈紦鍐插尯aSampleBuffer鐨勫綋鍓嶇储寮昳浣嶇疆
    aSampleBuffer[i]:= lrSignalIn;
    // 灏嗙储寮昳澧炲姞1锛岀敤浜庡噯澶囦笅涓娆℃暟鎹殑瀛樺偍浣嶇疆
    i:= i + 1;
    // 杩欓氬父鐢ㄤ簬寰幆缂撳啿鍖猴紝褰撹揪鍒版湯灏炬椂閲嶆柊寮濮
    IF i>= iN THEN
      i:= 0;
    END_IF
    // 閬嶅巻鏍锋湰缂撳啿鍖篴SampleBuffer涓殑鎵鏈夋牱鏈
    FOR j:= 0 TO iN DO
      lrTemp := lrTemp + aSampleBuffer[j];
    END_FOR
    // 璁$畻绉诲姩骞冲潎鍊硷紝鍗冲皢绱姞鐨勬牱鏈奸櫎浠ョ紦鍐插尯澶у皬iN
    Filter_recav := lrTemp /iN ;



    8锛庡姞鏉冮掓帹骞冲潎婊ゆ尝
    • 鐗圭偣锛



      姣忎釜鏁版嵁鐐规牴鎹叾鏃堕棿閲嶈鎬ц璧嬩簣涓涓潈閲嶃傛潈閲嶉氬父闅忕潃鏃堕棿鐨勫闀胯岄掑噺锛岃繖绉嶅姞鏉冩満鍒跺厑璁告护娉㈠櫒瀵规柊鏁版嵁缁欎簣鏇村鐨勫叧娉ㄣ
    [AppleScript] 绾枃鏈煡鐪 澶嶅埗浠g爜
    //鍔犳潈閫掓帹骞冲潎婊ゆ尝
    lrSumcoe :=0;
    // 灏嗗綋鍓嶇储寮昳杞崲涓洪暱瀹炴暟骞跺瓨鍌ㄥ湪鍔犳潈绯绘暟鏁扮粍aSumcoe涓
    FOR i:= 0 TO iN DO
      aSumcoe[i] :=TO_LREAL( i );
      lrSumcoe :=lrSumcoe +i;
    END_FOR
    // 灏嗕俊鍙峰糽rSignalIn璧嬪肩粰鏍锋湰缂撳啿鍖篴SampleBuffer鐨勬瘡涓綅缃
    FOR i :=0 TO iN DO
      aSampleBuffer[i]:= lrSignalIn;
    END_FOR
    lrSum :=0;
    // 閬嶅巻鏍锋湰缂撳啿鍖篴SampleBuffer锛岃绠楁瘡涓牱鏈间笌鍏跺搴斿姞鏉冪郴鏁扮殑涔樼Н
    FOR j:=0 TO iN DO
      lrSum := lrSum + aSampleBuffer[i]*aSumcoe[i];
    END_FOR
     // 灏嗗姞鏉冨悗鐨勬牱鏈兼诲拰闄や互鍔犳潈绯绘暟鐨勬诲拰锛屽緱鍒板姞鏉冪Щ鍔ㄥ钩鍧囧
    IF lrSumcoe <> 0 THEN
      Filter_recavwei := lrSum / lrSumcoe ;
    END_IF



    锛.銆涓闃舵粸鍚庢护娉㈡硶
    • 鐗圭偣锛
      涓闃舵粸鍚庢护娉㈡硶锛團irst-Order Lag Filter锛夛紝涔熺О涓烘寚鏁扮Щ鍔ㄥ钩鍧囨护娉㈡硶锛圗xponential Moving Average, EMA锛夛紝鏄竴绉嶅父鐢ㄧ殑淇″彿骞虫粦鎶鏈
    • 浼樼偣锛



      • 绠鍗曢珮鏁堬細绠楁硶瀹炵幇绠鍗曪紝璁$畻鏁堢巼楂橈紝閫傚悎瀹炴椂鏁版嵁澶勭悊銆
      • 骞虫粦鎬ц兘濂斤細鑳藉鏈夋晥鍦板钩婊戦殢鏈哄櫔澹帮紝鎻愪緵淇″彿鐨勫钩婊戜及璁°
      • 鏃堕棿鍔犳潈锛氬鏈杩戠殑鏁版嵁璧嬩簣鏇撮珮鐨勬潈閲嶏紝浣垮緱婊ゆ尝缁撴灉鏇村姞鍙嶆槧杩戞湡瓒嬪娍銆

    • 缂虹偣锛



      • 瀵瑰垵鍊兼晱鎰燂細婊ゆ尝鍣ㄧ殑鍒濆鍊煎彲鑳藉鏈缁堢粨鏋滄湁杈冨ぇ褰卞搷锛岀壒鍒槸鍦ㄦ暟鎹簭鍒楃殑寮濮嬮樁娈点
      • 寤惰繜鏁堝簲锛氱敱浜庢粸鍚庢晥搴旓紝婊ゆ尝鍚庣殑淇″彿浼氭湁涓瀹氱殑寤惰繜锛屾棤娉曞嵆鏃跺弽鏄犱俊鍙风殑绐佸彉銆
      • 绱Н璇樊锛氬湪鏌愪簺鎯呭喌涓嬶紝闀挎椂闂翠娇鐢ㄥ彲鑳藉鑷磋宸疮绉紝灏ゅ叾鏄湪淇″彿鐗规у彂鐢熷彉鍖栨椂

    [AppleScript] 绾枃鏈煡鐪 澶嶅埗浠g爜
    //涓闃舵护娉
    // 纭繚lrAlpha鐨勫煎湪0鍜1涔嬮棿
    lrAlpha:=LIMIT(0,lrAlpha,1);
    // 鏍规嵁涓闃朵綆閫氭护娉㈠櫒鐨勫叕寮忚绠楁护娉㈠悗鐨勪俊鍙
    Filter_firstorder :=(1 - lrAlpha)* lrSignalIn + lrAlpha * lrTemp;
    lrTemp:= Filter_firstorder;



    锛戯紣.銆鍗″皵鏇兼护娉㈡硶
    • 鏂规硶锛

      • 棰勬祴銆佹洿鏂帮細鏍规嵁绯荤粺鐨勫姩鎬佹ā鍨嬮娴嬩笅涓鐘舵侊紝鍒╃敤鏂扮殑娴嬮噺鏁版嵁鏇存柊棰勬祴鐨勭姸鎬併
      • 鍗″皵鏇煎鐩婏細璁$畻鍗″皵鏇煎鐩婏紝瀹冩槸涓涓潈閲嶏紝鐢ㄤ簬骞宠 棰勬祴鍊煎拰瑙傛祴鍊笺
      • 閫掓帹鏇存柊锛氫娇鐢ㄥ崱灏旀浖澧炵泭锛岀粨鍚堥娴嬪煎拰瑙傛祴鍊硷紝閫掓帹鏇存柊浼拌鐨勭姸鎬併

    • 浼樼偣锛



      • 鏈浼樻э細鍦ㄩ珮鏂櫔澹板亣璁句笅锛屽崱灏旀浖婊ゆ尝鎻愪緵浜嗘渶灏忓潎鏂硅宸殑鏈浼樹及璁°
      • 閫掓帹鎬ц川锛氳兘澶熼掓帹鍦版洿鏂扮姸鎬佷及璁★紝閫傚悎瀹炴椂绯荤粺銆
      • 椴佹鎬э細瀵逛簬绯荤粺妯″瀷鐨勪笉纭畾鎬у拰娴嬮噺鍣0鍏锋湁涓瀹氱殑椴佹鎬с
      • 閫氱敤鎬э細閫傜敤浜庡悇绉嶇嚎鎬у姩鎬佺郴缁燂紝涔熼氳繃鎵╁睍锛堝鎵╁睍鍗″皵鏇兼护娉㈠拰鏃犺抗鍗″皵鏇兼护娉級鐢ㄤ簬闈炵嚎鎬х郴缁熴

    • 缂虹偣锛



      • 楂樻柉鍣0鍋囪锛氬崱灏旀浖婊ゆ尝鍩轰簬楂樻柉鍣0鐨勫亣璁撅紝瀵逛簬闈為珮鏂櫔澹板彲鑳戒笉鏄渶浼樼殑銆
      • 绾挎х郴缁熸ā鍨嬶細鏍囧噯鐨勫崱灏旀浖婊ゆ尝閫傜敤浜庣嚎鎬х郴缁熷拰绾挎ц娴嬫ā鍨嬶紝瀵逛簬楂樺害闈炵嚎鎬х郴缁熼渶瑕佷娇鐢ㄦ墿灞曠増鏈
      • 鏁忔劅鎬э細瀵瑰垵濮嬬姸鎬佷及璁″拰绯荤粺妯″瀷鍙傛暟鐨勫噯纭ф晱鎰燂紝閿欒鐨勫弬鏁板彲鑳藉鑷存浼樼殑婊ゆ尝鎬ц兘銆
      • 璁$畻澶嶆潅搴︼細瀵逛簬鍏锋湁澶ч噺鐘舵佸彉閲忕殑绯荤粺锛岃绠楀崗鏂瑰樊鐭╅樀鐨勬洿鏂板彲鑳藉叿鏈夎緝楂樼殑璁$畻澶嶆潅搴︺
      • 绋冲畾鎬ч棶棰橈細鍦ㄦ煇浜涙儏鍐典笅锛屽鍗忔柟宸煩闃甸潪姝e畾锛屽崱灏旀浖婊ゆ尝鍙兘涓嶇ǔ瀹氥

    [AppleScript] 绾枃鏈煡鐪 澶嶅埗浠g爜
    FUNCTION KalmanFilter2D : lreal
    VAR_INPUT  
        z: REAL;           // 娴嬮噺鍊硷紙浣嶇疆锛  
        intetime: REAL;          // 鏃堕棿闂撮殧  
        Q_pos: REAL;       // 浣嶇疆杩囩▼鍣0鍗忔柟宸  
        Q_vel: REAL;       // 閫熷害杩囩▼鍣0鍗忔柟宸  
        R_pos: REAL;       // 浣嶇疆娴嬮噺鍣0鍗忔柟宸  
    END_VAR  
      
    VAR_OUTPUT  
        xHat: REAL;        // 浼拌鐨勪綅缃  
        vHat: REAL;        // 浼拌鐨勯熷害  
    END_VAR  
      
    VAR  
        xHatPrev: REAL;    // 涓婁竴娆$殑浣嶇疆浼拌  
        vHatPrev: REAL;    // 涓婁竴娆$殑閫熷害浼拌  
        P_xx: REAL;        // 浣嶇疆浼拌璇樊鍗忔柟宸  
        P_xv: REAL;        // 浣嶇疆鍜岄熷害浼拌璇樊鍗忔柟宸  
        P_vv: REAL;        // 閫熷害浼拌璇樊鍗忔柟宸  
        K_x: REAL;         // 鍗″皵鏇煎鐩婏紙閽堝浣嶇疆锛  
        K_v: REAL;         // 锛堟湰渚嬩腑涓嶄娇鐢紝浣嗕负浜嗗畬鏁存т繚鐣欙級  
        P_xx_pred: REAL;
        RP_xv_pred: REAL;
         P_vv_pred: REAL;
        S1: REAL;
        v: REAL;
      
        A_mat: ARRAY[1..2, 1..2] OF REAL;  
        Q_mat: ARRAY[1..2, 1..2] OF REAL;  
        C_mat: ARRAY[1..1, 1..2] OF REAL;  
    END_VAR 
        // 鍒濆鍖栫煩闃  
        A_mat[1,1] := 1; A_mat[1,2] := intetime;  
        A_mat[2,1] := 0; A_mat[2,2] := 1;  
      
        Q_mat[1,1] := Q_pos * intetime*intetime*intetime / 3 + Q_vel * intetime;  
        Q_mat[1,2] := Q_pos * intetime*intetime / 2;  
        Q_mat[2,1] := Q_pos * intetime*intetime / 2;  
        Q_mat[2,2] := Q_pos * intetime;  
      
        C_mat[1,1] := 1; C_mat[1,2] := 0;  
      
        // 棰勬祴姝ラ  
        xHatPrev := xHat;  
        vHatPrev := vHat + intetime * vHat; // 绠鍖栫殑閫熷害棰勬祴锛堝亣璁惧姞閫熷害涓0锛  
      
        // 鍗忔柟宸娴嬶紙杩欓噷绠鍖栦簡鐭╅樀杩愮畻锛屽疄闄呬腑鍙兘闇瑕佹洿澶嶆潅鐨勫鐞嗭級  
        P_xx_pred := P_xx + Q_mat[1,1];  
        RP_xv_pred := P_xv + Q_mat[1,2];  
        P_vv_pred := P_vv + Q_mat[2,2];  
      
        // 鏇存柊姝ラ锛堣繖閲屽彧鏇存柊浣嶇疆鐩稿叧鐨勫崱灏旀浖澧炵泭鍜岀姸鎬侊級  
       S1 := P_xx_pred + R_pos;  
        K_x := P_xx_pred / S1;  
      
        xHat := xHatPrev + K_x * (z - xHatPrev);  
        vHat := v;


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

    浣跨敤閬撳叿 涓炬姤

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

    鏈増绉垎瑙勫垯

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

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

    GMT+8, 2024-11-23 20:28 , Processed in 0.152721 second(s), 60 queries .

    閰峰痉缃

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

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