//-------------------------------------------------------// // Project Code : CodeLibrary // File Name : PI_Ctrl.cpp // Created on : 2019. 06. 07. // Description : PI 제어기 // Author : KimJeongWoo // Last modified Date : //-------------------------------------------------------// #include #include void sPiCtrl::Reset() { Err = 0; fb = 0; Integ = 0; out = 0; } float sPiCtrl::Run() { Integ += Ki * (Err - Ka * (fb - out)); // Integ = LIMITER(Integ, PImax, PImin); fb = Integ + Kp * Err + ff; // PI out = LIMITER(fb, PiMax, PiMin); return out; } void sPiCtrl::Init(float mKp, float mKi, float mKa, float mWc, float mTprd, float mPI_Max, float mPI_Min) { Kp = mKp; Ki = mKi; Ka = mKa; Wc = mWc; Tprd = mTprd; PiMax = mPI_Max; PiMin = mPI_Min; }