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.
Dependencies: mbed
Diff: PI_Cntrl.cpp
- Revision:
- 5:d6c7ccbbce78
- Parent:
- 0:15be70d21d7c
- Child:
- 8:d68e177e2571
--- a/PI_Cntrl.cpp Thu Mar 01 13:48:32 2018 +0000
+++ b/PI_Cntrl.cpp Fri Mar 09 12:53:45 2018 +0000
@@ -29,8 +29,9 @@
float PI_Cntrl::doStep(float error){
float kpe = Kp * error;
- float i_part = 1.0f/Tn * Ts * (kpe-del) + i_part_old; // I with windup subtraction
- float y_out_temp = (kpe + i_part_old ); // temporary variable
+ float i_part = Ts/Tn*(kpe-1.0f*del) + i_part_old; // I with windup subtraction
+ i_part_old = i_part;
+ float y_out_temp = (kpe + i_part); // unconstrained output
float y_out;
// -------- limit output --------
if(y_out_temp > out_max)
@@ -42,6 +43,6 @@
// -------- Anti-Windup --------
del = (y_out_temp - y_out);
// -------- Timeshift --------
- i_part_old = i_part;
+
return y_out;
}
\ No newline at end of file