Changeset 130
- Timestamp:
- 07/07/08 15:45:24 (17 years ago)
- Location:
- pmsm/simulator_zdenek
- Files:
-
- 3 modified
Legend:
- Unmodified
- Added
- Removed
-
pmsm/simulator_zdenek/regulace.cpp
r44 r130 164 164 filtr(Um/Ucn_2,&Urmf,Treg/Tfurm); 165 165 166 // saturation of modulation depth going to PWM 167 if (Um>Ucn_2*Urm_max) Um=Ucn_2*Urm_max; // linear modulation area only - ensure max. modulation depth 168 166 169 /////// PRECHOD ZPET DO SIMULACE ////////////// 167 170 *u=Um; -
pmsm/simulator_zdenek/simulator.cpp
r108 r130 58 58 static double us[2]={0.,0.}; // format us={us_alfa, us_beta} 59 59 60 // variables for calculation of mean values of stator voltage components 61 static double usx_av=0., usy_av=0.,sum_usx_av=0.,sum_usy_av=0.; 62 63 // variables for calculation of mean values of stator current components - (alfa, beta) 64 static double isx_av=0., isy_av=0.,sum_isx_av=0.,sum_isy_av=0.; 65 66 // stator voltage components filtering 67 static double usxf=0.,usyf=0.,Tf=0.01; 68 static unsigned int start_filter=1; 69 60 70 // output for EKF (voltages and measured currents, which are fed to KalmanObs) 61 double KalmanObs[ 4]={0.,0.,0.,0.}; // usx, usy, Isx, Isy71 double KalmanObs[10]={0.,0.,0.,0.,0.,0.,0.,0.,0.,0.}; // usx, usy, Isx, Isy, usx_av, usy_av 62 72 63 73 // real-time … … 87 97 h_reg=125e-6; // fpwm = 4kHz 88 98 h_reg_counter_mez=(int)(h_reg/h); // emulation of operation of DSP timer 89 h_reg_counter=h_reg_counter_mez; 99 //h_reg_counter=h_reg_counter_mez; 100 h_reg_counter=1; 90 101 h_reg_real=h_reg_counter_mez*h; // real sampling period 91 102 … … 155 166 156 167 for (i=0;i<3;i++) 157 { dtr[i]=ubytek(fabs(iabc[i])) ;168 { dtr[i]=ubytek(fabs(iabc[i]))*0.; 158 169 dd[i]=dtr[i]*.73; 159 170 } … … 182 193 183 194 // emulation of DSP timers 184 if ((citac==citac_PR)||(citac==0)) smer*=-1; 195 if ((citac==citac_PR)||(citac==0)) 196 { 197 smer*=-1; 198 // calculation of stator voltage components mean values 199 usx_av=h/h_reg*sum_usx_av; 200 usy_av=h/h_reg*sum_usy_av; 201 // reset of sum accumulators 202 sum_usx_av=0.; 203 sum_usy_av=0.; 204 205 // stator current components mean values - reference frame (alfa, beta) 206 isx_av=h/h_reg*sum_isx_av; 207 isy_av=h/h_reg*sum_isy_av; 208 // reset of sum accumulators 209 sum_isx_av=0.; 210 sum_isy_av=0.; 211 } 185 212 if ((citac2==citac_PR)||(citac2==0)) smer2*=-1; 186 213 citac+=smer; 187 214 citac2+=smer2; 215 216 // calculation of stator voltage components mean values - sum 217 sum_usx_av+=*us; 218 sum_usy_av+=*(us+1); 219 220 // stator voltage components filtering 221 //if (start_filter==1) 222 usxf+=(*us-usxf)*h/h_reg; 223 usyf+=(*(us+1)-usyf)*h/h_reg; 224 225 // stator current components mean values - reference frame (alfa, beta) 226 sum_isx_av+=*x; 227 sum_isy_av+=*(x+1); 188 228 } 189 229 … … 280 320 KalmanObs[0]=ua; // usx 281 321 KalmanObs[1]=(ua+2.*ub)/sqrt(3.); // usy 282 KalmanObs[2]=Isx; 283 KalmanObs[3]=Isy; 322 323 // real sampling - considered transport delay equal to the sampling period 324 /* KalmanObs[2]=Isx; 325 KalmanObs[3]=Isy;*/ 326 // ideal sampling 327 KalmanObs[2]=x[0]; 328 KalmanObs[3]=x[1]; 329 330 // diagnostic - mean values of stator voltage components - pwm() 331 KalmanObs[4]=usx_av; 332 KalmanObs[5]=usy_av; 333 KalmanObs[6]=usxf; 334 KalmanObs[7]=usyf; 335 KalmanObs[8]=isx_av; 336 KalmanObs[9]=isy_av; 284 337 285 338 vektor_regulace(0,0,Urm_max,Ww,u,Isx,Isy,theta,speed,U_modulace,Uc,Ucn,REZIM_REGULACE); // rezim=1 ... reg. rychlosti, rezim=0 ... reg. momentu -
pmsm/simulator_zdenek/simulator.h
r108 r130 22 22 extern double x[9]; 23 23 extern double t; 24 extern double KalmanObs[ 4];24 extern double KalmanObs[10];