Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: PID.cpp
- Revision:
- 1:4705d8930670
- Parent:
- 0:be531c5604db
- Child:
- 2:c8ab3e8d4c51
--- a/PID.cpp Fri Jan 11 08:00:51 2019 +0000 +++ b/PID.cpp Sun Apr 07 13:52:44 2019 +0000 @@ -1,15 +1,16 @@ #include "PID.h" #include "mbed.h" -PID::PID(){ +PID::PID(Timer *_timer){ integral = 0; prev_hensa = 0; nowtime = 0; prev_time = 0; lateD = 0; + timer = _timer; } -float PID::control(float target, float nowrpm, Timer *timer){ +float PID::control(float target, float nowrpm){ //timer->start(); nowtime =timer->read(); float hensa = target - nowrpm; @@ -22,7 +23,7 @@ return sousaryou; } -float PID::PI_lateD(float target, float nowrpm, Timer *timer){ +float PID::PI_lateD(float target, float nowrpm){ nowtime = (*timer).read(); float hensa = target - nowrpm; float dt = nowtime - prev_time; @@ -40,7 +41,7 @@ return sousaryou; } -float PID::control_PI(float target, float nowrpm, Timer *timer){ +float PID::control_PI(float target, float nowrpm){ Kp = 0.45 * Ku; Ti = 0.83 * Pu; Ki = (1 / Ti) * Kp;