lpf
Dependents: 06_MD_practice 2020BAuto 106_MD_practice
Revision 0:dedf16377e0f, committed 2020-01-25
- Comitter:
- THtakahiro702286
- Date:
- Sat Jan 25 09:11:57 2020 +0000
- Commit message:
- lpf
Changed in this revision
lpf.cpp | Show annotated file Show diff for this revision Revisions of this file |
lpf.h | Show annotated file Show diff for this revision Revisions of this file |
diff -r 000000000000 -r dedf16377e0f lpf.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lpf.cpp Sat Jan 25 09:11:57 2020 +0000 @@ -0,0 +1,37 @@ +#include "mbed.h" +#include "lpf.h" + +lpf::lpf(float system_cycle_second_,float arrive_time_){ + + /* + 引数1 制御周期(秒) + 引数2 何秒で目標値へ到達させたいか(s)時定数ではない + */ + + system_cycle_second = system_cycle_second_; + f_t_const = arrive_time_; + one_before_output = 0.0; + output=0.0; +} + +float lpf::path_value(float target_value){ + + output = ((system_cycle_second * target_value) + (f_t_const * one_before_output))/(system_cycle_second + f_t_const); + one_before_output = output; + + return output; +} + + +void lpf::change_time_constant(float change_time_constant_){ + + f_t_const = change_time_constant_; +} + + +void lpf::reset(void){ + + output = 0.0; + one_before_output = 0.0; + +} \ No newline at end of file
diff -r 000000000000 -r dedf16377e0f lpf.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lpf.h Sat Jan 25 09:11:57 2020 +0000 @@ -0,0 +1,20 @@ +#ifndef _LPF_H_ +#define _LPF_H_ + +class lpf{ + public: + lpf(float,float); //コンストラクタ 引数1:制御周期(s) 引数2:何秒で目標値に到達してほしいか(s) + float path_value(float); //ローパスフィルタ通過後の値を返す + void change_time_constant(float); //時定数を変更するための関数 + void reset(void); //一定の処理が終わった時に前回の偏差を0に戻す関数 + + float one_before_output; //前回の出力値を保管 + + private: + float system_cycle_second; //制御周期 + float f_t_const; //フィルタリング時定数(filtering_time_constant) + float output; + + +}; +#endif \ No newline at end of file