Changeset 654 for applications/pmsm
- Timestamp:
- 10/12/09 19:38:57 (15 years ago)
- Location:
- applications/pmsm
- Files:
-
- 1 added
- 7 modified
Legend:
- Unmodified
- Added
- Removed
-
applications/pmsm/CMakeLists.txt
r357 r654 1 # Make sure the compiler can find include files from our Bdm library. 1 # Matlab toolbox of functions from BDM 2 3 cmake_minimum_required(VERSION 2.6) 4 PROJECT(bdmtoolbox) 5 6 # Link it to BDM 7 SET(BDM_SOURCE_DIR "${CMAKE_SOURCE_DIR}/../../library") 8 SET(CMAKE_MODULE_PATH "${BDM_SOURCE_DIR}/system") 9 10 # Load BDM environment 11 INCLUDE(SetBdmEnv) 12 2 13 include_directories (${BDM_SOURCE_DIR}/bdm) 3 4 # Make sure the linker can find the bdm library once it is built. 5 link_directories (${BDM_BINARY_DIR}/bdm) 14 link_directories (${BDM_SOURCE_DIR}/bdm) 6 15 7 16 # no simulator needed... … … 24 33 #EXEC (sim_var pmsmsim) 25 34 26 add_subdirectory (TR2245)35 #add_subdirectory (TR2245) -
applications/pmsm/cfg/mpf_test.cfg
r295 r654 2 2 3 3 experiment={ 4 ndat = 9000 ;4 ndat = 90000; 5 5 }; 6 6 7 system= { 8 type = "stateDS"; 9 IM = {type="mprod"; 10 mpdfs=( 11 {type="mgnorm"; 12 g={type="pmsmIM"; 13 params : {type = "external";filename = "cfg/zcu.cfg";path = "pmsm107";}; 14 }; 15 dR= 16 }} 17 ); 7 system= "system@cfg/sim.cfg"; 8 9 estimator = ( 10 {class="MPFpmsm"; 11 params = "pmsm107@cfg/zcu.cfg"; 12 dQ=[0.17, 0.17, 0.00004, 1e-9]; 13 dR=[0.06, 0.06]; 14 prior={class="euni";high=[4];low=[-4];}; 15 //connect 16 drv = {class="RV"; names=("o_ia","o_ib","o_ua","o_ub");}; 17 rv = {class="RV"; names=("e_ia","e_ib","e_om","e_th");}; 18 options = "logbounds"; 19 n=20; 18 20 } 19 tstep = 1.0; // steps for profile in [s]20 profile = [1, 5, 0, -3, 8];21 opt = "u";22 };23 24 estimator = (25 {type="EKF";26 IM = {type="pmsmIM";27 params : {type = "external";filename = "cfg/zcu.cfg";path = "pmsm107";};28 };29 OM = {type="pmsmOM";};30 dQ=[62., 66., 44., 0.03];31 dR=[100, 100];32 //connect33 drv = {type="rv"; names=["o_ia","o_ib","t_ua","t_ub"];};34 rv = {type="rv"; names=["EKF"]; sizes=[4];};35 }36 21 ); 37 22 38 23 logger= { 39 type="dirfilelog";24 class="dirfilelog"; 40 25 maxlen = 1000; 41 dirname = " exp/sim";26 dirname = "kst/mpf_test"; 42 27 }; -
applications/pmsm/cfg/sim.cfg
r295 r654 6 6 7 7 system= { 8 type= "pmsmDS";9 params : {type = "external";filename = "cfg/zcu.cfg";path = "pmsm107";};8 class = "pmsmDS"; 9 params = "pmsm107@zcu.cfg"; 10 10 tstep = 1.0; // steps for profile in [s] 11 profile = [1, 5, 0, -3, 8];11 profileW = [1, 5, 0, -3, 0, 0, 0, 1, 0, 0 ]; 12 12 opt = "u"; 13 13 }; 14 14 15 15 estimator = ( 16 {type="EKF"; 17 IM = {type="pmsmIM"; 18 params : {type = "external";filename = "cfg/zcu.cfg";path = "pmsm107";}; 19 }; 20 OM = {type="pmsmOM";}; 21 dQ=[62., 66., 44., 0.03]; 22 dR=[100, 100]; 23 //connect 24 drv = {type="rv"; names=["o_ia","o_ib","o_ua","o_ub"];}; // observed u 25 //drv = {type="rv"; names=["o_ia","o_ib","t_ua","t_ub"];}; // true u 26 rv = {type="rv"; names=["EKF"]; sizes=[4];}; 27 } 16 {class="EKFfull"; 17 IM = {class="IMpmsm"; 18 params = "pmsm107@cfg/zcu.cfg"; 19 }; 20 OM = {class="OMpmsm";}; 21 dQ=[0.17, 0.17, 0.0000004, 1e-11]; 22 dR=[0.0006, 0.0006]; 23 //connect 24 drv = {class="RV"; names=("o_ia","o_ib","o_ua","o_ub");}; // observed u 25 //drv = {type="rv"; names=["o_ia","o_ib","t_ua","t_ub"];}; // true u 26 rv = {class="RV"; names=("EKF"); sizes=[4];}; 27 options = "logbounds"; 28 } 28 29 ); 29 30 30 31 logger= { 31 type="dirfilelog";32 class="dirfilelog"; 32 33 maxlen = 1000; 33 dirname = " exp/sim";34 dirname = "kst/sim"; 34 35 }; -
applications/pmsm/pmsm.h
r384 r654 2 2 #define PMSM_H 3 3 4 #include < stat/functions.h>5 #include " user_info.h"4 #include <math/functions.h> 5 #include "base/user_info.h" 6 6 7 7 /*! \defgroup PMSM … … 98 98 void from_setting( const Setting &root ) 99 99 { 100 UI::SettingResolver params_exp(root["params"]); 101 const Setting& params=params_exp.result; 102 103 set_parameters ( params["Rs"], params["Ls"], 125e-6, params["Fmag"], \ 100 101 const SettingResolver& params_b=root["params"]; 102 const Setting& params=params_b.result; 103 104 set_parameters ( params["Rs"], params["Ls"], 125e-6, params["Fmag"], \ 104 105 params["kp"], params["p"], params["J"], 0.0); 105 106 /* set_parameters ( root["params"]["Rs"], root["params"]["Ls"], 125e-6, root["params"]["Fmag"], \107 root["params"]["kp"], root["params"]["p"], root["params"]["J"], 0.0 );*/108 106 }; 109 107 -
applications/pmsm/pmsmDS.h
r384 r654 11 11 */ 12 12 13 #include < stat/loggers.h>13 #include <base/loggers.h> 14 14 #include <estim/kalman.h> 15 15 #include "simulator_zdenek/simulator.h" … … 71 71 ind++; 72 72 // check omega profile and set dW 73 if ( ind<profileWw.length() ) 73 if ( ind <2 && profileWw.length() ==1 ) 74 { 75 Ww=profileWw ( 0 ); 76 dW=0.0; 77 } 78 if ( ind<profileWw.length() ) 74 79 { 75 //linear increase76 if ( profileWw.length() ==1 )77 {78 Ww=profileWw ( 0 );79 dW=0.0;80 }81 else82 {83 80 dW = profileWw ( ind )-profileWw ( ind-1 ); 84 81 dW *=125e-6/dt_prof; 85 }86 82 } 87 83 else … … 167 163 void from_setting( const Setting &root ) 168 164 { 169 UI::SettingResolver params_exp(root["params"]); 170 const Setting& params=params_exp.result; 171 165 const SettingResolver& params_l(root["params"]); 166 const Setting ¶ms = params_l.result; 172 167 set_parameters ( params["Rs"], params["Ls"], params["Fmag"], \ 173 168 params["Bf"], params["p"], params["kp"], \ … … 214 209 { 215 210 static vec umin(2); 216 vec u(2); 217 //assume we know state exactly: 211 vec u(2); 212 vec &mu = est->_mu(); 213 //assume we know state exactly: 218 214 vec true_state=vec(x,4); // read from pmsm 219 E.set_mu(true_state);220 215 mu=true_state; 221 216 … … 228 223 229 224 //second derivative 230 IMpmsm2o* pf = dynamic_cast<IMpmsm2o*>(pfxu );225 IMpmsm2o* pf = dynamic_cast<IMpmsm2o*>(pfxu.get()); 231 226 if (pf) 232 227 { … … 254 249 void from_setting( const Setting &root ) 255 250 { 256 diffbifn*IM = UI::build<diffbifn>(root, "IM");257 diffbifn*OM = UI::build<diffbifn>(root, "OM");251 shared_ptr<diffbifn> IM = UI::build<diffbifn>(root, "IM"); 252 shared_ptr<diffbifn> OM = UI::build<diffbifn>(root, "OM"); 258 253 259 254 //parameters … … 289 284 290 285 //connect 291 RV*drv = UI::build<RV>(root, "drv");286 shared_ptr<RV> drv = UI::build<RV>(root, "drv"); 292 287 set_drv(*drv); 293 RV*rv = UI::build<RV>(root, "rv");288 shared_ptr<RV> rv = UI::build<RV>(root, "rv"); 294 289 set_rv(*rv); 295 290 } … … 317 312 true_state(4)=x[8]; 318 313 319 E.set_mu(true_state);314 vec &mu = est->_mu(); 320 315 mu = true_state; 321 316 //hack for ut … … 334 329 void from_setting( const Setting &root ) 335 330 { 336 diffbifn*IM = UI::build<diffbifn>(root,"IM");337 diffbifn*OM = UI::build<diffbifn>(root,"OM");331 shared_ptr<diffbifn> IM = UI::build<diffbifn>(root,"IM"); 332 shared_ptr<diffbifn> OM = UI::build<diffbifn>(root,"OM"); 338 333 339 334 //statistics … … 367 362 368 363 //connect 369 RV*drv = UI::build<RV>(root, "drv");364 shared_ptr<RV> drv = UI::build<RV>(root, "drv"); 370 365 set_drv(*drv); 371 RV*rv = UI::build<RV>(root, "rv");366 shared_ptr<RV> rv = UI::build<RV>(root, "rv"); 372 367 set_rv(*rv); 373 368 } -
applications/pmsm/pmsm_estim.cpp
r394 r654 7 7 */ 8 8 9 #include " user_info.h"10 #include " stat/loggers.h"9 #include "base/user_info.h" 10 #include "base/loggers.h" 11 11 #include "estim/kalman.h" 12 12 #include "pmsmDS.h" 13 #include "filters.h" 13 14 14 15 … … 20 21 UIFile F ( fname ); 21 22 22 logger*L = UI::build <logger>( F, "logger" );23 DS *pDS = UI::build<DS> ( F, "system" );24 Array< BM*> Es; // array of estimators23 shared_ptr<logger> L = UI::build <logger>( F, "logger" ); 24 shared_ptr<DS> pDS = UI::build<DS> ( F, "system" ); 25 Array<shared_ptr<BM> > Es; // array of estimators 25 26 UI::get( Es, F, "estimator" ); 26 27 int nE = Es.length(); //number of estimators … … 60 61 L->finalize(); 61 62 62 delete L;63 delete pDS;64 63 for (int i=0; i<nE; i++){ 65 64 delete Dls(i); 66 delete Es(i);67 65 } 68 66 return 0; -
applications/pmsm/testbidiff.cpp
r262 r654 1 1 2 #include "../bdm/stat/libBM.h"2 #include <base/bdmbase.h> 3 3 4 4 #include "pmsm.h"