Fork of PID by
PID_impl.hpp
- Committer:
- inst
- Date:
- 2016-03-03
- Revision:
- 4:ed6aea0299df
- Parent:
- 3:b28b34b89120
- Child:
- 5:82bc9c845760
File content as of revision 4:ed6aea0299df:
#ifndef INCLUDED_PID_IMPL_H #define INCLUDED_PID_IMPL_H #include "PID.hpp" namespace mbed_stl { template <typename T, typename K> PID<T, K>::PID(K kp, K ki, K kd) : kp_(kp), ki_(ki), kd_(kd), integral_(), prev_error_() {} template <typename T, typename K> inline T PID<T, K>::update(T error) { // P制御(比例) T mv = kp_ * error; // I制御(積分) mv += ki_ * error; integral_ += error; // D制御(微分) mv += kd_ * (error - prev_error_); prev_error_ = error; return mv; } } /* namespace mbed_stl */ #endif