ろーぱすふぃるた

Committer:
THtakahiro702286
Date:
Mon Jan 27 08:54:14 2020 +0000
Revision:
0:f252bd51e899
low path filter;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
THtakahiro702286 0:f252bd51e899 1 #include "mbed.h"
THtakahiro702286 0:f252bd51e899 2 #include "lpf.h"
THtakahiro702286 0:f252bd51e899 3
THtakahiro702286 0:f252bd51e899 4 lpf::lpf(float system_cycle_second_,float arrive_time_){
THtakahiro702286 0:f252bd51e899 5
THtakahiro702286 0:f252bd51e899 6 /*
THtakahiro702286 0:f252bd51e899 7 引数1 制御周期(秒)
THtakahiro702286 0:f252bd51e899 8 引数2 何秒で目標値へ到達させたいか(s)時定数ではない
THtakahiro702286 0:f252bd51e899 9 */
THtakahiro702286 0:f252bd51e899 10
THtakahiro702286 0:f252bd51e899 11 system_cycle_second = system_cycle_second_;
THtakahiro702286 0:f252bd51e899 12 f_t_const = arrive_time_;
THtakahiro702286 0:f252bd51e899 13 one_before_output = 0.0;
THtakahiro702286 0:f252bd51e899 14 output=0.0;
THtakahiro702286 0:f252bd51e899 15 }
THtakahiro702286 0:f252bd51e899 16
THtakahiro702286 0:f252bd51e899 17 float lpf::path_value(float target_value){
THtakahiro702286 0:f252bd51e899 18
THtakahiro702286 0:f252bd51e899 19 output = ((system_cycle_second * target_value) + (f_t_const * one_before_output))/(system_cycle_second + f_t_const);
THtakahiro702286 0:f252bd51e899 20 one_before_output = output;
THtakahiro702286 0:f252bd51e899 21
THtakahiro702286 0:f252bd51e899 22 return output;
THtakahiro702286 0:f252bd51e899 23 }
THtakahiro702286 0:f252bd51e899 24
THtakahiro702286 0:f252bd51e899 25
THtakahiro702286 0:f252bd51e899 26 void lpf::change_time_constant(float change_time_constant_){
THtakahiro702286 0:f252bd51e899 27
THtakahiro702286 0:f252bd51e899 28 f_t_const = change_time_constant_;
THtakahiro702286 0:f252bd51e899 29 }
THtakahiro702286 0:f252bd51e899 30
THtakahiro702286 0:f252bd51e899 31
THtakahiro702286 0:f252bd51e899 32 void lpf::reset(void){
THtakahiro702286 0:f252bd51e899 33
THtakahiro702286 0:f252bd51e899 34 output = 0.0;
THtakahiro702286 0:f252bd51e899 35 one_before_output = 0.0;
THtakahiro702286 0:f252bd51e899 36
THtakahiro702286 0:f252bd51e899 37 }