ろーぱすふぃるた

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers lpf.cpp Source File

lpf.cpp

00001 #include "mbed.h"
00002 #include "lpf.h"
00003 
00004 lpf::lpf(float system_cycle_second_,float arrive_time_){
00005 
00006     /*
00007         引数1 制御周期(秒)
00008         引数2 何秒で目標値へ到達させたいか(s)時定数ではない
00009     */
00010     
00011     system_cycle_second = system_cycle_second_;
00012     f_t_const = arrive_time_;
00013     one_before_output = 0.0;
00014     output=0.0;
00015 }
00016 
00017 float lpf::path_value(float target_value){
00018      
00019     output = ((system_cycle_second * target_value) + (f_t_const * one_before_output))/(system_cycle_second + f_t_const);
00020     one_before_output = output;
00021     
00022     return output;
00023 }
00024 
00025 
00026 void lpf::change_time_constant(float change_time_constant_){
00027     
00028     f_t_const = change_time_constant_;
00029 }
00030 
00031 
00032 void lpf::reset(void){
00033     
00034     output = 0.0;
00035     one_before_output = 0.0;
00036     
00037 }