Dual-phase oscillator using 2nd-order IIR filter.
Dependencies: UITDSP_ADDA mbed
Revision 1:60bb239847c3, committed 2016-02-23
- Comitter:
- MikamiUitOpen
- Date:
- Tue Feb 23 00:28:02 2016 +0000
- Parent:
- 0:45f7919cc254
- Commit message:
- 2
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Tue Feb 16 06:50:27 2016 +0000 +++ b/main.cpp Tue Feb 23 00:28:02 2016 +0000 @@ -1,7 +1,7 @@ //------------------------------------------------------------------------------ // cos波,sin波の同時発生,2次の IIR フィルタを使う方法 // アルゴリズム検証用プログラムのため,無駄な部分あり -// 2016/02/16, Copyright (c) 2016 MIKAMI, Naoki +// 2016/02/23, Copyright (c) 2016 MIKAMI, Naoki //------------------------------------------------------------------------------ #include "ADC_BuiltIn.hpp" // かならず必要 @@ -25,21 +25,20 @@ float un1 = 0; // u[-1] = 0; float un2 = 0; // u[-2] = 0; - float xn1 = 1; // x[-1] - + float xn = 1; // x[n], 単位インパルス while (true) { - float xn = adc_.Read(); // A0 からの入力信号を読み込む(ダミー) + adc_.Read(); // 標本化クロックと同期をとるために必要 //----------------------------------------------- - xn = 0; - float un = a1*un1 - un2 + xn1; + float un = a1*un1 - un2 + xn; float ynS = un1*b1S; // sin float ynC = un - un1*b1C; // cos - xn1 = xn; un2 = un1; un1 = un; + + xn = 0; // 単位インパルスなので次からは 0 //----------------------------------------------- myDac_.Write(0.8f*ynS, 0.8f*ynC); // DAC へ出力する }