![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
CQエレクトロニクス・セミナ「実習・マイコンを動かしながら学ぶディジタル・フィルタ」で使うプログラム.1次IIRフィルタの係数をターミナルから変更できる. http://seminar.cqpub.co.jp/ccm/ES18-0020
Dependencies: mbed Array_Matrix BSP_DISCO_F746NG LCD_DISCO_F746NG TS_DISCO_F746NG
Filter/IIR1_Variable.hpp@0:47718d3154d9, 2017-10-09 (annotated)
- Committer:
- MikamiUitOpen
- Date:
- Mon Oct 09 02:36:11 2017 +0000
- Revision:
- 0:47718d3154d9
1
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
MikamiUitOpen | 0:47718d3154d9 | 1 | //--------------------------------------------------- |
MikamiUitOpen | 0:47718d3154d9 | 2 | // 一次の IIR フィルタ ― 係数可変 |
MikamiUitOpen | 0:47718d3154d9 | 3 | // |
MikamiUitOpen | 0:47718d3154d9 | 4 | // 2017/09/24, Copyright (c) 2017 MIKAMI, Naoki |
MikamiUitOpen | 0:47718d3154d9 | 5 | //--------------------------------------------------- |
MikamiUitOpen | 0:47718d3154d9 | 6 | |
MikamiUitOpen | 0:47718d3154d9 | 7 | #ifndef IIR_1ST_VARIABLE_HPP |
MikamiUitOpen | 0:47718d3154d9 | 8 | #define IIR_1ST_VARIABLE_HPP |
MikamiUitOpen | 0:47718d3154d9 | 9 | |
MikamiUitOpen | 0:47718d3154d9 | 10 | #include "mbed.h" |
MikamiUitOpen | 0:47718d3154d9 | 11 | |
MikamiUitOpen | 0:47718d3154d9 | 12 | class Iir1Variable |
MikamiUitOpen | 0:47718d3154d9 | 13 | { |
MikamiUitOpen | 0:47718d3154d9 | 14 | public: |
MikamiUitOpen | 0:47718d3154d9 | 15 | Iir1Variable(float a1) |
MikamiUitOpen | 0:47718d3154d9 | 16 | : a1_(a1), b0_(1.0f - a1), yn_(0) {} |
MikamiUitOpen | 0:47718d3154d9 | 17 | |
MikamiUitOpen | 0:47718d3154d9 | 18 | // フィルタ処理を実行する |
MikamiUitOpen | 0:47718d3154d9 | 19 | int16_t Execute(int16_t xn) |
MikamiUitOpen | 0:47718d3154d9 | 20 | { |
MikamiUitOpen | 0:47718d3154d9 | 21 | yn_ = a1_*yn_ + b0_*xn; |
MikamiUitOpen | 0:47718d3154d9 | 22 | |
MikamiUitOpen | 0:47718d3154d9 | 23 | return (int16_t)yn_; |
MikamiUitOpen | 0:47718d3154d9 | 24 | } |
MikamiUitOpen | 0:47718d3154d9 | 25 | |
MikamiUitOpen | 0:47718d3154d9 | 26 | void SetCoefs(float a1) |
MikamiUitOpen | 0:47718d3154d9 | 27 | { |
MikamiUitOpen | 0:47718d3154d9 | 28 | a1_ = a1; |
MikamiUitOpen | 0:47718d3154d9 | 29 | b0_ = 1.0f - a1; |
MikamiUitOpen | 0:47718d3154d9 | 30 | } |
MikamiUitOpen | 0:47718d3154d9 | 31 | |
MikamiUitOpen | 0:47718d3154d9 | 32 | private: |
MikamiUitOpen | 0:47718d3154d9 | 33 | float a1_; // 係数 |
MikamiUitOpen | 0:47718d3154d9 | 34 | float b0_; // 係数 |
MikamiUitOpen | 0:47718d3154d9 | 35 | float yn_; |
MikamiUitOpen | 0:47718d3154d9 | 36 | }; |
MikamiUitOpen | 0:47718d3154d9 | 37 | #endif // IIR_1ST_VARIABLE_HPP |