网上找了一个滤波的程序,看了一大顿没看明白,有哪位大侠给讲解一下?

已锁定

小釉

  • 帖子

    2758
  • 精华

    26
  • 被关注

    62

论坛等级:至圣

注册时间:2011-05-12

钻石 钻石 如何晋级?

网上找了一个滤波的程序,看了一大顿没看明白,有哪位大侠给讲解一下?

1535

4

2011-12-23 13:25:33

(* ============================================================================= *)
(* PURPOSE : To filter a value by applying a first-order exponential filter *)
(* with a user-selectable time period, F-tau. The filter is calculated *)
(* using the following formula - *)
(* *)
(* Rate Rate *)
(* FiltOut := FiltOut * e + RawValue * (1 - e ) *)
(* *)
(* where Rate := (-0.1 / F_tau ) *)
(* *)
(* The Function Block is intended to be triggered every 100mS (hence *)
(* the 0.1 in the formula) from cyclic interrupt Organization Block *)
(* OB35. If a different resolution is required, use a different OB as *)
(* the trigger, and adjust the formula to reflect this. *)
(* *)
(* ============================================================================= *)


FUNCTION_BLOCK FB200
TITLE = 'Low Pass Filter'
VERSION : '1.0'
AUTHOR : KenMuir
NAME : LowPass
FAMILY : Filter


(* ----------------------------- *)
(* DEFINITION OF LOCAL VARIABLES *)
(* ----------------------------- *)


VAR_INPUT
RawValue : REAL; // Incoming unfiltered value
F_tau : REAL; // Time interval (in seconds) for filter period
END_VAR

VAR_OUTPUT
FiltOut : REAL; // Filtered output value
ZRError : BOOL; // Error flag if F_tau is set to zero (invalid rate)
END_VAR

VAR
LastFV : REAL; // Static variable holds value of FiltOut from previous
END_VAR // execution cycle.

VAR_TEMP
ExpRate : REAL; // Equals exp(-0.1 / F_tau)
END_VAR


(* ----------------------------- *)
(* START OF CODE SECTION *)
(* ----------------------------- *)

BEGIN

IF F_tau = 0.0 THEN // If the filter period is set to zero ...
ZRError := true; // .. . set the Zero Rate Error bit true
ELSE
ZRError := false; // Error bit reset to false
ExpRate := EXP(-0.1 / F_tau);
FiltOut := LastFV * ExpRate + (RawValue * (1 - ExpRate)); // Calculate new output
LastFV := FiltOut; // Store output value for next cycle of calculation
END_IF;


END_FUNCTION_BLOCK

这个是低通滤波的例子。低通滤波,还有在西门子的文档中还可以看到pt1 filter,这两者是否是一回事?
网上找了一个滤波的程序,看了一大顿没看明白,有哪位大侠给讲解一下? 已锁定
编辑推荐: 关闭

请填写推广理由:

本版热门话题

SIMATIC S7-300/400

共有54618条技术帖

相关推荐

热门标签

相关帖子推荐

guzhang

恭喜,你发布的帖子

评为精华帖!

快扫描右侧二维码晒一晒吧!

再发帖或跟帖交流2条,就能晋升VIP啦!开启更多专属权限!

  • 分享

  • 只看
    楼主

top
您收到0封站内信:
×
×
信息提示
很抱歉!您所访问的页面不存在,或网址发生了变化,请稍后再试。