Dependents:   YMotor

Fork of PID by tarou yamada

Committer:
inst
Date:
Tue Apr 26 08:25:02 2016 +0000
Revision:
6:4427687e6dbe
Parent:
4:ed6aea0299df

        

Who changed what in which revision?

UserRevisionLine numberNew contents of line
inst 4:ed6aea0299df 1 #ifndef INCLUDED_MBED_STL_PID_H
inst 4:ed6aea0299df 2 #define INCLUDED_MBED_STL_PID_H
inst 4:ed6aea0299df 3
inst 6:4427687e6dbe 4 #include "mbed.h"
inst 6:4427687e6dbe 5
inst 4:ed6aea0299df 6 namespace mbed_stl {
inst 2:73618cad4762 7
inst 6:4427687e6dbe 8 // ErrTypeは偏差の型.MVTypeは操作量の型.KTypeは係数の型.
inst 6:4427687e6dbe 9 template <typename ErrType, typename MVType = ErrType, typename KType = ErrType>
inst 2:73618cad4762 10 class PID{
inst 2:73618cad4762 11 public:
inst 6:4427687e6dbe 12 PID(KType kp, KType ki, KType kd);
inst 2:73618cad4762 13
inst 6:4427687e6dbe 14 MVType update(ErrType error);
inst 2:73618cad4762 15
inst 2:73618cad4762 16 private:
inst 6:4427687e6dbe 17 const KType kp_; // 比例制御係数
inst 6:4427687e6dbe 18 const KType ki_; // 積分制御係数
inst 6:4427687e6dbe 19 const KType kd_; // 微分制御係数
inst 2:73618cad4762 20
inst 6:4427687e6dbe 21 ErrType integral_;
inst 6:4427687e6dbe 22 ErrType prev_error_;
inst 6:4427687e6dbe 23
inst 6:4427687e6dbe 24 Timer timer_;
inst 6:4427687e6dbe 25 float prev_time_us_;
inst 2:73618cad4762 26 };
inst 2:73618cad4762 27
inst 4:ed6aea0299df 28 } /* namespace mbed_stl */
inst 4:ed6aea0299df 29
inst 2:73618cad4762 30 #include "PID_impl.hpp"
inst 2:73618cad4762 31
inst 6:4427687e6dbe 32 typedef mbed_stl::PID<float> PID_f;
inst 6:4427687e6dbe 33 typedef mbed_stl::PID<double> PID_d;
inst 6:4427687e6dbe 34
inst 2:73618cad4762 35 #endif