- Timestamp:
- 02/24/09 14:12:46 (16 years ago)
- Location:
- pmsm
- Files:
-
- 3 added
- 3 modified
Legend:
- Unmodified
- Added
- Removed
-
pmsm/CMakeLists.txt
r279 r280 21 21 22 22 EXEC (pmsm_estim pmsmsim) 23 EXEC (sim pmsmsim) 24 EXEC (sim_var pmsmsim) -
pmsm/pmsm.h
r279 r280 38 38 double ubm = u0 ( 1 ); 39 39 40 vec xk =zeros( 4 );40 vec xk( 4 ); 41 41 //ia 42 42 xk ( 0 ) = ( 1.0- Rs/Ls*dt ) * iam + Ypm/Ls*dt*omm * sin ( thm ) + uam*dt/Ls; -
pmsm/pmsmDS.h
r278 r280 27 27 //! Number of miliseconds per discrete time step 28 28 int Dt; 29 //! options for logging, string in which each character has a meaning: 30 //! \c u - log predictions of 'true' voltage 31 string opt; 29 //! options for logging, - log predictions of 'true' voltage 30 bool opt_modu; 32 31 public: 33 32 //! Constructor with fixed sampling period 34 pmsmDS ( string opt0="" ) : Dt ( 125 ), opt(opt0) {}33 pmsmDS () {Dt=125; Drv=RV ( "{o_ua o_ub o_ia o_ib t_ua t_ub }" );} 35 34 void set_parameters ( double Rs0, double Ls0, double Fmag0, double Bf0, double p0, double kp0, double J0, double Uc0, double DT0, double dt0 ) { 36 35 pmsmsim_set_parameters ( Rs0, Ls0, Fmag0, Bf0, p0, kp0, J0, Uc0, DT0, dt0 ); 36 } 37 //! parse options: "modelu" => opt_modu=true; 38 void set_options ( string &opt ) { 39 opt_modu = ( opt.find ( "modelu" ) ==string::npos ); 37 40 } 38 41 void getdata ( vec &dt ) {dt=vec ( KalmanObs,6 );} … … 48 51 //linear increase 49 52 if ( profileWw.length() ==1 ) { 50 Ww=profileWw ( 0 ); dW=0.0;} 53 Ww=profileWw ( 0 ); dW=0.0; 54 } 51 55 else { 52 56 dW = profileWw ( ind )-profileWw ( ind-1 ); … … 65 69 void log_add ( logger &L ) { 66 70 L_x = L.add ( rx, "x" ); 67 L_oy = L.add ( ry, "o bs" );68 L_ou = L.add ( ru, "o bs" );69 L_iu = L.add ( ru, "t rue" );71 L_oy = L.add ( ry, "o" ); 72 L_ou = L.add ( ru, "o" ); 73 L_iu = L.add ( ru, "t" ); 70 74 // log differences 71 if ( opt.find("u")==string::npos){72 L_optu = L.add (ru, "model");75 if ( opt_modu ) { 76 L_optu = L.add ( ru, "model" ); 73 77 } 74 78 } … … 79 83 L.logit ( L_ou, vec_2 ( KalmanObs[0],KalmanObs[1] ) ); 80 84 L.logit ( L_iu, vec_2 ( KalmanObs[4],KalmanObs[5] ) ); 81 if ( opt.find("u")==string::npos){82 double sq3=sqrt (3.0);85 if ( opt_modu ) { 86 double sq3=sqrt ( 3.0 ); 83 87 double ua,ub; 84 88 double i1=x[0]; 85 double i2=0.5* (-i1+sq3*x[1]);86 double i3=0.5* (-i1-sq3*x[1]);89 double i2=0.5* ( -i1+sq3*x[1] ); 90 double i3=0.5* ( -i1-sq3*x[1] ); 87 91 double u1=KalmanObs[0]; 88 double u2=0.5* (-u1+sq3*KalmanObs[1]);89 double u3=0.5* (-u1-sq3*KalmanObs[1]);90 91 double du1=0.7* (double(i1>0.1) - double(i1<-0.1))+0.05*i1;92 double du2=0.7* (double(i2>0.1) - double(i2<-0.1))+0.05*i2;93 double du3=0.7* (double(i3>0.1) - double(i3<-0.1))+0.05*i3;94 ua = ( 2.0*(u1-du1)-(u2-du2)-(u3-du3))/3.0;95 ub = ( (u2-du2)-(u3-du3))/sq3;96 L.logit ( L_optu , vec_2 (ua,ub));92 double u2=0.5* ( -u1+sq3*KalmanObs[1] ); 93 double u3=0.5* ( -u1-sq3*KalmanObs[1] ); 94 95 double du1=0.7* ( double ( i1>0.1 ) - double ( i1<-0.1 ) ) +0.05*i1; 96 double du2=0.7* ( double ( i2>0.1 ) - double ( i2<-0.1 ) ) +0.05*i2; 97 double du3=0.7* ( double ( i3>0.1 ) - double ( i3<-0.1 ) ) +0.05*i3; 98 ua = ( 2.0* ( u1-du1 )- ( u2-du2 )- ( u3-du3 ) ) /3.0; 99 ub = ( ( u2-du2 )- ( u3-du3 ) ) /sq3; 100 L.logit ( L_optu , vec_2 ( ua,ub ) ); 97 101 } 98 102 } 99 103 100 104 void set_profile ( double dt, const vec &Ww ) {dt_prof=dt; profileWw=Ww;}