1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> |
---|
2 | <html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"> |
---|
3 | <title>mixpp: pmsmDS.h Source File</title> |
---|
4 | <link href="tabs.css" rel="stylesheet" type="text/css"> |
---|
5 | <link href="doxygen.css" rel="stylesheet" type="text/css"> |
---|
6 | </head><body> |
---|
7 | <!-- Generated by Doxygen 1.5.8 --> |
---|
8 | <script type="text/javascript"> |
---|
9 | <!-- |
---|
10 | function changeDisplayState (e){ |
---|
11 | var num=this.id.replace(/[^[0-9]/g,''); |
---|
12 | var button=this.firstChild; |
---|
13 | var sectionDiv=document.getElementById('dynsection'+num); |
---|
14 | if (sectionDiv.style.display=='none'||sectionDiv.style.display==''){ |
---|
15 | sectionDiv.style.display='block'; |
---|
16 | button.src='open.gif'; |
---|
17 | }else{ |
---|
18 | sectionDiv.style.display='none'; |
---|
19 | button.src='closed.gif'; |
---|
20 | } |
---|
21 | } |
---|
22 | function initDynSections(){ |
---|
23 | var divs=document.getElementsByTagName('div'); |
---|
24 | var sectionCounter=1; |
---|
25 | for(var i=0;i<divs.length-1;i++){ |
---|
26 | if(divs[i].className=='dynheader'&&divs[i+1].className=='dynsection'){ |
---|
27 | var header=divs[i]; |
---|
28 | var section=divs[i+1]; |
---|
29 | var button=header.firstChild; |
---|
30 | if (button!='IMG'){ |
---|
31 | divs[i].insertBefore(document.createTextNode(' '),divs[i].firstChild); |
---|
32 | button=document.createElement('img'); |
---|
33 | divs[i].insertBefore(button,divs[i].firstChild); |
---|
34 | } |
---|
35 | header.style.cursor='pointer'; |
---|
36 | header.onclick=changeDisplayState; |
---|
37 | header.id='dynheader'+sectionCounter; |
---|
38 | button.src='closed.gif'; |
---|
39 | section.id='dynsection'+sectionCounter; |
---|
40 | section.style.display='none'; |
---|
41 | section.style.marginLeft='14px'; |
---|
42 | sectionCounter++; |
---|
43 | } |
---|
44 | } |
---|
45 | } |
---|
46 | window.onload = initDynSections; |
---|
47 | --> |
---|
48 | </script> |
---|
49 | <div class="navigation" id="top"> |
---|
50 | <div class="tabs"> |
---|
51 | <ul> |
---|
52 | <li><a href="main.html"><span>Main Page</span></a></li> |
---|
53 | <li><a href="pages.html"><span>Related Pages</span></a></li> |
---|
54 | <li><a href="modules.html"><span>Modules</span></a></li> |
---|
55 | <li><a href="annotated.html"><span>Classes</span></a></li> |
---|
56 | <li class="current"><a href="files.html"><span>Files</span></a></li> |
---|
57 | </ul> |
---|
58 | </div> |
---|
59 | <div class="tabs"> |
---|
60 | <ul> |
---|
61 | <li><a href="files.html"><span>File List</span></a></li> |
---|
62 | <li><a href="globals.html"><span>File Members</span></a></li> |
---|
63 | </ul> |
---|
64 | </div> |
---|
65 | <h1>pmsmDS.h</h1><a href="pmsmDS_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 |
---|
66 | <a name="l00013"></a>00013 <span class="preprocessor">#include <<a class="code" href="loggers_8h.html" title="Loggers for storing results of experiments.">stat/loggers.h</a>></span> |
---|
67 | <a name="l00014"></a>00014 <span class="preprocessor">#include "simulator.h"</span> |
---|
68 | <a name="l00015"></a>00015 <span class="preprocessor">#include "pmsm.h"</span> |
---|
69 | <a name="l00016"></a>00016 |
---|
70 | <a name="l00018"></a><a class="code" href="classpmsmDS.html">00018</a> <span class="keyword">class </span><a class="code" href="classpmsmDS.html" title="Simulator of PMSM machine with predefined profile on omega.">pmsmDS</a> : <span class="keyword">public</span> <a class="code" href="classbdm_1_1DS.html" title="Abstract class for discrete-time sources of data.">DS</a> { |
---|
71 | <a name="l00019"></a>00019 |
---|
72 | <a name="l00020"></a>00020 <span class="keyword">protected</span>: |
---|
73 | <a name="l00022"></a><a class="code" href="classpmsmDS.html#3975e648cc981a550997df8120e176f7">00022</a> <span class="keywordtype">int</span> <a class="code" href="classpmsmDS.html#3975e648cc981a550997df8120e176f7" title="indeces of logged variables">L_x</a>, L_ou, L_oy, L_iu, L_optu; |
---|
74 | <a name="l00024"></a><a class="code" href="classpmsmDS.html#ba6fbc63e4353135857bbba8f30e3012">00024</a> vec <a class="code" href="classpmsmDS.html#ba6fbc63e4353135857bbba8f30e3012" title="Setpoints of omega in timespans given by dt_prof.">profileWw</a>; |
---|
75 | <a name="l00026"></a><a class="code" href="classpmsmDS.html#01d9d15490d336b6613368557608f4fe">00026</a> <span class="keywordtype">double</span> <a class="code" href="classpmsmDS.html#01d9d15490d336b6613368557608f4fe" title="time-step for profiles">dt_prof</a>; |
---|
76 | <a name="l00028"></a><a class="code" href="classpmsmDS.html#c27956dc82ede2e8dbeb34e6cfa15a40">00028</a> <span class="keywordtype">int</span> <a class="code" href="classpmsmDS.html#c27956dc82ede2e8dbeb34e6cfa15a40" title="Number of miliseconds per discrete time step.">Dt</a>; |
---|
77 | <a name="l00030"></a><a class="code" href="classpmsmDS.html#f387fee363e4a8492074fee36bb8421b">00030</a> <span class="keywordtype">bool</span> <a class="code" href="classpmsmDS.html#f387fee363e4a8492074fee36bb8421b" title="options for logging, - log predictions of &#39;true&#39; voltage">opt_modu</a>; |
---|
78 | <a name="l00031"></a>00031 <span class="keyword">public</span>: |
---|
79 | <a name="l00033"></a><a class="code" href="classpmsmDS.html#e6a50a246de039f30cb5423521aab55c">00033</a> <a class="code" href="classpmsmDS.html#e6a50a246de039f30cb5423521aab55c" title="Constructor with fixed sampling period.">pmsmDS</a> () {<a class="code" href="classpmsmDS.html#c27956dc82ede2e8dbeb34e6cfa15a40" title="Number of miliseconds per discrete time step.">Dt</a>=125; <a class="code" href="classbdm_1_1DS.html#d8db125ac35f3b8eeb773fc9a4cb45ec" title="Description of data returned by getdata().">Drv</a>=<a class="code" href="classbdm_1_1RV.html" title="Class representing variables, most often random variables.">RV</a> ( <span class="stringliteral">"{o_ua o_ub o_ia o_ib t_ua t_ub }"</span> );} |
---|
80 | <a name="l00034"></a>00034 <span class="keywordtype">void</span> set_parameters ( <span class="keywordtype">double</span> Rs0, <span class="keywordtype">double</span> Ls0, <span class="keywordtype">double</span> Fmag0, <span class="keywordtype">double</span> Bf0, <span class="keywordtype">double</span> p0, <span class="keywordtype">double</span> kp0, <span class="keywordtype">double</span> J0, <span class="keywordtype">double</span> Uc0, <span class="keywordtype">double</span> DT0, <span class="keywordtype">double</span> dt0 ) { |
---|
81 | <a name="l00035"></a>00035 pmsmsim_set_parameters ( Rs0, Ls0, Fmag0, Bf0, p0, kp0, J0, Uc0, DT0, dt0 ); |
---|
82 | <a name="l00036"></a>00036 } |
---|
83 | <a name="l00038"></a><a class="code" href="classpmsmDS.html#75dd22db70746bfd0c3e685a17bbf34a">00038</a> <span class="keywordtype">void</span> <a class="code" href="classpmsmDS.html#75dd22db70746bfd0c3e685a17bbf34a" title="parse options: &quot;modelu&quot; =&gt; opt_modu=true;">set_options</a> ( <span class="keywordtype">string</span> &opt ) { |
---|
84 | <a name="l00039"></a>00039 <a class="code" href="classpmsmDS.html#f387fee363e4a8492074fee36bb8421b" title="options for logging, - log predictions of &#39;true&#39; voltage">opt_modu</a> = ( opt.find ( <span class="stringliteral">"modelu"</span> ) ==string::npos ); |
---|
85 | <a name="l00040"></a>00040 } |
---|
86 | <a name="l00041"></a><a class="code" href="classpmsmDS.html#4e47e678eb56e0b3bd47d801d0995e46">00041</a> <span class="keywordtype">void</span> <a class="code" href="classpmsmDS.html#4e47e678eb56e0b3bd47d801d0995e46" title="Returns full vector of observed data=[output, input].">getdata</a> ( vec &dt ) {dt=vec ( KalmanObs,6 );} |
---|
87 | <a name="l00042"></a><a class="code" href="classpmsmDS.html#35e9a2b9d82bd1b71d66778021d1e8b4">00042</a> <span class="keywordtype">void</span> <a class="code" href="classpmsmDS.html#35e9a2b9d82bd1b71d66778021d1e8b4" title="Accepts action variable and schedule it for application.">write</a> ( vec &ut ) {} |
---|
88 | <a name="l00043"></a>00043 |
---|
89 | <a name="l00044"></a><a class="code" href="classpmsmDS.html#664fc8deff7c141ee7ab826a9abb387b">00044</a> <span class="keywordtype">void</span> <a class="code" href="classpmsmDS.html#664fc8deff7c141ee7ab826a9abb387b" title="Moves from to , i.e. perfroms the actions and reads response of the system.">step</a>() { |
---|
90 | <a name="l00045"></a>00045 <span class="keyword">static</span> <span class="keywordtype">int</span> ind=0; |
---|
91 | <a name="l00046"></a>00046 <span class="keyword">static</span> <span class="keywordtype">double</span> dW; <span class="comment">// increase of W</span> |
---|
92 | <a name="l00047"></a>00047 <span class="keyword">static</span> <span class="keywordtype">double</span> Ww; <span class="comment">// W</span> |
---|
93 | <a name="l00048"></a>00048 <span class="keywordflow">if</span> ( t>=<a class="code" href="classpmsmDS.html#01d9d15490d336b6613368557608f4fe" title="time-step for profiles">dt_prof</a>*ind ) { |
---|
94 | <a name="l00049"></a>00049 ind++; |
---|
95 | <a name="l00050"></a>00050 <span class="keywordflow">if</span> ( ind<<a class="code" href="classpmsmDS.html#ba6fbc63e4353135857bbba8f30e3012" title="Setpoints of omega in timespans given by dt_prof.">profileWw</a>.length() ) { |
---|
96 | <a name="l00051"></a>00051 <span class="comment">//linear increase</span> |
---|
97 | <a name="l00052"></a>00052 <span class="keywordflow">if</span> ( <a class="code" href="classpmsmDS.html#ba6fbc63e4353135857bbba8f30e3012" title="Setpoints of omega in timespans given by dt_prof.">profileWw</a>.length() ==1 ) { |
---|
98 | <a name="l00053"></a>00053 Ww=<a class="code" href="classpmsmDS.html#ba6fbc63e4353135857bbba8f30e3012" title="Setpoints of omega in timespans given by dt_prof.">profileWw</a> ( 0 ); dW=0.0; |
---|
99 | <a name="l00054"></a>00054 } |
---|
100 | <a name="l00055"></a>00055 <span class="keywordflow">else</span> { |
---|
101 | <a name="l00056"></a>00056 dW = <a class="code" href="classpmsmDS.html#ba6fbc63e4353135857bbba8f30e3012" title="Setpoints of omega in timespans given by dt_prof.">profileWw</a> ( ind )-<a class="code" href="classpmsmDS.html#ba6fbc63e4353135857bbba8f30e3012" title="Setpoints of omega in timespans given by dt_prof.">profileWw</a> ( ind-1 ); |
---|
102 | <a name="l00057"></a>00057 dW *=125e-6/<a class="code" href="classpmsmDS.html#01d9d15490d336b6613368557608f4fe" title="time-step for profiles">dt_prof</a>; |
---|
103 | <a name="l00058"></a>00058 } |
---|
104 | <a name="l00059"></a>00059 } |
---|
105 | <a name="l00060"></a>00060 <span class="keywordflow">else</span> { |
---|
106 | <a name="l00061"></a>00061 dW = 0; |
---|
107 | <a name="l00062"></a>00062 } |
---|
108 | <a name="l00063"></a>00063 } |
---|
109 | <a name="l00064"></a>00064 Ww += dW; |
---|
110 | <a name="l00065"></a>00065 <span class="comment">//Simulate Dt seconds!</span> |
---|
111 | <a name="l00066"></a>00066 <span class="keywordflow">for</span> ( <span class="keywordtype">int</span> i=0;i<<a class="code" href="classpmsmDS.html#c27956dc82ede2e8dbeb34e6cfa15a40" title="Number of miliseconds per discrete time step.">Dt</a>;i++ ) { pmsmsim_step ( Ww );} |
---|
112 | <a name="l00067"></a>00067 }; |
---|
113 | <a name="l00068"></a>00068 |
---|
114 | <a name="l00069"></a><a class="code" href="classpmsmDS.html#d75b83468db25c56977ffccff46b0b37">00069</a> <span class="keywordtype">void</span> <a class="code" href="classpmsmDS.html#d75b83468db25c56977ffccff46b0b37" title="Register DS for logging into logger L.">log_add</a> ( <a class="code" href="classbdm_1_1logger.html" title="Class for storing results (and semi-results) of an experiment.">logger</a> &L ) { |
---|
115 | <a name="l00070"></a>00070 <a class="code" href="classpmsmDS.html#3975e648cc981a550997df8120e176f7" title="indeces of logged variables">L_x</a> = L.<a class="code" href="classbdm_1_1logger.html#cfb4807e20b3d00f3d33e55ada528dc1">add</a> ( rx, <span class="stringliteral">"x"</span> ); |
---|
116 | <a name="l00071"></a>00071 L_oy = L.<a class="code" href="classbdm_1_1logger.html#cfb4807e20b3d00f3d33e55ada528dc1">add</a> ( ry, <span class="stringliteral">"o"</span> ); |
---|
117 | <a name="l00072"></a>00072 L_ou = L.<a class="code" href="classbdm_1_1logger.html#cfb4807e20b3d00f3d33e55ada528dc1">add</a> ( ru, <span class="stringliteral">"o"</span> ); |
---|
118 | <a name="l00073"></a>00073 L_iu = L.<a class="code" href="classbdm_1_1logger.html#cfb4807e20b3d00f3d33e55ada528dc1">add</a> ( ru, <span class="stringliteral">"t"</span> ); |
---|
119 | <a name="l00074"></a>00074 <span class="comment">// log differences</span> |
---|
120 | <a name="l00075"></a>00075 <span class="keywordflow">if</span> ( <a class="code" href="classpmsmDS.html#f387fee363e4a8492074fee36bb8421b" title="options for logging, - log predictions of &#39;true&#39; voltage">opt_modu</a> ) { |
---|
121 | <a name="l00076"></a>00076 L_optu = L.<a class="code" href="classbdm_1_1logger.html#cfb4807e20b3d00f3d33e55ada528dc1">add</a> ( ru, <span class="stringliteral">"model"</span> ); |
---|
122 | <a name="l00077"></a>00077 } |
---|
123 | <a name="l00078"></a>00078 } |
---|
124 | <a name="l00079"></a>00079 |
---|
125 | <a name="l00080"></a><a class="code" href="classpmsmDS.html#21cac6deaac2dd073c982d7bec839b47">00080</a> <span class="keywordtype">void</span> <a class="code" href="classpmsmDS.html#21cac6deaac2dd073c982d7bec839b47" title="Register DS for logging into logger L.">logit</a> ( <a class="code" href="classbdm_1_1logger.html" title="Class for storing results (and semi-results) of an experiment.">logger</a> &L ) { |
---|
126 | <a name="l00081"></a>00081 L.<a class="code" href="classbdm_1_1logger.html#397c014b0aaf3581516e2a105d26a5c9" title="log this vector">logit</a> ( <a class="code" href="classpmsmDS.html#3975e648cc981a550997df8120e176f7" title="indeces of logged variables">L_x</a>, vec ( x,4 ) ); |
---|
127 | <a name="l00082"></a>00082 L.<a class="code" href="classbdm_1_1logger.html#397c014b0aaf3581516e2a105d26a5c9" title="log this vector">logit</a> ( L_oy, vec_2 ( KalmanObs[2],KalmanObs[3] ) ); |
---|
128 | <a name="l00083"></a>00083 L.<a class="code" href="classbdm_1_1logger.html#397c014b0aaf3581516e2a105d26a5c9" title="log this vector">logit</a> ( L_ou, vec_2 ( KalmanObs[0],KalmanObs[1] ) ); |
---|
129 | <a name="l00084"></a>00084 L.<a class="code" href="classbdm_1_1logger.html#397c014b0aaf3581516e2a105d26a5c9" title="log this vector">logit</a> ( L_iu, vec_2 ( KalmanObs[4],KalmanObs[5] ) ); |
---|
130 | <a name="l00085"></a>00085 <span class="keywordflow">if</span> ( <a class="code" href="classpmsmDS.html#f387fee363e4a8492074fee36bb8421b" title="options for logging, - log predictions of &#39;true&#39; voltage">opt_modu</a> ) { |
---|
131 | <a name="l00086"></a>00086 <span class="keywordtype">double</span> sq3=sqrt ( 3.0 ); |
---|
132 | <a name="l00087"></a>00087 <span class="keywordtype">double</span> ua,ub; |
---|
133 | <a name="l00088"></a>00088 <span class="keywordtype">double</span> i1=x[0]; |
---|
134 | <a name="l00089"></a>00089 <span class="keywordtype">double</span> i2=0.5* ( -i1+sq3*x[1] ); |
---|
135 | <a name="l00090"></a>00090 <span class="keywordtype">double</span> i3=0.5* ( -i1-sq3*x[1] ); |
---|
136 | <a name="l00091"></a>00091 <span class="keywordtype">double</span> u1=KalmanObs[0]; |
---|
137 | <a name="l00092"></a>00092 <span class="keywordtype">double</span> u2=0.5* ( -u1+sq3*KalmanObs[1] ); |
---|
138 | <a name="l00093"></a>00093 <span class="keywordtype">double</span> u3=0.5* ( -u1-sq3*KalmanObs[1] ); |
---|
139 | <a name="l00094"></a>00094 |
---|
140 | <a name="l00095"></a>00095 <span class="keywordtype">double</span> du1=0.7* ( double ( i1>0.1 ) - double ( i1<-0.1 ) ) +0.05*i1; |
---|
141 | <a name="l00096"></a>00096 <span class="keywordtype">double</span> du2=0.7* ( double ( i2>0.1 ) - double ( i2<-0.1 ) ) +0.05*i2; |
---|
142 | <a name="l00097"></a>00097 <span class="keywordtype">double</span> du3=0.7* ( double ( i3>0.1 ) - double ( i3<-0.1 ) ) +0.05*i3; |
---|
143 | <a name="l00098"></a>00098 ua = ( 2.0* ( u1-du1 )- ( u2-du2 )- ( u3-du3 ) ) /3.0; |
---|
144 | <a name="l00099"></a>00099 ub = ( ( u2-du2 )- ( u3-du3 ) ) /sq3; |
---|
145 | <a name="l00100"></a>00100 L.<a class="code" href="classbdm_1_1logger.html#397c014b0aaf3581516e2a105d26a5c9" title="log this vector">logit</a> ( L_optu , vec_2 ( ua,ub ) ); |
---|
146 | <a name="l00101"></a>00101 } |
---|
147 | <a name="l00102"></a>00102 } |
---|
148 | <a name="l00103"></a>00103 |
---|
149 | <a name="l00104"></a>00104 <span class="keywordtype">void</span> set_profile ( <span class="keywordtype">double</span> dt, <span class="keyword">const</span> vec &Ww ) {<a class="code" href="classpmsmDS.html#01d9d15490d336b6613368557608f4fe" title="time-step for profiles">dt_prof</a>=dt; <a class="code" href="classpmsmDS.html#ba6fbc63e4353135857bbba8f30e3012" title="Setpoints of omega in timespans given by dt_prof.">profileWw</a>=Ww;} |
---|
150 | <a name="l00105"></a>00105 }; |
---|
151 | </pre></div></div> |
---|
152 | <hr size="1"><address style="text-align: right;"><small>Generated on Tue Mar 17 18:33:03 2009 for mixpp by |
---|
153 | <a href="http://www.doxygen.org/index.html"> |
---|
154 | <img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.8 </small></address> |
---|
155 | </body> |
---|
156 | </html> |
---|