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: shared/PID_Control/I_PD/I_PD.cpp
- Revision:
- 0:ee7e9405e1c7
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/shared/PID_Control/I_PD/I_PD.cpp Wed Apr 14 07:26:19 2021 +0000
@@ -0,0 +1,28 @@
+#include "I_PD.h"
+
+double I_PD::_get_control()
+{
+ return PID::_pid_state.k * (_i - (_p +_d));
+}
+void I_PD::_calc_p()
+{
+ _update(_diff, PID::_pid_state.target - PID::_pid_state.current);
+ _update(_measure, PID::_pid_state.target);
+ _p = _measure[1];
+}
+void I_PD::_calc_i()
+{
+ _integral += (_diff[0] + _diff[1]) / 2;
+ _i = _integral;
+}
+void I_PD::_calc_d()
+{
+ _d = _measure[1] - _measure[0];
+}
+void I_PD::_reset()
+{
+ _p = _i = _d = 0;
+ _diff[0] = _diff[1] = 0;
+ _integral = 0;
+ _measure[0] = _measure[1] = 0;
+}