![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
The experiment using this program is introduced on "Interface" No.12, CQ publishing Co.,Ltd, 2014. 本プログラムを使った実験は,CQ出版社のインターフェース 2014年12月号で紹介しています.
Dependencies: DSProcessingIO mbed
FIR_LPF_Symmetry.cpp@0:4498a5360dde, 2014-07-15 (annotated)
- Committer:
- CQpub0Mikami
- Date:
- Tue Jul 15 08:21:30 2014 +0000
- Revision:
- 0:4498a5360dde
1
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
CQpub0Mikami | 0:4498a5360dde | 1 | //-------------------------------------------------------------- |
CQpub0Mikami | 0:4498a5360dde | 2 | // FIR filter: Even order, Symmetric structure of direct form |
CQpub0Mikami | 0:4498a5360dde | 3 | // |
CQpub0Mikami | 0:4498a5360dde | 4 | // Copyright (c) 2014 MIKAMI, Naoki, 2014/06/20 |
CQpub0Mikami | 0:4498a5360dde | 5 | //-------------------------------------------------------------- |
CQpub0Mikami | 0:4498a5360dde | 6 | |
CQpub0Mikami | 0:4498a5360dde | 7 | #include "mbed.h" |
CQpub0Mikami | 0:4498a5360dde | 8 | #include "AdcInternal.hpp" |
CQpub0Mikami | 0:4498a5360dde | 9 | #include "MCP4922Single.hpp" |
CQpub0Mikami | 0:4498a5360dde | 10 | #include "coefficientsSym_200.hpp" |
CQpub0Mikami | 0:4498a5360dde | 11 | #include "FIR_Symmetry.hpp" |
CQpub0Mikami | 0:4498a5360dde | 12 | |
CQpub0Mikami | 0:4498a5360dde | 13 | using namespace Mikami; |
CQpub0Mikami | 0:4498a5360dde | 14 | |
CQpub0Mikami | 0:4498a5360dde | 15 | // sampling frequency |
CQpub0Mikami | 0:4498a5360dde | 16 | const float FS_ = 10.0e3f; |
CQpub0Mikami | 0:4498a5360dde | 17 | |
CQpub0Mikami | 0:4498a5360dde | 18 | Adc adc_(A0); |
CQpub0Mikami | 0:4498a5360dde | 19 | Dac dacA_(Dac::DAC_A); |
CQpub0Mikami | 0:4498a5360dde | 20 | Ticker timer_; // for timer interrupt |
CQpub0Mikami | 0:4498a5360dde | 21 | |
CQpub0Mikami | 0:4498a5360dde | 22 | FirSymmetry<ORDER_> lpf(hm_); |
CQpub0Mikami | 0:4498a5360dde | 23 | |
CQpub0Mikami | 0:4498a5360dde | 24 | void TimerIsr() |
CQpub0Mikami | 0:4498a5360dde | 25 | { |
CQpub0Mikami | 0:4498a5360dde | 26 | float xn = adc_.Read(); // input |
CQpub0Mikami | 0:4498a5360dde | 27 | |
CQpub0Mikami | 0:4498a5360dde | 28 | // Execute FIR filter |
CQpub0Mikami | 0:4498a5360dde | 29 | float yn = lpf.Execute(xn); |
CQpub0Mikami | 0:4498a5360dde | 30 | |
CQpub0Mikami | 0:4498a5360dde | 31 | dacA_.Write(yn); // output |
CQpub0Mikami | 0:4498a5360dde | 32 | } |
CQpub0Mikami | 0:4498a5360dde | 33 | |
CQpub0Mikami | 0:4498a5360dde | 34 | int main() |
CQpub0Mikami | 0:4498a5360dde | 35 | { |
CQpub0Mikami | 0:4498a5360dde | 36 | timer_.attach_us(&TimerIsr, 1.0e6f/FS_); |
CQpub0Mikami | 0:4498a5360dde | 37 | |
CQpub0Mikami | 0:4498a5360dde | 38 | while (true) {} // infinite loop |
CQpub0Mikami | 0:4498a5360dde | 39 | } |
CQpub0Mikami | 0:4498a5360dde | 40 |