Changeset 1251 for applications/pmsm
- Timestamp:
- 11/14/10 23:11:49 (14 years ago)
- Location:
- applications/pmsm
- Files:
-
- 2 modified
Legend:
- Unmodified
- Added
- Removed
-
applications/pmsm/experiments/ctrl.cfg
r1247 r1251 9 9 params = "pmsm107@../cfg/zcu.cfg"; 10 10 tstep = 1; // steps for profile in [s] 11 // profileW = [0, 0, -30, -200, -90, -60, -30, 0, 30, 200];12 profileW = [0, -10, 30, 60, 90, 60, 30, 0, -30, -60, -30];11 profileW = [0, 30, 0, 2 ]; 12 // profileW = [0, -10, 30, 60, 90, 60, 30, 0, -30, -60, -30]; 13 13 // profileW = [1, 10, 50, 200, 200, 30, 0, 0, -30, -30, -100, -100, -40, 0, 0]; 14 14 // profileM = [0, 30, 0, 0, 30, 0, 0, 0, 0, 0, 10, 0, 0]; … … 21 21 }; 22 22 OM = {class="OMpmsm";}; 23 dQ=[0.01, 0.01, 0.0001, 0.000 1];23 dQ=[0.01, 0.01, 0.0001, 0.0000000001]; 24 24 dR=[0.05, 0.05]; 25 25 //connect 26 yrv = {class="RV"; names=("o_ia","o_ib");}; // observed u 27 rvc = {class="RV"; names=("t_ua","t_ub");}; // observed u 28 rv = {class="RV"; names=("ia","ib","om","th");}; 29 log_level="logmean,logevidence,logU,logG,logD"; 26 log_level="logmean,logU,logG,logD"; 30 27 name = "Est0"; 31 28 }; -
applications/pmsm/pmsm_ctrl.h
r1243 r1251 35 35 }; 36 36 37 class PMSM_PICtrl: public Controller{ 37 /*! \brief Root class for controllers of PMSM 38 * 39 * It defines the interface for controllers that connect to the pmsmDSctrl. 40 * The adapt() function calls bayes() of an internal BM. Note that it is assumed that the estimator is compatible with PMSM system. 41 * I.e. it must have rv={ia, ib} and rvc={ua,ub}, any other BM will not work. 42 * 43 */ 44 class PMSMCtrl: public Controller{ 38 45 protected: 46 //! Est where rv and rcv are not used! 39 47 shared_ptr<BM> Est; 40 vec state; 48 //! switch to use or not to use the internal estimator 49 bool estim; 50 51 // internal quantities filled by PMSMCtrl::ctrlaction() 52 double isa; 53 double isb; 54 double ome; 55 double the; 56 double Ww; 57 58 public: 59 60 PMSMCtrl():Controller() { 61 rv = RV("{ua ub }"); 62 rvc = RV("{o_ia o_ib o_ua o_ub o_om o_th Ww }"); 63 } 64 65 void adapt(const itpp::vec& data){ 66 if (estim){ 67 vec y=data.get(0,1); 68 vec u=data.get(2,3); 69 Est->bayes(y,u); 70 } 71 } 72 73 74 virtual vec ctrlaction(const itpp::vec& cond) { 75 76 if (estim){ 77 vec x_est=Est->posterior().mean(); 78 isa=x_est(0); 79 isb=x_est(1); 80 ome=x_est(2); 81 the=x_est(3); 82 } else { 83 isa=cond(0);//x_est(0); 84 isb=cond(1);//x_est(1); 85 ome=cond(4);//x[2];//x_est(2); 86 the=cond(5);//x_est(3); 87 } 88 Ww=cond(6); 89 90 return empty_vec; // dummy return 91 }; 92 void from_setting(const libconfig::Setting& set){ 93 Controller::from_setting(set); 94 Est=UI::build<BM>(set,"estim",UI::optional); 95 estim = Est; 96 } 97 void log_register ( logger &L, const string &prefix ) { 98 Controller::log_register(L,prefix); 99 if (estim) Est->log_register(L,prefix); 100 } 101 void log_write() const{ 102 if (estim) Est->log_write(); 103 } 104 }; 105 //UIREGISTER(PMSMCtrl); -- abstract 106 107 class PMSM_PICtrl: public PMSMCtrl{ 41 108 public: 42 109 PI_ctrl Cwq; 43 110 PI_ctrl Cuq; 44 111 PI_ctrl Cud; 45 46 PMSM_PICtrl(): Cwq(3.0, 3.0*0.000125/0.1, -1200, 1200), 47 Cuq(20.0, 20.0*0.000125/0.005, -1200, 1200), 48 Cud(20.0, 20.0*0.000125/0.005, -1200, 1200) 49 { 50 rv = RV("{ua ub }"); 51 rvc = RV("{o_ia o_ib o_ua o_ub Ww o_om o_th }"); 52 } 112 113 PMSM_PICtrl():PMSMCtrl(), 114 Cwq(3.0, 3.0*0.000125/0.1, -1200, 1200), 115 Cuq(20.0, 20.0*0.000125/0.005, -1200, 1200), 116 Cud(20.0, 20.0*0.000125/0.005, -1200, 1200) {} 117 53 118 54 void adapt(const itpp::vec& data){ 55 vec y=data.get(0,1); 56 vec u=data.get(2,3); 57 Est->bayes(y,u); 58 59 } 60 61 62 virtual vec ctrlaction(const itpp::vec& cond) { 63 vec x_est=Est->posterior().mean(); 64 double isa=cond(0);//x_est(0); 65 double isb=cond(1);//x_est(1); 66 double ome=cond(5);//x[2];//x_est(2); 67 double the=cond(6);//x_est(3); 68 double Ww=cond(4); 119 virtual vec ctrlaction(const itpp::vec& cond) { 120 PMSMCtrl::ctrlaction(cond); // fills isa,isb,om,the 69 121 70 122 double Isd = isa*cos(the)+isb*sin(the); … … 78 130 const double Ls0=0.003465; // inductance 79 131 const double Fmag0= 0.1989; // Magnetic?? 80 132 81 133 ud-=Ls0*ome*Iqw; // har 82 134 uq+=Fmag0*ome; … … 93 145 return uab; 94 146 }; 95 void from_setting(const libconfig::Setting& set){96 Controller::from_setting(set);97 Est=UI::build<BM>(set,"estim",UI::compulsory);98 }99 147 }; 100 148 UIREGISTER(PMSM_PICtrl);