Changeset 1243

Show
Ignore:
Timestamp:
11/02/10 21:20:06 (14 years ago)
Author:
smidl
Message:

Contrallable PMSM DS + PI control

Files:
2 added
6 modified

Legend:

Unmodified
Added
Removed
  • applications/pmsm/CMakeLists.txt

    r1184 r1243  
    3131EXEC (pmsm_estim pmsmsim ekf_obj) 
    3232MEX (pmsm_estim pmsmsim ekf_obj) 
     33EXEC (pmsm_ctrl pmsmsim ekf_obj) 
     34MEX (pmsm_ctrl pmsmsim ekf_obj) 
     35 
    3336#EXEC (sim pmsmsim) 
    3437#EXEC (sim_var pmsmsim) 
  • applications/pmsm/pmsm.h

    r1192 r1243  
    1212 
    1313//TODO hardcoded RVs!!! 
    14 RV rx ( "{ia ib om th }"); 
    15 RV ru ( "{o_ua o_ub }"); 
    16 RV ry ( "{oia oib }"); 
     14// RV rx ( "{ia ib om th }"); 
     15// RV ru ( "{o_ua o_ub }"); 
     16// RV ry ( "{oia oib }"); 
    1717 
    1818// class uipmsm : public uibase{ 
     
    390390 
    391391 
    392  
    393  
    394392/*!@}*/ 
    395393#endif //PMSM_H 
  • applications/pmsm/pmsmDS.h

    r1198 r1243  
    1010  ----------------------------------- 
    1111*/ 
     12 
     13#ifndef PMSM_DS 
     14#define PMSM_DS 
    1215 
    1316#include <base/loggers.h> 
     
    116119        if ( log_level[logvoltage] ) 
    117120        { 
    118             L.add_vector ( log_level, logvoltage, ru, "model" ); 
     121            L.add_vector ( log_level, logvoltage, RV("{ua, ub }"), "model" ); 
    119122        } 
    120123    } 
     
    174177UIREGISTER ( pmsmDS ); 
    175178 
     179//! Simulator of PMSM machine with predefined profile on omega 
     180class pmsmDSctrl : public pmsmDS 
     181{ 
     182        double Ww; 
     183        double ua; 
     184        double ub; 
     185public: 
     186        //! Constructor with fixed sampling period 
     187    pmsmDSctrl() : pmsmDS() 
     188        { 
     189                Drv.add(RV ( "{Ww }" )); 
     190                Urv=RV ( "{ua ub }" ); 
     191                dtsize = Drv._dsize(); 
     192                utsize = Urv._dsize(); 
     193        } 
     194                 
     195                void getdata ( vec &dt ) const 
     196                { 
     197                        pmsmDS::getdata(dt); 
     198                        dt(9)=Ww; 
     199                } 
     200                void write (const vec &ut ) { 
     201                        ua = ut(0); 
     202                        ub = ut(1); 
     203                } 
     204                 
     205                void step() 
     206                { 
     207                        static int ind=0; 
     208                        static double dW; // increase of W 
     209                        static double Mz; // W 
     210                        t+=125e-6; 
     211                        if ( t>=dt_prof*ind ) 
     212                        { 
     213                                ind++; 
     214                                // check omega profile and set dW 
     215                                if ( ind <2 && profileWw.length() ==1 ) 
     216                                { 
     217                                        Ww=profileWw ( 0 ); 
     218                                        dW=0.0; 
     219                                } 
     220                                if ( ind<profileWw.length() ) 
     221                                { 
     222                                        dW = profileWw ( ind )-profileWw ( ind-1 ); 
     223                                        dW *=125e-6/dt_prof; 
     224                                } 
     225                                else 
     226                                { 
     227                                        dW = 0; 
     228                                } 
     229                                // Check Mz profile and set Mz 
     230                                if ( ind<profileMz.length() ) 
     231                                { 
     232                                        //sudden increase 
     233                                        Mz = profileMz(ind); 
     234                                } 
     235                                else 
     236                                { 
     237                                        Mz = 0; 
     238                                } 
     239                        } 
     240                        Ww += dW; 
     241                        //Simulate Dt seconds! 
     242                        for ( int i=0; i<Dt; i++ ) 
     243                        { 
     244                                pmsmsim_noreg_step (ua , ub); 
     245                        } 
     246        }; 
     247         
     248        }; 
     249         
     250        UIREGISTER ( pmsmDSctrl ); 
     251         
    176252 
    177253//! This class behaves like BM but it is evaluating EKF 
     
    337413 
    338414UIREGISTER ( pmsmCRBMz ); 
     415 
     416#endif 
  • applications/pmsm/simulator_zdenek/simulator.cpp

    r326 r1243  
    484484 
    485485  pmsm_model(5); 
     486 
     487  KalmanObs[0]=ualfa; //debug_pwm;                     // usx 
     488  KalmanObs[1]=ubeta;    // usy 
     489   
     490  KalmanObs[2]=x[0]; 
     491  KalmanObs[3]=x[1]; 
     492   
     493  // diagnostic - mean values of stator voltage components - pwm() 
     494  KalmanObs[4]=usx_av; 
     495  KalmanObs[5]=usy_av; 
     496  KalmanObs[6]=usxf; 
     497  KalmanObs[7]=usyf; 
     498   
    486499} 
    487500////////////////////////////////////////////////////////////////////////////////////////////////////// 
  • library/bdm/design/arx_ctrl.h

    r1064 r1243  
    6060        lq.redesign(); 
    6161    } 
    62     vec ctrlaction ( const vec &cond ) const { 
     62    vec ctrlaction ( const vec &cond ) { 
    6363        //cond is xt + ut 
    6464        vec state = cond.left ( Stsp->_A().rows() ); 
  • library/bdm/design/ctrlbase.h

    r1130 r1243  
    1010  ----------------------------------- 
    1111*/ 
     12 
     13#ifndef CTRL_BASE 
     14#define CTRL_BASE 
     15 
    1216 
    1317#include "../base/bdmbase.h" 
     
    3236    virtual void redesign() {}; 
    3337    //! returns designed control action 
    34     virtual vec ctrlaction ( const vec &cond ) const { 
     38    virtual vec ctrlaction ( const vec &cond ) { 
    3539        return vec ( 0 ); 
    3640    } 
     
    129133 
    130134    //! compute control action 
    131     vec ctrlaction ( const vec &state, const vec &ukm ) const { 
     135    vec ctrlaction ( const vec &state, const vec &ukm ) { 
    132136        vec pom = concat ( state, ones ( dimy ), ukm ); 
    133137        return L*pom; 
     
    141145 
    142146} // namespace 
     147 
     148#endif //CTRL_BASE