pr7

Dependencies:   mbed

Committer:
pmic
Date:
Fri May 10 14:25:24 2019 +0000
Revision:
1:92f175969d90
Parent:
0:05dd1de8cc3f
Child:
2:1ded9d10f322
A few cosmetic improvements, version can be compiled and loaded on nucleo

Who changed what in which revision?

UserRevisionLine numberNew contents of line
pmic 1:92f175969d90 1 /*
pmic 1:92f175969d90 2 PID-T1 Controller class
pmic 1:92f175969d90 3
pmic 1:92f175969d90 4 1 s
pmic 1:92f175969d90 5 G(s) = Kp + Ki --- + Kd ---------
pmic 1:92f175969d90 6 s T_f*s + p
pmic 1:92f175969d90 7
pmic 1:92f175969d90 8 Eigther reseting the Nucleo via the black button or save a new software on
pmic 1:92f175969d90 9 the Nucleo sets the analog output to zero. Zero is equal to -4 Ampere!!!
pmic 1:92f175969d90 10 Therefor: NEVER !!! reset or save a new software while the VC is powered on
pmic 1:92f175969d90 11 (the green button on the VC is glowing green)
pmic 1:92f175969d90 12
altb2 0:05dd1de8cc3f 13 */
altb2 0:05dd1de8cc3f 14
altb2 0:05dd1de8cc3f 15 #include "PID_Cntrl.h"
altb2 0:05dd1de8cc3f 16 using namespace std;
altb2 0:05dd1de8cc3f 17
pmic 1:92f175969d90 18 PID_Cntrl::PID_Cntrl(float Kp, float Ki, float Kd, float Tf, float Ts, float uMin, float uMax)
altb2 0:05dd1de8cc3f 19 {
pmic 1:92f175969d90 20 // link member variables
pmic 1:92f175969d90 21 // ???
pmic 1:92f175969d90 22
altb2 0:05dd1de8cc3f 23 reset(0.0f);
altb2 0:05dd1de8cc3f 24 }
altb2 0:05dd1de8cc3f 25
altb2 0:05dd1de8cc3f 26 PID_Cntrl::~PID_Cntrl() {}
altb2 0:05dd1de8cc3f 27
altb2 0:05dd1de8cc3f 28 void PID_Cntrl::reset(float initValue)
altb2 0:05dd1de8cc3f 29 {
pmic 1:92f175969d90 30
pmic 1:92f175969d90 31 // implement controller reset
pmic 1:92f175969d90 32 // ???
altb2 0:05dd1de8cc3f 33
altb2 0:05dd1de8cc3f 34 }
altb2 0:05dd1de8cc3f 35
altb2 0:05dd1de8cc3f 36 float PID_Cntrl::update(double e)
altb2 0:05dd1de8cc3f 37 {
pmic 1:92f175969d90 38
pmic 1:92f175969d90 39 // controller update function
pmic 1:92f175969d90 40
pmic 1:92f175969d90 41 // calculate uI
pmic 1:92f175969d90 42 // ???
altb2 0:05dd1de8cc3f 43
pmic 1:92f175969d90 44 // saturate uI, uMin <= uI <= uMax (anti-windup for the integrator part)
pmic 1:92f175969d90 45 // ???
pmic 1:92f175969d90 46
pmic 1:92f175969d90 47 // calculate uD
pmic 1:92f175969d90 48 // ???
pmic 1:92f175969d90 49
pmic 1:92f175969d90 50 // calculate u
pmic 1:92f175969d90 51 // ???
pmic 1:92f175969d90 52
pmic 1:92f175969d90 53 // saturate u, uMin <= u <= uMax
pmic 1:92f175969d90 54 // ???
pmic 1:92f175969d90 55
pmic 1:92f175969d90 56 // update signal storage
pmic 1:92f175969d90 57 // ???
pmic 1:92f175969d90 58
altb2 0:05dd1de8cc3f 59 return 0.0f;
altb2 0:05dd1de8cc3f 60 }
altb2 0:05dd1de8cc3f 61