Show
Ignore:
Timestamp:
03/19/08 15:32:40 (17 years ago)
Author:
smidl
Message:

Opravy simulatoru: premenovani na prefix pmsmsim_ + preklad na linuxu

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • simulator_zdenek/simulator.cpp

    r38 r40  
    1212 
    1313#include <math.h> 
     14#include <stdlib.h> //na linuxu je abs v stdlib 
    1415#include "regulace.h" 
    1516#include "simulator.h" 
     
    1718#define REZIM_REGULACE  1       // 0...reg. momentu, 1...reg.rychlosti, 2... Isqw=sqrt(Imax^2-Id^2) - max. moment 
    1819 
    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); 
     20void pmsmsim_set_parameters(double Rs0, double Ls0, double Fmag0, double Bf0, double p0, double kp0, double J0, double Uc0, double DT0, double dt0); 
     21void pmsmsim_step(double Ww); 
    2122 
    2223// local functions 
     
    5455static double us[2]={0.,0.};    // format us={us_alfa, us_beta} 
    5556 
    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, Isy 
     57// output for EKF (voltages and measured currents, which are fed to KalmanObs) 
     58double KalmanObs[4]={0.,0.,0.,0.};      // usx, usy, Isx, Isy 
    5859 
    5960// real-time 
    6061static double t=0.; 
    6162 
    62 void set_parameters(double Rs0, double Ls0, double Fmag0, double Bf0, double p0, double kp0, double J0, double Uc0, double DT0, double dt0) 
     63void pmsmsim_set_parameters(double Rs0, double Ls0, double Fmag0, double Bf0, double p0, double kp0, double J0, double Uc0, double DT0, double dt0) 
    6364{ 
    6465  int tmp_i; 
     
    9798  smer=-1; smer2=-1; 
    9899  citac=0; 
    99   citac2=abs(0-(DT/h)); 
     100  citac2=abs(0-(int)(DT/h)); //VS: oprava, je to spravne? 
    100101  citac_PR=h_reg_counter_mez; 
    101102 
     
    258259 
    259260////////////////////////////////////////////////////////////////////////////////////////////////////// 
    260 void eval(double Ww)            // you must link array Kalman[] to EKF modul 
     261void pmsmsim_step(double Ww)            // you must link array KalmanObs[] to EKF modul 
    261262{ 
    262263  double Umk, ua, ub; 
     
    273274      ua=Umk*cos(*(u+1)); 
    274275      ub=Umk*cos(*(u+1)-2./3.*M_PI); 
    275       Kalman[0]=ua;                     // usx 
    276       Kalman[1]=(ua+2.*ub)/sqrt(3.);    // usy 
    277       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; 
    279280 
    280281      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