| 1 | <?xml version='1.0' encoding='UTF-8' standalone='no'?> |
|---|
| 2 | <doxygen xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="compound.xsd" version="1.5.6"> |
|---|
| 3 | <compounddef id="fixed_8cpp" kind="file"> |
|---|
| 4 | <compoundname>fixed.cpp</compoundname> |
|---|
| 5 | <includes refid="fixed_8h" local="yes">fixed.h</includes> |
|---|
| 6 | <incdepgraph> |
|---|
| 7 | <node id="751"> |
|---|
| 8 | <label>work/git/mixpp/pmsm/simulator_zdenek/ekf_example/fixed.cpp</label> |
|---|
| 9 | <link refid="fixed.cpp"/> |
|---|
| 10 | <childnode refid="752" relation="include"> |
|---|
| 11 | </childnode> |
|---|
| 12 | </node> |
|---|
| 13 | <node id="752"> |
|---|
| 14 | <label>fixed.h</label> |
|---|
| 15 | <link refid="fixed_8h-source"/> |
|---|
| 16 | </node> |
|---|
| 17 | </incdepgraph> |
|---|
| 18 | <sectiondef kind="func"> |
|---|
| 19 | <memberdef kind="function" id="fixed_8cpp_198167cf2f2a56e52fe05495e1ac08678" prot="public" static="no" const="no" explicit="no" inline="no" virt="non-virtual"> |
|---|
| 20 | <type>long</type> |
|---|
| 21 | <definition>long prevod</definition> |
|---|
| 22 | <argsstring>(double x, unsigned int posun)</argsstring> |
|---|
| 23 | <name>prevod</name> |
|---|
| 24 | <param> |
|---|
| 25 | <type>double</type> |
|---|
| 26 | <declname>x</declname> |
|---|
| 27 | </param> |
|---|
| 28 | <param> |
|---|
| 29 | <type>unsigned int</type> |
|---|
| 30 | <declname>posun</declname> |
|---|
| 31 | </param> |
|---|
| 32 | <briefdescription> |
|---|
| 33 | </briefdescription> |
|---|
| 34 | <detaileddescription> |
|---|
| 35 | </detaileddescription> |
|---|
| 36 | <inbodydescription> |
|---|
| 37 | </inbodydescription> |
|---|
| 38 | <location file="/home/smidl/work/git/mixpp/pmsm/simulator_zdenek/ekf_example/fixed.cpp" line="10" bodyfile="/home/smidl/work/git/mixpp/pmsm/simulator_zdenek/ekf_example/fixed.cpp" bodystart="22" bodyend="33"/> |
|---|
| 39 | </memberdef> |
|---|
| 40 | <memberdef kind="function" id="fixed_8cpp_1621d21561d09502b53759d627511b688" prot="public" static="no" const="no" explicit="no" inline="no" virt="non-virtual"> |
|---|
| 41 | <type>double</type> |
|---|
| 42 | <definition>double zprevod</definition> |
|---|
| 43 | <argsstring>(long x, unsigned int posun)</argsstring> |
|---|
| 44 | <name>zprevod</name> |
|---|
| 45 | <param> |
|---|
| 46 | <type>long</type> |
|---|
| 47 | <declname>x</declname> |
|---|
| 48 | </param> |
|---|
| 49 | <param> |
|---|
| 50 | <type>unsigned int</type> |
|---|
| 51 | <declname>posun</declname> |
|---|
| 52 | </param> |
|---|
| 53 | <briefdescription> |
|---|
| 54 | </briefdescription> |
|---|
| 55 | <detaileddescription> |
|---|
| 56 | </detaileddescription> |
|---|
| 57 | <inbodydescription> |
|---|
| 58 | </inbodydescription> |
|---|
| 59 | <location file="/home/smidl/work/git/mixpp/pmsm/simulator_zdenek/ekf_example/fixed.cpp" line="12" bodyfile="/home/smidl/work/git/mixpp/pmsm/simulator_zdenek/ekf_example/fixed.cpp" bodystart="35" bodyend="44"/> |
|---|
| 60 | </memberdef> |
|---|
| 61 | <memberdef kind="function" id="fixed_8cpp_150d456f9c404f8c7e49246d61930c59c" prot="public" static="no" const="no" explicit="no" inline="no" virt="non-virtual"> |
|---|
| 62 | <type>long</type> |
|---|
| 63 | <definition>long nasob</definition> |
|---|
| 64 | <argsstring>(int x, int y, unsigned int posun)</argsstring> |
|---|
| 65 | <name>nasob</name> |
|---|
| 66 | <param> |
|---|
| 67 | <type>int</type> |
|---|
| 68 | <declname>x</declname> |
|---|
| 69 | </param> |
|---|
| 70 | <param> |
|---|
| 71 | <type>int</type> |
|---|
| 72 | <declname>y</declname> |
|---|
| 73 | </param> |
|---|
| 74 | <param> |
|---|
| 75 | <type>unsigned int</type> |
|---|
| 76 | <declname>posun</declname> |
|---|
| 77 | </param> |
|---|
| 78 | <briefdescription> |
|---|
| 79 | </briefdescription> |
|---|
| 80 | <detaileddescription> |
|---|
| 81 | </detaileddescription> |
|---|
| 82 | <inbodydescription> |
|---|
| 83 | </inbodydescription> |
|---|
| 84 | <location file="/home/smidl/work/git/mixpp/pmsm/simulator_zdenek/ekf_example/fixed.cpp" line="14" bodyfile="/home/smidl/work/git/mixpp/pmsm/simulator_zdenek/ekf_example/fixed.cpp" bodystart="46" bodyend="60"/> |
|---|
| 85 | </memberdef> |
|---|
| 86 | <memberdef kind="function" id="fixed_8cpp_19aaf1455f6660d8566e6876236e3e3ab" prot="public" static="no" const="no" explicit="no" inline="no" virt="non-virtual"> |
|---|
| 87 | <type>int</type> |
|---|
| 88 | <definition>int deleni15</definition> |
|---|
| 89 | <argsstring>(int x, int y)</argsstring> |
|---|
| 90 | <name>deleni15</name> |
|---|
| 91 | <param> |
|---|
| 92 | <type>int</type> |
|---|
| 93 | <declname>x</declname> |
|---|
| 94 | </param> |
|---|
| 95 | <param> |
|---|
| 96 | <type>int</type> |
|---|
| 97 | <declname>y</declname> |
|---|
| 98 | </param> |
|---|
| 99 | <briefdescription> |
|---|
| 100 | </briefdescription> |
|---|
| 101 | <detaileddescription> |
|---|
| 102 | </detaileddescription> |
|---|
| 103 | <inbodydescription> |
|---|
| 104 | </inbodydescription> |
|---|
| 105 | <location file="/home/smidl/work/git/mixpp/pmsm/simulator_zdenek/ekf_example/fixed.cpp" line="16" bodyfile="/home/smidl/work/git/mixpp/pmsm/simulator_zdenek/ekf_example/fixed.cpp" bodystart="62" bodyend="71"/> |
|---|
| 106 | </memberdef> |
|---|
| 107 | <memberdef kind="function" id="fixed_8cpp_1ea13e9b9069cde6d7947242971c7780c" prot="public" static="no" const="no" explicit="no" inline="no" virt="non-virtual"> |
|---|
| 108 | <type>int</type> |
|---|
| 109 | <definition>int deleni</definition> |
|---|
| 110 | <argsstring>(int x, int y, int posun1, int posun2, int scale, int posun_fin)</argsstring> |
|---|
| 111 | <name>deleni</name> |
|---|
| 112 | <param> |
|---|
| 113 | <type>int</type> |
|---|
| 114 | <declname>x</declname> |
|---|
| 115 | </param> |
|---|
| 116 | <param> |
|---|
| 117 | <type>int</type> |
|---|
| 118 | <declname>y</declname> |
|---|
| 119 | </param> |
|---|
| 120 | <param> |
|---|
| 121 | <type>int</type> |
|---|
| 122 | <declname>posun1</declname> |
|---|
| 123 | </param> |
|---|
| 124 | <param> |
|---|
| 125 | <type>int</type> |
|---|
| 126 | <declname>posun2</declname> |
|---|
| 127 | </param> |
|---|
| 128 | <param> |
|---|
| 129 | <type>int</type> |
|---|
| 130 | <declname>scale</declname> |
|---|
| 131 | </param> |
|---|
| 132 | <param> |
|---|
| 133 | <type>int</type> |
|---|
| 134 | <declname>posun_fin</declname> |
|---|
| 135 | </param> |
|---|
| 136 | <briefdescription> |
|---|
| 137 | </briefdescription> |
|---|
| 138 | <detaileddescription> |
|---|
| 139 | </detaileddescription> |
|---|
| 140 | <inbodydescription> |
|---|
| 141 | </inbodydescription> |
|---|
| 142 | <location file="/home/smidl/work/git/mixpp/pmsm/simulator_zdenek/ekf_example/fixed.cpp" line="18" bodyfile="/home/smidl/work/git/mixpp/pmsm/simulator_zdenek/ekf_example/fixed.cpp" bodystart="73" bodyend="107"/> |
|---|
| 143 | </memberdef> |
|---|
| 144 | </sectiondef> |
|---|
| 145 | <briefdescription> |
|---|
| 146 | </briefdescription> |
|---|
| 147 | <detaileddescription> |
|---|
| 148 | </detaileddescription> |
|---|
| 149 | <programlisting> |
|---|
| 150 | <codeline lineno="1"><highlight class="comment">/*<sp/></highlight></codeline> |
|---|
| 151 | <codeline lineno="2"><highlight class="comment"><sp/><sp/><sp/>Operace<sp/>v<sp/>pevne<sp/>radove<sp/>carce</highlight></codeline> |
|---|
| 152 | <codeline lineno="3"><highlight class="comment"><sp/><sp/><sp/></highlight></codeline> |
|---|
| 153 | <codeline lineno="4"><highlight class="comment"><sp/><sp/><sp/>9.10.2005</highlight></codeline> |
|---|
| 154 | <codeline lineno="5"><highlight class="comment">*/</highlight><highlight class="normal"></highlight></codeline> |
|---|
| 155 | <codeline lineno="6"><highlight class="normal"></highlight></codeline> |
|---|
| 156 | <codeline lineno="7"><highlight class="normal"></highlight></codeline> |
|---|
| 157 | <codeline lineno="8"><highlight class="normal"></highlight><highlight class="preprocessor">#include<sp/>"fixed.h"</highlight><highlight class="normal"></highlight></codeline> |
|---|
| 158 | <codeline lineno="9"><highlight class="normal"></highlight></codeline> |
|---|
| 159 | <codeline lineno="10"><highlight class="normal"></highlight><highlight class="keywordtype">long</highlight><highlight class="normal"><sp/>prevod(</highlight><highlight class="keywordtype">double</highlight><highlight class="normal"><sp/>x,<sp/></highlight><highlight class="keywordtype">unsigned</highlight><highlight class="normal"><sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>posun);</highlight></codeline> |
|---|
| 160 | <codeline lineno="11"><highlight class="normal"></highlight><highlight class="comment">//<sp/>prevod<sp/>"x"<sp/>do<sp/>systemu<sp/>"Qposun"</highlight><highlight class="normal"></highlight></codeline> |
|---|
| 161 | <codeline lineno="12"><highlight class="normal"></highlight><highlight class="keywordtype">double</highlight><highlight class="normal"><sp/>zprevod(</highlight><highlight class="keywordtype">long</highlight><highlight class="normal"><sp/>x,<sp/></highlight><highlight class="keywordtype">unsigned</highlight><highlight class="normal"><sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>posun);</highlight></codeline> |
|---|
| 162 | <codeline lineno="13"><highlight class="normal"></highlight><highlight class="comment">//<sp/>prevod<sp/>"x"<sp/>ze<sp/>systemu<sp/>"Qposun"<sp/>do<sp/>DOUBLE</highlight><highlight class="normal"></highlight></codeline> |
|---|
| 163 | <codeline lineno="14"><highlight class="normal"></highlight><highlight class="keywordtype">long</highlight><highlight class="normal"><sp/>nasob(</highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>x,<sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>y,</highlight><highlight class="keywordtype">unsigned</highlight><highlight class="normal"><sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>posun);</highlight></codeline> |
|---|
| 164 | <codeline lineno="15"><highlight class="normal"></highlight><highlight class="comment">//<sp/>(x*y)>>posun</highlight><highlight class="normal"></highlight></codeline> |
|---|
| 165 | <codeline lineno="16"><highlight class="normal"></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>deleni15(</highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>x,<sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>y);</highlight></codeline> |
|---|
| 166 | <codeline lineno="17"><highlight class="normal"></highlight><highlight class="comment">//<sp/>(x*Q15/y)<sp/>se<sp/>saturaci</highlight><highlight class="normal"></highlight></codeline> |
|---|
| 167 | <codeline lineno="18"><highlight class="normal"></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>deleni(</highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>x,<sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>y,<sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>posun1,<sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>posun2,<sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>scale,<sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>posun_fin);</highlight></codeline> |
|---|
| 168 | <codeline lineno="19"><highlight class="normal"></highlight><highlight class="comment">//<sp/>obecne<sp/>deleni:<sp/>x_"Qposun1"*"Qscale"/y_"Qposun2"<sp/>-><sp/>"Q_posun_fin"</highlight><highlight class="normal"></highlight></codeline> |
|---|
| 169 | <codeline lineno="20"><highlight class="normal"></highlight></codeline> |
|---|
| 170 | <codeline lineno="21"><highlight class="normal"><sp/><sp/></highlight></codeline> |
|---|
| 171 | <codeline lineno="22"><highlight class="normal"></highlight><highlight class="keywordtype">long</highlight><highlight class="normal"><sp/>prevod(</highlight><highlight class="keywordtype">double</highlight><highlight class="normal"><sp/>x,<sp/></highlight><highlight class="keywordtype">unsigned</highlight><highlight class="normal"><sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>posun)</highlight></codeline> |
|---|
| 172 | <codeline lineno="23"><highlight class="normal">{</highlight></codeline> |
|---|
| 173 | <codeline lineno="24"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordtype">long</highlight><highlight class="normal"><sp/>y,nasobic;</highlight></codeline> |
|---|
| 174 | <codeline lineno="25"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>znamenko;</highlight></codeline> |
|---|
| 175 | <codeline lineno="26"><highlight class="normal"><sp/><sp/></highlight></codeline> |
|---|
| 176 | <codeline lineno="27"><highlight class="normal"><sp/><sp/>nasobic=(long)1<<posun;</highlight></codeline> |
|---|
| 177 | <codeline lineno="28"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(x>=0)<sp/>znamenko=1;</highlight></codeline> |
|---|
| 178 | <codeline lineno="29"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/>znamenko=-1;</highlight></codeline> |
|---|
| 179 | <codeline lineno="30"><highlight class="normal"><sp/><sp/>y=(long)(x*nasobic+znamenko*0.5);</highlight></codeline> |
|---|
| 180 | <codeline lineno="31"><highlight class="normal"><sp/><sp/></highlight></codeline> |
|---|
| 181 | <codeline lineno="32"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>y;</highlight></codeline> |
|---|
| 182 | <codeline lineno="33"><highlight class="normal">}</highlight></codeline> |
|---|
| 183 | <codeline lineno="34"><highlight class="normal"></highlight></codeline> |
|---|
| 184 | <codeline lineno="35"><highlight class="normal"></highlight><highlight class="keywordtype">double</highlight><highlight class="normal"><sp/>zprevod(</highlight><highlight class="keywordtype">long</highlight><highlight class="normal"><sp/>x,<sp/></highlight><highlight class="keywordtype">unsigned</highlight><highlight class="normal"><sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>posun)</highlight></codeline> |
|---|
| 185 | <codeline lineno="36"><highlight class="normal">{</highlight></codeline> |
|---|
| 186 | <codeline lineno="37"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordtype">long</highlight><highlight class="normal"><sp/>nasobic;</highlight></codeline> |
|---|
| 187 | <codeline lineno="38"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordtype">double</highlight><highlight class="normal"><sp/>y;</highlight></codeline> |
|---|
| 188 | <codeline lineno="39"><highlight class="normal"><sp/><sp/></highlight></codeline> |
|---|
| 189 | <codeline lineno="40"><highlight class="normal"><sp/><sp/>nasobic=(long)1<<posun;</highlight></codeline> |
|---|
| 190 | <codeline lineno="41"><highlight class="normal"><sp/><sp/>y=(double)x/nasobic;</highlight></codeline> |
|---|
| 191 | <codeline lineno="42"><highlight class="normal"><sp/><sp/></highlight></codeline> |
|---|
| 192 | <codeline lineno="43"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>y;</highlight></codeline> |
|---|
| 193 | <codeline lineno="44"><highlight class="normal">}</highlight></codeline> |
|---|
| 194 | <codeline lineno="45"><highlight class="normal"></highlight></codeline> |
|---|
| 195 | <codeline lineno="46"><highlight class="normal"></highlight><highlight class="keywordtype">long</highlight><highlight class="normal"><sp/>nasob(</highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>x,<sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>y,</highlight><highlight class="keywordtype">unsigned</highlight><highlight class="normal"><sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>posun)</highlight></codeline> |
|---|
| 196 | <codeline lineno="47"><highlight class="normal">{</highlight></codeline> |
|---|
| 197 | <codeline lineno="48"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordtype">long</highlight><highlight class="normal"><sp/>z,zaokrouhl;<sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">//<sp/>zaokrouhl<sp/>...<sp/>zaokrouhlovani<sp/>vysledku<sp/>pricteni<sp/>0.5</highlight><highlight class="normal"></highlight></codeline> |
|---|
| 198 | <codeline lineno="49"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>znamenko;</highlight></codeline> |
|---|
| 199 | <codeline lineno="50"><highlight class="normal"><sp/><sp/></highlight></codeline> |
|---|
| 200 | <codeline lineno="51"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(posun>0)</highlight></codeline> |
|---|
| 201 | <codeline lineno="52"><highlight class="normal"><sp/><sp/><sp/><sp/>zaokrouhl=(long)1<<(posun-1);</highlight></codeline> |
|---|
| 202 | <codeline lineno="53"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/>zaokrouhl=0;</highlight></codeline> |
|---|
| 203 | <codeline lineno="54"><highlight class="normal"><sp/><sp/>z=(long)x*y;</highlight></codeline> |
|---|
| 204 | <codeline lineno="55"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(z>=0)<sp/>znamenko=1;</highlight></codeline> |
|---|
| 205 | <codeline lineno="56"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/>znamenko=-1;</highlight></codeline> |
|---|
| 206 | <codeline lineno="57"><highlight class="normal"><sp/><sp/>z=(z+znamenko*zaokrouhl)>>posun;</highlight></codeline> |
|---|
| 207 | <codeline lineno="58"><highlight class="normal"><sp/><sp/></highlight></codeline> |
|---|
| 208 | <codeline lineno="59"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>z;</highlight></codeline> |
|---|
| 209 | <codeline lineno="60"><highlight class="normal">}</highlight></codeline> |
|---|
| 210 | <codeline lineno="61"><highlight class="normal"></highlight></codeline> |
|---|
| 211 | <codeline lineno="62"><highlight class="normal"></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>deleni15(</highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>x,<sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>y)<sp/><sp/><sp/></highlight><highlight class="comment">//<sp/>deleni<sp/>Q15/Q15<sp/>se<sp/>saturaci</highlight><highlight class="normal"></highlight></codeline> |
|---|
| 212 | <codeline lineno="63"><highlight class="normal">{</highlight></codeline> |
|---|
| 213 | <codeline lineno="64"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordtype">long</highlight><highlight class="normal"><sp/>z;</highlight></codeline> |
|---|
| 214 | <codeline lineno="65"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight></codeline> |
|---|
| 215 | <codeline lineno="66"><highlight class="normal"><sp/><sp/>z=(long)x*32768/y;</highlight></codeline> |
|---|
| 216 | <codeline lineno="67"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(z>32767)<sp/>z=32767;</highlight></codeline> |
|---|
| 217 | <codeline lineno="68"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(z<-32768)<sp/>z=-32768;<sp/><sp/></highlight></codeline> |
|---|
| 218 | <codeline lineno="69"><highlight class="normal"><sp/><sp/></highlight></codeline> |
|---|
| 219 | <codeline lineno="70"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>(</highlight><highlight class="keywordtype">int</highlight><highlight class="normal">)z;</highlight></codeline> |
|---|
| 220 | <codeline lineno="71"><highlight class="normal">}</highlight></codeline> |
|---|
| 221 | <codeline lineno="72"><highlight class="normal"></highlight></codeline> |
|---|
| 222 | <codeline lineno="73"><highlight class="normal"></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>deleni(</highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>x,<sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>y,<sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>posun1,<sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>posun2,<sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>scale,<sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>posun_fin)<sp/><sp/></highlight></codeline> |
|---|
| 223 | <codeline lineno="74"><highlight class="normal"></highlight><highlight class="comment">/*</highlight></codeline> |
|---|
| 224 | <codeline lineno="75"><highlight class="comment">x/y<sp/><sp/><sp/><sp/>...<sp/>podil</highlight></codeline> |
|---|
| 225 | <codeline lineno="76"><highlight class="comment">posun1<sp/>...<sp/>posun<sp/>x<sp/>(scale<sp/>faktor)</highlight></codeline> |
|---|
| 226 | <codeline lineno="77"><highlight class="comment">posun2<sp/>...<sp/>posun<sp/>y</highlight></codeline> |
|---|
| 227 | <codeline lineno="78"><highlight class="comment">scale<sp/><sp/>...<sp/>posun<sp/>pri<sp/>deleni<sp/>-<sp/>pomocny</highlight></codeline> |
|---|
| 228 | <codeline lineno="79"><highlight class="comment">posun_fin<sp/>...<sp/>system,<sp/>ve<sp/>kterem<sp/>ma<sp/>byt<sp/>vysledek<sp/>(scale<sp/>faktor<sp/>vysledku)</highlight></codeline> |
|---|
| 229 | <codeline lineno="80"><highlight class="comment">*/</highlight><highlight class="normal"></highlight></codeline> |
|---|
| 230 | <codeline lineno="81"><highlight class="normal">{</highlight></codeline> |
|---|
| 231 | <codeline lineno="82"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>z;</highlight></codeline> |
|---|
| 232 | <codeline lineno="83"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>bit_posun;</highlight></codeline> |
|---|
| 233 | <codeline lineno="84"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordtype">long</highlight><highlight class="normal"><sp/>zz,<sp/>scale_fakt,<sp/>scale_fin;</highlight></codeline> |
|---|
| 234 | <codeline lineno="85"><highlight class="normal"><sp/><sp/></highlight></codeline> |
|---|
| 235 | <codeline lineno="86"><highlight class="normal"><sp/><sp/>scale_fakt=(long)1<<scale;</highlight></codeline> |
|---|
| 236 | <codeline lineno="87"><highlight class="normal"><sp/><sp/>bit_posun=(posun1+scale-posun2)-posun_fin;</highlight></codeline> |
|---|
| 237 | <codeline lineno="88"><highlight class="normal"><sp/><sp/></highlight></codeline> |
|---|
| 238 | <codeline lineno="89"><highlight class="normal"><sp/><sp/>zz=(long)x*scale_fakt/y;</highlight></codeline> |
|---|
| 239 | <codeline lineno="90"><highlight class="normal"></highlight></codeline> |
|---|
| 240 | <codeline lineno="91"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(bit_posun>=0)</highlight></codeline> |
|---|
| 241 | <codeline lineno="92"><highlight class="normal"><sp/><sp/><sp/><sp/>zz=(int)(zz>>bit_posun);</highlight></codeline> |
|---|
| 242 | <codeline lineno="93"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"></highlight></codeline> |
|---|
| 243 | <codeline lineno="94"><highlight class="normal"><sp/><sp/>{<sp/>bit_posun*=-1;</highlight></codeline> |
|---|
| 244 | <codeline lineno="95"><highlight class="normal"><sp/><sp/><sp/><sp/>zz=(int)(zz<<bit_posun);</highlight></codeline> |
|---|
| 245 | <codeline lineno="96"><highlight class="normal"><sp/><sp/>}</highlight></codeline> |
|---|
| 246 | <codeline lineno="97"><highlight class="normal"><sp/><sp/></highlight></codeline> |
|---|
| 247 | <codeline lineno="98"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">//<sp/>Saturace<sp/>vystupu</highlight><highlight class="normal"></highlight></codeline> |
|---|
| 248 | <codeline lineno="99"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(zz>32767)</highlight></codeline> |
|---|
| 249 | <codeline lineno="100"><highlight class="normal"><sp/><sp/><sp/><sp/>z=32767;</highlight></codeline> |
|---|
| 250 | <codeline lineno="101"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(zz<-32768)</highlight></codeline> |
|---|
| 251 | <codeline lineno="102"><highlight class="normal"><sp/><sp/><sp/><sp/>z=-32768;</highlight></codeline> |
|---|
| 252 | <codeline lineno="103"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"></highlight></codeline> |
|---|
| 253 | <codeline lineno="104"><highlight class="normal"><sp/><sp/><sp/><sp/>z=zz;</highlight></codeline> |
|---|
| 254 | <codeline lineno="105"><highlight class="normal"><sp/><sp/></highlight></codeline> |
|---|
| 255 | <codeline lineno="106"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>z;</highlight></codeline> |
|---|
| 256 | <codeline lineno="107"><highlight class="normal">}</highlight></codeline> |
|---|
| 257 | </programlisting> |
|---|
| 258 | <location file="/home/smidl/work/git/mixpp/pmsm/simulator_zdenek/ekf_example/fixed.cpp"/> |
|---|
| 259 | </compounddef> |
|---|
| 260 | </doxygen> |
|---|