Changeset 40 for simulator_zdenek/simulator.cpp
- Timestamp:
- 03/19/08 15:32:40 (17 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
simulator_zdenek/simulator.cpp
r38 r40 12 12 13 13 #include <math.h> 14 #include <stdlib.h> //na linuxu je abs v stdlib 14 15 #include "regulace.h" 15 16 #include "simulator.h" … … 17 18 #define REZIM_REGULACE 1 // 0...reg. momentu, 1...reg.rychlosti, 2... Isqw=sqrt(Imax^2-Id^2) - max. moment 18 19 19 void set_parameters(double Rs0, double Ls0, double Fmag0, double Bf0, double p0, double kp0, double J0, double Uc0, double DT0, double dt0);20 void eval(double Ww);20 void pmsmsim_set_parameters(double Rs0, double Ls0, double Fmag0, double Bf0, double p0, double kp0, double J0, double Uc0, double DT0, double dt0); 21 void pmsmsim_step(double Ww); 21 22 22 23 // local functions … … 54 55 static double us[2]={0.,0.}; // format us={us_alfa, us_beta} 55 56 56 // output for EKF (voltages and measured currents, which are fed to Kalman )57 static double Kalman[4]={0.,0.,0.,0.}; // usx, usy, Isx, Isy57 // output for EKF (voltages and measured currents, which are fed to KalmanObs) 58 double KalmanObs[4]={0.,0.,0.,0.}; // usx, usy, Isx, Isy 58 59 59 60 // real-time 60 61 static double t=0.; 61 62 62 void set_parameters(double Rs0, double Ls0, double Fmag0, double Bf0, double p0, double kp0, double J0, double Uc0, double DT0, double dt0)63 void pmsmsim_set_parameters(double Rs0, double Ls0, double Fmag0, double Bf0, double p0, double kp0, double J0, double Uc0, double DT0, double dt0) 63 64 { 64 65 int tmp_i; … … 97 98 smer=-1; smer2=-1; 98 99 citac=0; 99 citac2=abs(0-( DT/h));100 citac2=abs(0-(int)(DT/h)); //VS: oprava, je to spravne? 100 101 citac_PR=h_reg_counter_mez; 101 102 … … 258 259 259 260 ////////////////////////////////////////////////////////////////////////////////////////////////////// 260 void eval(double Ww) // you must link array Kalman[] to EKF modul261 void pmsmsim_step(double Ww) // you must link array KalmanObs[] to EKF modul 261 262 { 262 263 double Umk, ua, ub; … … 273 274 ua=Umk*cos(*(u+1)); 274 275 ub=Umk*cos(*(u+1)-2./3.*M_PI); 275 Kalman [0]=ua; // usx276 Kalman [1]=(ua+2.*ub)/sqrt(3.); // usy277 Kalman [2]=Isx;278 Kalman [3]=Isy;276 KalmanObs[0]=ua; // usx 277 KalmanObs[1]=(ua+2.*ub)/sqrt(3.); // usy 278 KalmanObs[2]=Isx; 279 KalmanObs[3]=Isy; 279 280 280 281 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