- Timestamp:
- 03/16/12 16:46:40 (12 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
applications/pmsm/simulator_zdenek/ekf_example/simulmpf.cpp
r1437 r1439 65 65 66 66 // EKF - vysledek estimace 67 static doublempf_estim[2]={0.,0.}; // w_est, theta_est68 static doubleEsinth, Ecosth;67 static floatx mpf_estim[2]={0.,0.}; // w_est, theta_est 68 static floatx Esinth, Ecosth; 69 69 70 70 FILE *fw; … … 115 115 init_pmsm(param, REL1); 116 116 init_regulace(param,h_reg); 117 mpf_init(1e0, 1e- 5, 1e0);//VS:117 mpf_init(1e0, 1e-3, 1e0);//VS: 118 118 119 119 fw=fopen("data/graf2.txt","w"); … … 161 161 162 162 if (t>0.7) Ww=2.*M_PI*10.; 163 if (t>1.0) x[8]=1.2; // 1A164 if (t>1.2) x[8]=10.8; // 9A165 if (t>1.4) x[8]=25.2; // 21A163 // if (t>1.0) x[8]=1.2; // 1A 164 // if (t>1.2) x[8]=10.8; // 9A 165 // if (t>1.4) x[8]=25.2; // 21A 166 166 167 167 if (t>1.6) Ww=2.*M_PI*50.; 168 if (t>1.9) x[8]=1.2; // 1A169 if (t>2.1) x[8]=10.8; // 9A170 if (t>2.3) x[8]=25.2; // 21A168 // if (t>1.9) x[8]=1.2; // 1A 169 // if (t>2.1) x[8]=10.8; // 9A 170 // if (t>2.3) x[8]=25.2; // 21A 171 171 172 172 if (t>2.5) Ww=2.*M_PI*100; 173 if (t>2.8) x[8]=1.2; // 1A174 if (t>3.0) x[8]=10.8; // 9A175 if (t>3.2) x[8]=25.2; // 21A173 // if (t>2.8) x[8]=1.2; // 1A 174 // if (t>3.0) x[8]=10.8; // 9A 175 // if (t>3.2) x[8]=25.2; // 21A 176 176 177 177 if (t>3.4) Ww=2.*M_PI*150; 178 if (t>3.7) x[8]=1.2; // 1A179 if (t>3.9) x[8]=10.8; // 9A180 if (t>4.1) x[8]=25.2; // 21A178 // if (t>3.7) x[8]=1.2; // 1A 179 // if (t>3.9) x[8]=10.8; // 9A 180 // if (t>4.1) x[8]=25.2; // 21A 181 181 182 182 if (t>4.3) Ww=2.*M_PI*0; 183 if (t>4.8) x[8]=-1.2; // 1A184 if (t>5.0) x[8]=-10.8; // 9A185 if (t>5.2) x[8]=-25.2; // 21A183 // if (t>4.8) x[8]=-1.2; // 1A 184 // if (t>5.0) x[8]=-10.8; // 9A 185 // if (t>5.2) x[8]=-25.2; // 21A 186 186 187 187 if (t>5.4) Ww=2.*M_PI*(-10.); 188 if (t>5.7) x[8]=-1.2; // 1A189 if (t>5.9) x[8]=-10.8; // 9A190 if (t>6.1) x[8]=-25.2; // 21A188 // if (t>5.7) x[8]=-1.2; // 1A 189 // if (t>5.9) x[8]=-10.8; // 9A 190 // if (t>6.1) x[8]=-25.2; // 21A 191 191 192 192 if (t>6.3) Ww=2.*M_PI*(-50.); 193 if (t>6.7) x[8]=-1.2; // 1A194 if (t>6.9) x[8]=-10.8; // 9A195 if (t>7.1) x[8]=-25.2; // 21A193 // if (t>6.7) x[8]=-1.2; // 1A 194 // if (t>6.9) x[8]=-10.8; // 9A 195 // if (t>7.1) x[8]=-25.2; // 21A 196 196 197 197 if (t>7.3) Ww=2.*M_PI*(-100.); 198 if (t>7.7) x[8]=-1.2; // 1A199 if (t>7.9) x[8]=-10.8; // 9A200 if (t>8.1) x[8]=-25.2; // 21A201 if (t>8.3) x[8]=10.8; // 9A202 if (t>8.5) x[8]=25.2; // 21A198 // if (t>7.7) x[8]=-1.2; // 1A 199 // if (t>7.9) x[8]=-10.8; // 9A 200 // if (t>8.1) x[8]=-25.2; // 21A 201 // if (t>8.3) x[8]=10.8; // 9A 202 // if (t>8.5) x[8]=25.2; // 21A 203 203 204 204 … … 218 218 if (x[2]<-1615) x[2]=-1615; /**/ 219 219 220 // KALMAN 221 Umk=*u*Uc/Ucn; 220 221 // KALMAN (pouzij stara Usx, Usy!! 222 if (0){ 223 mpf_bayes((floatx)Isx,(floatx)Isy,(floatx)Usx,(floatx)Usy); 224 mpf_mean(&Esinth,&Ecosth,&mpf_estim[0]); 225 mpf_estim[1]=atan2((floatx)Esinth,(floatx)Ecosth); 226 } else { 227 mpf_estim[0]=kalman_om((floatx)Isx,(floatx)Isy,(floatx)Usx,(floatx)Usy,(floatx)x[3]); 228 } 229 230 Umk=*u*Uc/Ucn; 222 231 ua=Umk*cos(*(u+1)); 223 232 ub=Umk*cos(*(u+1)-2./3.*M_PI); 224 233 Usx=ua; // usx 225 234 Usy=(ua+2.*ub)/sqrt(3.); // usy 226 227 mpf_bayes(Isx,Isy,Usx,Usy);228 mpf_mean(&Esinth,&Ecosth,&mpf_estim[0]);229 mpf_estim[1]=atan2(Esinth,Ecosth);230 231 235 // vystup z EKF zaveden do regulatoru 232 236 // rychlost=ekf_estim[0]; theta=ekf_estim[1]; //VS