Changeset 1380
- Timestamp:
- 08/01/11 22:11:09 (13 years ago)
- Files:
-
- 2 added
- 10 modified
Legend:
- Unmodified
- Added
- Removed
-
applications/pmsm/pmsmDS.h
r1377 r1380 25 25 { 26 26 LOG_LEVEL(pmsmDS,logvoltage); 27 27 28 28 protected: 29 29 //! indices of logged variables … … 38 38 int Dt; 39 39 public: 40 double x[8]; 41 double KalmanObs[8]; 40 42 //! Constructor with fixed sampling period 41 43 pmsmDS () : DS() … … 44 46 Drv=RV ( "{o_ua o_ub o_ia o_ib t_ua t_ub o_om o_th Mz }" ); 45 47 dtsize = Drv._dsize(); 48 pmsmsim_fill_xy(x,KalmanObs); 46 49 } 47 50 void set_parameters ( double Rs0, double Ls0, double Fmag0, double Bf0, double p0, double kp0, double J0, double Uc0, double DT0, double dt0 ) … … 66 69 void step() 67 70 { 71 pmsmsim_fill_xy(x,KalmanObs); 68 72 static int ind=0; 69 73 static double dW; // increase of W 70 74 static double Ww; // W 71 75 static double Mz; // W 76 double t; 77 t=pmsmsim_get_t(); 72 78 if ( t>=dt_prof*ind ) 73 79 { … … 210 216 void step() 211 217 { 218 double t=pmsmsim_get_t(); 219 212 220 static int ind=0; 213 221 static double dW; // increase of W … … 256 264 257 265 266 #ifdef XXX 258 267 //! This class behaves like BM but it is evaluating EKF 259 268 class pmsmCRB : public EKFfull … … 279 288 vec &mu = est._mu(); 280 289 //assume we know state exactly: 281 vec true_state= vec(x,4); // read from pmsm290 vec true_state=0;//TODO vec(x,4); // read from pmsm 282 291 mu=true_state; 283 292 … … 418 427 419 428 UIREGISTER ( pmsmCRBMz ); 429 #endif 420 430 421 431 #endif -
applications/pmsm/simulator_zdenek/CMakeLists.txt
r1344 r1380 1 1 # Simulator library 2 add_library (pmsmsim simulator.cpp regulace.cpp)2 add_library (pmsmsim SHARED simulator.cpp regulace.cpp) 3 3 4 EXEC (test_UD pmsmsim ekf_obj)5 EXEC (test_Ch pmsmsim ekf_obj)4 #EXEC (test_UD pmsmsim ekf_obj) 5 #EXEC (test_Ch pmsmsim ekf_obj) 6 6 7 7 add_executable(round_test round_test.cpp) -
applications/pmsm/simulator_zdenek/demo_example/main.CPP
r38 r1380 30 30 FILE *fw; 31 31 32 voidmain(void)32 int main(void) 33 33 { 34 34 h=1e-6; … … 72 72 73 73 fclose(fw); 74 return 0; 74 75 } -
applications/pmsm/simulator_zdenek/ekf_example/CMakeLists.txt
r1174 r1380 2 2 3 3 include_directories(../../bdm) 4 add_library (ekf_obj ekf_obj.cpp fixed.cpp matrix.cpp matrix_vs.cpp )4 add_library (ekf_obj ekf_obj.cpp fixed.cpp matrix.cpp matrix_vs.cpp mpf_double.cpp) -
applications/pmsm/simulator_zdenek/ekf_example/ekf_obj.cpp
r1341 r1380 3 3 4 4 #include "ekf_obj.h" 5 #include "../simulator.h"5 //#include "../simulator.h" 6 6 7 7 double minQ(double Q){if (Q>1.0){ return 1.0;} else {return Q;};}; -
applications/pmsm/simulator_zdenek/ekf_example/ekf_obj.h
r1341 r1380 21 21 #include "reference_Q15.h" 22 22 #include "parametry_motoru.h" 23 #include "mpf_double.h" 23 24 24 25 using namespace bdm; … … 564 565 565 566 567 class MPF_pmsm_red:public BM{ 568 569 570 public: 571 MPF_pmsm_red(){ 572 dimy=2; 573 dimc=2; 574 mpf_init(1e-1, 1e-6, 1e-1); 575 }; 576 void bayes ( const vec &val, const vec &cond ) { 577 const double &isa = val(0); 578 const double &isb = val(1); 579 const double &usa = cond(0); 580 const double &usb = cond(1); 581 mpf_bayes(isa,isb,usa,usb); 582 } 583 584 class mp:public epdf{ 585 public: 586 mp():epdf(){set_dim(N);} 587 vec sample() const {return zeros(N);} 588 double evallog(const vec &v) const {return 0.0;} 589 vec mean() const {vec tmp(N); mpf_th(tmp._data()); return tmp;} 590 vec variance() const {return zeros(N);} 591 }; 592 593 mp mypdf; 594 const mp& posterior() const {return mypdf;} 595 }; 596 UIREGISTER(MPF_pmsm_red); 566 597 567 598 -
applications/pmsm/simulator_zdenek/pmsm_sim.cpp
r1378 r1380 10 10 usa = *mxGetPr(input[0]); 11 11 usb = *mxGetPr(input[1]); 12 pmsmsim_noreg_step(usa,usb);12 pmsmsim_noreg_step(usa,usb); 13 13 } 14 14 if ( n_input==1 ) { 15 double Ww = *mxGetPr(input[0]); 16 for (int i=0;i<125; i++){ 17 pmsmsim_step(Ww,0.0); 15 double Ww = *mxGetPr(input[0]); 16 for (int i=0;i<125; i++){ 17 pmsmsim_step(Ww,0.0); 18 } 18 19 } 19 }20 if (n_input==0){21 pmsmsim_set_parameters ( 0.28,0.003465,0.1989,0.0,4,1.5,0.04, 200., 3e-6, 1e-6 );22 }23 20 24 21 output[0]= mxCreateDoubleMatrix(9, 1, mxREAL); 25 22 x_out= mxGetPr(output[0]); 26 23 27 for (int i=0; i<9; i++){ 28 x_out[i]=x[i]; 29 } 30 31 output[1]= mxCreateDoubleMatrix(6, 1, mxREAL); 24 output[1]= mxCreateDoubleMatrix(6, 1, mxREAL); 32 25 y_out= mxGetPr(output[1]); 33 26 34 for (int i=0; i<5; i++){ 35 y_out[i]=KalmanObs[i]; 36 } 37 27 pmsmsim_fill_xy(x_out,y_out); 38 28 39 29 } -
applications/pmsm/simulator_zdenek/simulator.cpp
r1306 r1380 42 42 43 43 // system state 44 double x[9]; // (isx,isy,wme,theta_e,M,Fsd,Isd,Isq,Mz)44 static double x[9]; // (isx,isy,wme,theta_e,M,Fsd,Isd,Isq,Mz) 45 45 46 46 // internal variables of PWM module … … 70 70 71 71 // output for EKF (voltages and measured currents, which are fed to KalmanObs) 72 double KalmanObs[10]={0.,0.,0.,0.,0.,0.,0.,0.,0.,0.}; // usx, usy, Isx, Isy, usx_av, usy_av72 static double KalmanObs[10]={0.,0.,0.,0.,0.,0.,0.,0.,0.,0.}; // usx, usy, Isx, Isy, usx_av, usy_av 73 73 74 74 // real-time 75 double t=0.; //VS removed static due to clash with export in .h75 static double t=0.; //VS removed static due to clash with export in .h 76 76 77 77 // stator voltage components in alfa beta (inluding impact of the real dc-link voltage) … … 510 510 ////////////////////////////////////////////////////////////////////////////////////////////////////// 511 511 ////////////////////////////////////////////////////////////////////////////////////////////////////// 512 513 // for mexfile 514 void pmsmsim_fill_parameters(double x_out[10]){ 515 x_out[0]= Rs; 516 x_out[1]= Ls; 517 x_out[2]= Fmag; 518 x_out[3]= Bf; 519 x_out[4]= p; 520 x_out[5]= kp; 521 x_out[6]= J; 522 x_out[7]= Uc; 523 x_out[8]= DT; 524 x_out[9]= h; 525 } 526 void pmsmsim_fill_xy(double xout[9], double yout[6]){ 527 for (int i=0;i<9;i++){ 528 xout[i]=x[i]; 529 } 530 for (int i=0;i<6;i++){ 531 yout[i]=KalmanObs[i]; 532 } 533 } 534 double pmsmsim_get_t() 535 { 536 return t; 537 } 538 -
applications/pmsm/simulator_zdenek/simulator.h
r318 r1380 20 20 extern void pmsmsim_step(double Ww, double Mz=0.0); 21 21 extern void pmsmsim_noreg_step(double ua, double ub); 22 extern void pmsmsim_fill_parameters(double P[10]); 23 extern void pmsmsim_fill_xy(double xout[9], double yout[6]); 24 extern double pmsmsim_get_t(); 22 25 23 extern double x[9];24 extern double t;25 extern double KalmanObs[10]; -
library/bdm/estim/arx.cpp
r1192 r1380 352 352 353 353 void ARXpartialforg::bayes ( const vec &val, const vec &cond ) { 354 #define LOG2 0.69314718055995 354 355 #define LOG2 0.69314718055995 355 356 vec frg = cond.right(cond.length() - rgrlen); 356 357 vec cond_rgr = cond.left(rgrlen); // regression vector