1次遅れと2次遅れ,ノッチフィルターを実装
Fork of Filter by
Diff: Filter.cpp
- Revision:
- 2:a842c1a33e4f
- Parent:
- 1:637f9a61b133
- Child:
- 3:987d5d78f863
diff -r 637f9a61b133 -r a842c1a33e4f Filter.cpp --- a/Filter.cpp Thu Jan 11 06:53:03 2018 +0000 +++ b/Filter.cpp Thu Jan 11 07:00:44 2018 +0000 @@ -14,7 +14,7 @@ { static double preOutput = 0.0; - double Output = (INT_TIME * input + T_LPF * preOutput)/(T_LPF + INT_TIME); + double Output = (int_time * input + T_LPF * preOutput)/(T_LPF + int_time); preOutput = Output; @@ -26,7 +26,7 @@ // 落としたい角周波数[rad/s]をOm_nに入れる Om_n = Omega; sq_Om = pow(Om_n, 2.0); // Om_nの2乗 - sq_dt = pow(INT_TIME, 2.0); // dtの2乗 + sq_dt = pow(int_time, 2.0); // dtの2乗 } @@ -35,7 +35,7 @@ static double preOutput[2] = {0.0, 0.0}; static double preInput[2] = {0.0, 0.0}; - double Output = (2*(1 + Om_n * INT_TIME) * preOutput[0]-preOutput[1] + (1 + sq_Om * sq_dt) * input -2 * preInput[0] + preInput[1]) / (1 + 2 * Om_n * INT_TIME + sq_Om * sq_dt); + double Output = (2*(1 + Om_n * int_time) * preOutput[0]-preOutput[1] + (1 + sq_Om * sq_dt) * input -2 * preInput[0] + preInput[1]) / (1 + 2 * Om_n * int_time + sq_Om * sq_dt); preInput[1] = preInput[0]; preInput[0] = input;