group___p_i_d.html 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
  5. <meta http-equiv="X-UA-Compatible" content="IE=9"/>
  6. <title>CMSIS-DSP: PID Motor Control</title>
  7. <link href="tabs.css" rel="stylesheet" type="text/css"/>
  8. <link href="cmsis.css" rel="stylesheet" type="text/css" />
  9. <script type="text/javascript" src="jquery.js"></script>
  10. <script type="text/javascript" src="dynsections.js"></script>
  11. <link href="navtree.css" rel="stylesheet" type="text/css"/>
  12. <script type="text/javascript" src="resize.js"></script>
  13. <script type="text/javascript" src="navtree.js"></script>
  14. <script type="text/javascript">
  15. $(document).ready(initResizable);
  16. </script>
  17. <link href="search/search.css" rel="stylesheet" type="text/css"/>
  18. <script type="text/javascript" src="search/search.js"></script>
  19. <script type="text/javascript">
  20. $(document).ready(function() { searchBox.OnSelectItem(0); });
  21. </script>
  22. <link href="stylsheetf" rel="stylesheet" type="text/css" />
  23. </head>
  24. <body>
  25. <div id="top"><!-- do not remove this div, it is closed by doxygen! -->
  26. <div id="titlearea">
  27. <table cellspacing="0" cellpadding="0">
  28. <tbody>
  29. <tr style="height: 46px;">
  30. <td id="projectlogo"><img alt="Logo" src="CMSIS_Logo_Final.png"/></td>
  31. <td style="padding-left: 0.5em;">
  32. <div id="projectname">CMSIS-DSP
  33. &#160;<span id="projectnumber">Version 1.4.4</span>
  34. </div>
  35. <div id="projectbrief">CMSIS DSP Software Library</div>
  36. </td>
  37. </tr>
  38. </tbody>
  39. </table>
  40. </div>
  41. <!-- end header part -->
  42. <div id="CMSISnav" class="tabs1">
  43. <ul class="tablist">
  44. <li><a href="../../General/html/index.html"><span>CMSIS</span></a></li>
  45. <li><a href="../../Core/html/index.html"><span>CORE</span></a></li>
  46. <li><a href="../../Driver/html/index.html"><span>Driver</span></a></li>
  47. <li class="current"><a href="../../DSP/html/index.html"><span>DSP</span></a></li>
  48. <li><a href="../../RTOS/html/index.html"><span>RTOS API</span></a></li>
  49. <li><a href="../../Pack/html/index.html"><span>Pack</span></a></li>
  50. <li><a href="../../SVD/html/index.html"><span>SVD</span></a></li>
  51. </ul>
  52. </div>
  53. <!-- Generated by Doxygen 1.8.2 -->
  54. <script type="text/javascript">
  55. var searchBox = new SearchBox("searchBox", "search",false,'Search');
  56. </script>
  57. <div id="navrow1" class="tabs">
  58. <ul class="tablist">
  59. <li><a href="index.html"><span>Main&#160;Page</span></a></li>
  60. <li><a href="pages.html"><span>Usage&#160;and&#160;Description</span></a></li>
  61. <li><a href="modules.html"><span>Reference</span></a></li>
  62. <li>
  63. <div id="MSearchBox" class="MSearchBoxInactive">
  64. <span class="left">
  65. <img id="MSearchSelect" src="search/mag_sel.png"
  66. onmouseover="return searchBox.OnSearchSelectShow()"
  67. onmouseout="return searchBox.OnSearchSelectHide()"
  68. alt=""/>
  69. <input type="text" id="MSearchField" value="Search" accesskey="S"
  70. onfocus="searchBox.OnSearchFieldFocus(true)"
  71. onblur="searchBox.OnSearchFieldFocus(false)"
  72. onkeyup="searchBox.OnSearchFieldChange(event)"/>
  73. </span><span class="right">
  74. <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
  75. </span>
  76. </div>
  77. </li>
  78. </ul>
  79. </div>
  80. </div><!-- top -->
  81. <div id="side-nav" class="ui-resizable side-nav-resizable">
  82. <div id="nav-tree">
  83. <div id="nav-tree-contents">
  84. <div id="nav-sync" class="sync"></div>
  85. </div>
  86. </div>
  87. <div id="splitbar" style="-moz-user-select:none;"
  88. class="ui-resizable-handle">
  89. </div>
  90. </div>
  91. <script type="text/javascript">
  92. $(document).ready(function(){initNavTree('group___p_i_d.html','');});
  93. </script>
  94. <div id="doc-content">
  95. <!-- window showing the filter options -->
  96. <div id="MSearchSelectWindow"
  97. onmouseover="return searchBox.OnSearchSelectShow()"
  98. onmouseout="return searchBox.OnSearchSelectHide()"
  99. onkeydown="return searchBox.OnSearchSelectKey(event)">
  100. <a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Data Structures</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&#160;</span>Typedefs</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark">&#160;</span>Enumerations</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(7)"><span class="SelectionMark">&#160;</span>Enumerator</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(8)"><span class="SelectionMark">&#160;</span>Macros</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(9)"><span class="SelectionMark">&#160;</span>Groups</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(10)"><span class="SelectionMark">&#160;</span>Pages</a></div>
  101. <!-- iframe showing the search results (closed by default) -->
  102. <div id="MSearchResultsWindow">
  103. <iframe src="javascript:void(0)" frameborder="0"
  104. name="MSearchResults" id="MSearchResults">
  105. </iframe>
  106. </div>
  107. <div class="header">
  108. <div class="summary">
  109. <a href="#func-members">Functions</a> </div>
  110. <div class="headertitle">
  111. <div class="title">PID Motor Control</div> </div>
  112. <div class="ingroups"><a class="el" href="group__group_controller.html">Controller Functions</a></div></div><!--header-->
  113. <div class="contents">
  114. <table class="memberdecls">
  115. <tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="func-members"></a>
  116. Functions</h2></td></tr>
  117. <tr class="memitem:gae31536b19b82b93ed184fb1ab73cfcb3"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group___p_i_d.html#gae31536b19b82b93ed184fb1ab73cfcb3">arm_pid_init_f32</a> (<a class="el" href="structarm__pid__instance__f32.html">arm_pid_instance_f32</a> *S, int32_t resetStateFlag)</td></tr>
  118. <tr class="memdesc:gae31536b19b82b93ed184fb1ab73cfcb3"><td class="mdescLeft">&#160;</td><td class="mdescRight">Initialization function for the floating-point PID Control. <a href="#gae31536b19b82b93ed184fb1ab73cfcb3"></a><br/></td></tr>
  119. <tr class="separator:gae31536b19b82b93ed184fb1ab73cfcb3"><td class="memSeparator" colspan="2">&#160;</td></tr>
  120. <tr class="memitem:ga2cb1e3d3ebb167348fdabec74653d5c3"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group___p_i_d.html#ga2cb1e3d3ebb167348fdabec74653d5c3">arm_pid_init_q15</a> (<a class="el" href="structarm__pid__instance__q15.html">arm_pid_instance_q15</a> *S, int32_t resetStateFlag)</td></tr>
  121. <tr class="memdesc:ga2cb1e3d3ebb167348fdabec74653d5c3"><td class="mdescLeft">&#160;</td><td class="mdescRight">Initialization function for the Q15 PID Control. <a href="#ga2cb1e3d3ebb167348fdabec74653d5c3"></a><br/></td></tr>
  122. <tr class="separator:ga2cb1e3d3ebb167348fdabec74653d5c3"><td class="memSeparator" colspan="2">&#160;</td></tr>
  123. <tr class="memitem:gad9d88485234fa9460b1ce9e64989ac86"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group___p_i_d.html#gad9d88485234fa9460b1ce9e64989ac86">arm_pid_init_q31</a> (<a class="el" href="structarm__pid__instance__q31.html">arm_pid_instance_q31</a> *S, int32_t resetStateFlag)</td></tr>
  124. <tr class="memdesc:gad9d88485234fa9460b1ce9e64989ac86"><td class="mdescLeft">&#160;</td><td class="mdescRight">Initialization function for the Q31 PID Control. <a href="#gad9d88485234fa9460b1ce9e64989ac86"></a><br/></td></tr>
  125. <tr class="separator:gad9d88485234fa9460b1ce9e64989ac86"><td class="memSeparator" colspan="2">&#160;</td></tr>
  126. <tr class="memitem:ga9ec860bcb6f8ca31205bf0f1b51ab723"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group___p_i_d.html#ga9ec860bcb6f8ca31205bf0f1b51ab723">arm_pid_reset_f32</a> (<a class="el" href="structarm__pid__instance__f32.html">arm_pid_instance_f32</a> *S)</td></tr>
  127. <tr class="memdesc:ga9ec860bcb6f8ca31205bf0f1b51ab723"><td class="mdescLeft">&#160;</td><td class="mdescRight">Reset function for the floating-point PID Control. <a href="#ga9ec860bcb6f8ca31205bf0f1b51ab723"></a><br/></td></tr>
  128. <tr class="separator:ga9ec860bcb6f8ca31205bf0f1b51ab723"><td class="memSeparator" colspan="2">&#160;</td></tr>
  129. <tr class="memitem:ga408566dacb4fa6e0458b2c75672e525f"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group___p_i_d.html#ga408566dacb4fa6e0458b2c75672e525f">arm_pid_reset_q15</a> (<a class="el" href="structarm__pid__instance__q15.html">arm_pid_instance_q15</a> *S)</td></tr>
  130. <tr class="memdesc:ga408566dacb4fa6e0458b2c75672e525f"><td class="mdescLeft">&#160;</td><td class="mdescRight">Reset function for the Q15 PID Control. <a href="#ga408566dacb4fa6e0458b2c75672e525f"></a><br/></td></tr>
  131. <tr class="separator:ga408566dacb4fa6e0458b2c75672e525f"><td class="memSeparator" colspan="2">&#160;</td></tr>
  132. <tr class="memitem:gaeecbacd3fb37c608ec25474d3a0dffa9"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group___p_i_d.html#gaeecbacd3fb37c608ec25474d3a0dffa9">arm_pid_reset_q31</a> (<a class="el" href="structarm__pid__instance__q31.html">arm_pid_instance_q31</a> *S)</td></tr>
  133. <tr class="memdesc:gaeecbacd3fb37c608ec25474d3a0dffa9"><td class="mdescLeft">&#160;</td><td class="mdescRight">Reset function for the Q31 PID Control. <a href="#gaeecbacd3fb37c608ec25474d3a0dffa9"></a><br/></td></tr>
  134. <tr class="separator:gaeecbacd3fb37c608ec25474d3a0dffa9"><td class="memSeparator" colspan="2">&#160;</td></tr>
  135. <tr class="memitem:gac5c79ed46abf2d72b8cf41fa6c708bda"><td class="memItemLeft" align="right" valign="top">static __INLINE <a class="el" href="arm__math_8h.html#a4611b605e45ab401f02cab15c5e38715">float32_t</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group___p_i_d.html#gac5c79ed46abf2d72b8cf41fa6c708bda">arm_pid_f32</a> (<a class="el" href="structarm__pid__instance__f32.html">arm_pid_instance_f32</a> *S, <a class="el" href="arm__math_8h.html#a4611b605e45ab401f02cab15c5e38715">float32_t</a> in)</td></tr>
  136. <tr class="memdesc:gac5c79ed46abf2d72b8cf41fa6c708bda"><td class="mdescLeft">&#160;</td><td class="mdescRight">Process function for the floating-point PID Control. <a href="#gac5c79ed46abf2d72b8cf41fa6c708bda"></a><br/></td></tr>
  137. <tr class="separator:gac5c79ed46abf2d72b8cf41fa6c708bda"><td class="memSeparator" colspan="2">&#160;</td></tr>
  138. <tr class="memitem:ga5f6f941e7ae981728dd3a662f8f4ecd7"><td class="memItemLeft" align="right" valign="top">static __INLINE <a class="el" href="arm__math_8h.html#adc89a3547f5324b7b3b95adec3806bc0">q31_t</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group___p_i_d.html#ga5f6f941e7ae981728dd3a662f8f4ecd7">arm_pid_q31</a> (<a class="el" href="structarm__pid__instance__q31.html">arm_pid_instance_q31</a> *S, <a class="el" href="arm__math_8h.html#adc89a3547f5324b7b3b95adec3806bc0">q31_t</a> in)</td></tr>
  139. <tr class="memdesc:ga5f6f941e7ae981728dd3a662f8f4ecd7"><td class="mdescLeft">&#160;</td><td class="mdescRight">Process function for the Q31 PID Control. <a href="#ga5f6f941e7ae981728dd3a662f8f4ecd7"></a><br/></td></tr>
  140. <tr class="separator:ga5f6f941e7ae981728dd3a662f8f4ecd7"><td class="memSeparator" colspan="2">&#160;</td></tr>
  141. <tr class="memitem:ga084f646bbb20d55f225c3efafcf7fc1f"><td class="memItemLeft" align="right" valign="top">static __INLINE <a class="el" href="arm__math_8h.html#ab5a8fb21a5b3b983d5f54f31614052ea">q15_t</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group___p_i_d.html#ga084f646bbb20d55f225c3efafcf7fc1f">arm_pid_q15</a> (<a class="el" href="structarm__pid__instance__q15.html">arm_pid_instance_q15</a> *S, <a class="el" href="arm__math_8h.html#ab5a8fb21a5b3b983d5f54f31614052ea">q15_t</a> in)</td></tr>
  142. <tr class="memdesc:ga084f646bbb20d55f225c3efafcf7fc1f"><td class="mdescLeft">&#160;</td><td class="mdescRight">Process function for the Q15 PID Control. <a href="#ga084f646bbb20d55f225c3efafcf7fc1f"></a><br/></td></tr>
  143. <tr class="separator:ga084f646bbb20d55f225c3efafcf7fc1f"><td class="memSeparator" colspan="2">&#160;</td></tr>
  144. </table>
  145. <a name="details" id="details"></a><h2 class="groupheader">Description</h2>
  146. <p>A Proportional Integral Derivative (PID) controller is a generic feedback control loop mechanism widely used in industrial control systems. A PID controller is the most commonly used type of feedback controller.</p>
  147. <p>This set of functions implements (PID) controllers for Q15, Q31, and floating-point data types. The functions operate on a single sample of data and each call to the function returns a single processed value. <code>S</code> points to an instance of the PID control data structure. <code>in</code> is the input sample value. The functions return the output value.</p>
  148. <dl class="section user"><dt>Algorithm:</dt><dd><pre>
  149. y[n] = y[n-1] + A0 * x[n] + A1 * x[n-1] + A2 * x[n-2]
  150. A0 = Kp + Ki + Kd
  151. A1 = (-Kp ) - (2 * Kd )
  152. A2 = Kd </pre></dd></dl>
  153. <dl class="section user"><dt></dt><dd>where <code>Kp</code> is proportional constant, <code>Ki</code> is Integral constant and <code>Kd</code> is Derivative constant</dd></dl>
  154. <dl class="section user"><dt></dt><dd><div class="image">
  155. <img src="PID.gif" alt="PID.gif"/>
  156. <div class="caption">
  157. Proportional Integral Derivative Controller</div></div>
  158. </dd></dl>
  159. <dl class="section user"><dt></dt><dd>The PID controller calculates an "error" value as the difference between the measured output and the reference input. The controller attempts to minimize the error by adjusting the process control inputs. The proportional value determines the reaction to the current error, the integral value determines the reaction based on the sum of recent errors, and the derivative value determines the reaction based on the rate at which the error has been changing.</dd></dl>
  160. <dl class="section user"><dt>Instance Structure</dt><dd>The Gains A0, A1, A2 and state variables for a PID controller are stored together in an instance data structure. A separate instance structure must be defined for each PID Controller. There are separate instance structure declarations for each of the 3 supported data types.</dd></dl>
  161. <dl class="section user"><dt>Reset Functions</dt><dd>There is also an associated reset function for each data type which clears the state array.</dd></dl>
  162. <dl class="section user"><dt>Initialization Functions</dt><dd>There is also an associated initialization function for each data type. The initialization function performs the following operations:<ul>
  163. <li>Initializes the Gains A0, A1, A2 from Kp,Ki, Kd gains.</li>
  164. <li>Zeros out the values in the state buffer.</li>
  165. </ul>
  166. </dd></dl>
  167. <dl class="section user"><dt></dt><dd>Instance structure cannot be placed into a const data section and it is recommended to use the initialization function.</dd></dl>
  168. <dl class="section user"><dt>Fixed-Point Behavior</dt><dd>Care must be taken when using the fixed-point versions of the PID Controller functions. In particular, the overflow and saturation behavior of the accumulator used in each function must be considered. Refer to the function specific documentation below for usage guidelines. </dd></dl>
  169. <h2 class="groupheader">Function Documentation</h2>
  170. <a class="anchor" id="gac5c79ed46abf2d72b8cf41fa6c708bda"></a>
  171. <div class="memitem">
  172. <div class="memproto">
  173. <table class="mlabels">
  174. <tr>
  175. <td class="mlabels-left">
  176. <table class="memname">
  177. <tr>
  178. <td class="memname">static __INLINE <a class="el" href="arm__math_8h.html#a4611b605e45ab401f02cab15c5e38715">float32_t</a> arm_pid_f32 </td>
  179. <td>(</td>
  180. <td class="paramtype"><a class="el" href="structarm__pid__instance__f32.html">arm_pid_instance_f32</a> *&#160;</td>
  181. <td class="paramname"><em>S</em>, </td>
  182. </tr>
  183. <tr>
  184. <td class="paramkey"></td>
  185. <td></td>
  186. <td class="paramtype"><a class="el" href="arm__math_8h.html#a4611b605e45ab401f02cab15c5e38715">float32_t</a>&#160;</td>
  187. <td class="paramname"><em>in</em>&#160;</td>
  188. </tr>
  189. <tr>
  190. <td></td>
  191. <td>)</td>
  192. <td></td><td></td>
  193. </tr>
  194. </table>
  195. </td>
  196. <td class="mlabels-right">
  197. <span class="mlabels"><span class="mlabel">static</span></span> </td>
  198. </tr>
  199. </table>
  200. </div><div class="memdoc">
  201. <dl class="params"><dt>Parameters</dt><dd>
  202. <table class="params">
  203. <tr><td class="paramdir">[in,out]</td><td class="paramname">*S</td><td>is an instance of the floating-point PID Control structure </td></tr>
  204. <tr><td class="paramdir">[in]</td><td class="paramname">in</td><td>input sample to process </td></tr>
  205. </table>
  206. </dd>
  207. </dl>
  208. <dl class="section return"><dt>Returns</dt><dd>out processed output sample. </dd></dl>
  209. <p>References <a class="el" href="structarm__pid__instance__f32.html#ad7b0bed64915d0a25a3409fa2dc45556">arm_pid_instance_f32::A0</a>, <a class="el" href="structarm__pid__instance__f32.html#a7def89571c50f7137a213326a396e560">arm_pid_instance_f32::A1</a>, <a class="el" href="structarm__pid__instance__f32.html#a155acf642ba2f521869f19d694cd7fa0">arm_pid_instance_f32::A2</a>, and <a class="el" href="structarm__pid__instance__f32.html#afd394e1e52fb1d526aa472c83b8f2464">arm_pid_instance_f32::state</a>.</p>
  210. </div>
  211. </div>
  212. <a class="anchor" id="gae31536b19b82b93ed184fb1ab73cfcb3"></a>
  213. <div class="memitem">
  214. <div class="memproto">
  215. <table class="memname">
  216. <tr>
  217. <td class="memname">void arm_pid_init_f32 </td>
  218. <td>(</td>
  219. <td class="paramtype"><a class="el" href="structarm__pid__instance__f32.html">arm_pid_instance_f32</a> *&#160;</td>
  220. <td class="paramname"><em>S</em>, </td>
  221. </tr>
  222. <tr>
  223. <td class="paramkey"></td>
  224. <td></td>
  225. <td class="paramtype">int32_t&#160;</td>
  226. <td class="paramname"><em>resetStateFlag</em>&#160;</td>
  227. </tr>
  228. <tr>
  229. <td></td>
  230. <td>)</td>
  231. <td></td><td></td>
  232. </tr>
  233. </table>
  234. </div><div class="memdoc">
  235. <dl class="params"><dt>Parameters</dt><dd>
  236. <table class="params">
  237. <tr><td class="paramdir">[in,out]</td><td class="paramname">*S</td><td>points to an instance of the PID structure. </td></tr>
  238. <tr><td class="paramdir">[in]</td><td class="paramname">resetStateFlag</td><td>flag to reset the state. 0 = no change in state &amp; 1 = reset the state. </td></tr>
  239. </table>
  240. </dd>
  241. </dl>
  242. <dl class="section return"><dt>Returns</dt><dd>none. </dd></dl>
  243. <dl class="section user"><dt>Description: </dt><dd></dd></dl>
  244. <dl class="section user"><dt></dt><dd>The <code>resetStateFlag</code> specifies whether to set state to zero or not. <br/>
  245. The function computes the structure fields: <code>A0</code>, <code>A1</code> <code>A2</code> using the proportional gain( <code>Kp</code>), integral gain( <code>Ki</code>) and derivative gain( <code>Kd</code>) also sets the state variables to all zeros. </dd></dl>
  246. <p>References <a class="el" href="structarm__pid__instance__f32.html#ad7b0bed64915d0a25a3409fa2dc45556">arm_pid_instance_f32::A0</a>, <a class="el" href="structarm__pid__instance__f32.html#a7def89571c50f7137a213326a396e560">arm_pid_instance_f32::A1</a>, <a class="el" href="structarm__pid__instance__f32.html#a155acf642ba2f521869f19d694cd7fa0">arm_pid_instance_f32::A2</a>, <a class="el" href="structarm__pid__instance__f32.html#ad5b68fbf84d16188ae4747ff91f6f088">arm_pid_instance_f32::Kd</a>, <a class="el" href="structarm__pid__instance__f32.html#ac0feffde05fe391eeab3bf78e953830a">arm_pid_instance_f32::Ki</a>, <a class="el" href="structarm__pid__instance__f32.html#aa9b9aa9e413c6cec376a9dddc9f01ebe">arm_pid_instance_f32::Kp</a>, and <a class="el" href="structarm__pid__instance__f32.html#afd394e1e52fb1d526aa472c83b8f2464">arm_pid_instance_f32::state</a>.</p>
  247. </div>
  248. </div>
  249. <a class="anchor" id="ga2cb1e3d3ebb167348fdabec74653d5c3"></a>
  250. <div class="memitem">
  251. <div class="memproto">
  252. <table class="memname">
  253. <tr>
  254. <td class="memname">void arm_pid_init_q15 </td>
  255. <td>(</td>
  256. <td class="paramtype"><a class="el" href="structarm__pid__instance__q15.html">arm_pid_instance_q15</a> *&#160;</td>
  257. <td class="paramname"><em>S</em>, </td>
  258. </tr>
  259. <tr>
  260. <td class="paramkey"></td>
  261. <td></td>
  262. <td class="paramtype">int32_t&#160;</td>
  263. <td class="paramname"><em>resetStateFlag</em>&#160;</td>
  264. </tr>
  265. <tr>
  266. <td></td>
  267. <td>)</td>
  268. <td></td><td></td>
  269. </tr>
  270. </table>
  271. </div><div class="memdoc">
  272. <dl class="params"><dt>Parameters</dt><dd>
  273. <table class="params">
  274. <tr><td class="paramdir">[in,out]</td><td class="paramname">*S</td><td>points to an instance of the Q15 PID structure. </td></tr>
  275. <tr><td class="paramdir">[in]</td><td class="paramname">resetStateFlag</td><td>flag to reset the state. 0 = no change in state 1 = reset the state. </td></tr>
  276. </table>
  277. </dd>
  278. </dl>
  279. <dl class="section return"><dt>Returns</dt><dd>none. </dd></dl>
  280. <dl class="section user"><dt>Description: </dt><dd></dd></dl>
  281. <dl class="section user"><dt></dt><dd>The <code>resetStateFlag</code> specifies whether to set state to zero or not. <br/>
  282. The function computes the structure fields: <code>A0</code>, <code>A1</code> <code>A2</code> using the proportional gain( <code>Kp</code>), integral gain( <code>Ki</code>) and derivative gain( <code>Kd</code>) also sets the state variables to all zeros. </dd></dl>
  283. <p>References <a class="el" href="structarm__pid__instance__q15.html#ad77f3a2823c7f96de42c92a3fbf3246b">arm_pid_instance_q15::A0</a>, <a class="el" href="structarm__pid__instance__q15.html#a1b8412c517071962a9acfdc6778906ec">arm_pid_instance_q15::A1</a>, <a class="el" href="structarm__pid__instance__q15.html#af5d4b53091f19eff7536636b7cc43111">arm_pid_instance_q15::Kd</a>, <a class="el" href="structarm__pid__instance__q15.html#a0dcc19d5c8f7bc401acea9e8318cd777">arm_pid_instance_q15::Ki</a>, <a class="el" href="structarm__pid__instance__q15.html#ad228aae24a1b6d855c93a8b9bbc1c4f1">arm_pid_instance_q15::Kp</a>, and <a class="el" href="structarm__pid__instance__q15.html#a4a3f0a878b5b6b055e3478a2f244cd30">arm_pid_instance_q15::state</a>.</p>
  284. </div>
  285. </div>
  286. <a class="anchor" id="gad9d88485234fa9460b1ce9e64989ac86"></a>
  287. <div class="memitem">
  288. <div class="memproto">
  289. <table class="memname">
  290. <tr>
  291. <td class="memname">void arm_pid_init_q31 </td>
  292. <td>(</td>
  293. <td class="paramtype"><a class="el" href="structarm__pid__instance__q31.html">arm_pid_instance_q31</a> *&#160;</td>
  294. <td class="paramname"><em>S</em>, </td>
  295. </tr>
  296. <tr>
  297. <td class="paramkey"></td>
  298. <td></td>
  299. <td class="paramtype">int32_t&#160;</td>
  300. <td class="paramname"><em>resetStateFlag</em>&#160;</td>
  301. </tr>
  302. <tr>
  303. <td></td>
  304. <td>)</td>
  305. <td></td><td></td>
  306. </tr>
  307. </table>
  308. </div><div class="memdoc">
  309. <dl class="params"><dt>Parameters</dt><dd>
  310. <table class="params">
  311. <tr><td class="paramdir">[in,out]</td><td class="paramname">*S</td><td>points to an instance of the Q31 PID structure. </td></tr>
  312. <tr><td class="paramdir">[in]</td><td class="paramname">resetStateFlag</td><td>flag to reset the state. 0 = no change in state 1 = reset the state. </td></tr>
  313. </table>
  314. </dd>
  315. </dl>
  316. <dl class="section return"><dt>Returns</dt><dd>none. </dd></dl>
  317. <dl class="section user"><dt>Description: </dt><dd></dd></dl>
  318. <dl class="section user"><dt></dt><dd>The <code>resetStateFlag</code> specifies whether to set state to zero or not. <br/>
  319. The function computes the structure fields: <code>A0</code>, <code>A1</code> <code>A2</code> using the proportional gain( <code>Kp</code>), integral gain( <code>Ki</code>) and derivative gain( <code>Kd</code>) also sets the state variables to all zeros. </dd></dl>
  320. <p>References <a class="el" href="structarm__pid__instance__q31.html#aa5332635ce9c7078cdb4c1ecf442eadd">arm_pid_instance_q31::A0</a>, <a class="el" href="structarm__pid__instance__q31.html#a2f7492bd6fb92fae5e2de7fbbec39b0e">arm_pid_instance_q31::A1</a>, <a class="el" href="structarm__pid__instance__q31.html#a3e34537c53af4f9ad7bfffa4dff27c82">arm_pid_instance_q31::A2</a>, <a class="el" href="arm__math_8h.html#ad7373e53d3c2e1adfeafc8c2e9720b5c">clip_q63_to_q31()</a>, <a class="el" href="structarm__pid__instance__q31.html#aab4ff371d14441df501f1169f71cbd17">arm_pid_instance_q31::Kd</a>, <a class="el" href="structarm__pid__instance__q31.html#aa861d69fd398f29aa0b4b455a823ed72">arm_pid_instance_q31::Ki</a>, <a class="el" href="structarm__pid__instance__q31.html#ac2410bf7f856d58dc1d773d4983cac8e">arm_pid_instance_q31::Kp</a>, and <a class="el" href="structarm__pid__instance__q31.html#a228e4a64da6014844a0a671a1fa391d4">arm_pid_instance_q31::state</a>.</p>
  321. </div>
  322. </div>
  323. <a class="anchor" id="ga084f646bbb20d55f225c3efafcf7fc1f"></a>
  324. <div class="memitem">
  325. <div class="memproto">
  326. <table class="mlabels">
  327. <tr>
  328. <td class="mlabels-left">
  329. <table class="memname">
  330. <tr>
  331. <td class="memname">static __INLINE <a class="el" href="arm__math_8h.html#ab5a8fb21a5b3b983d5f54f31614052ea">q15_t</a> arm_pid_q15 </td>
  332. <td>(</td>
  333. <td class="paramtype"><a class="el" href="structarm__pid__instance__q15.html">arm_pid_instance_q15</a> *&#160;</td>
  334. <td class="paramname"><em>S</em>, </td>
  335. </tr>
  336. <tr>
  337. <td class="paramkey"></td>
  338. <td></td>
  339. <td class="paramtype"><a class="el" href="arm__math_8h.html#ab5a8fb21a5b3b983d5f54f31614052ea">q15_t</a>&#160;</td>
  340. <td class="paramname"><em>in</em>&#160;</td>
  341. </tr>
  342. <tr>
  343. <td></td>
  344. <td>)</td>
  345. <td></td><td></td>
  346. </tr>
  347. </table>
  348. </td>
  349. <td class="mlabels-right">
  350. <span class="mlabels"><span class="mlabel">static</span></span> </td>
  351. </tr>
  352. </table>
  353. </div><div class="memdoc">
  354. <dl class="params"><dt>Parameters</dt><dd>
  355. <table class="params">
  356. <tr><td class="paramdir">[in,out]</td><td class="paramname">*S</td><td>points to an instance of the Q15 PID Control structure </td></tr>
  357. <tr><td class="paramdir">[in]</td><td class="paramname">in</td><td>input sample to process </td></tr>
  358. </table>
  359. </dd>
  360. </dl>
  361. <dl class="section return"><dt>Returns</dt><dd>out processed output sample.</dd></dl>
  362. <p><b>Scaling and Overflow Behavior:</b> </p>
  363. <dl class="section user"><dt></dt><dd>The function is implemented using a 64-bit internal accumulator. Both Gains and state variables are represented in 1.15 format and multiplications yield a 2.30 result. The 2.30 intermediate results are accumulated in a 64-bit accumulator in 34.30 format. There is no risk of internal overflow with this approach and the full precision of intermediate multiplications is preserved. After all additions have been performed, the accumulator is truncated to 34.15 format by discarding low 15 bits. Lastly, the accumulator is saturated to yield a result in 1.15 format. </dd></dl>
  364. <p>References <a class="el" href="arm__math_8h.html#a1185d670d798aaf52eec13f0403f3407">__SIMD32_CONST</a>, <a class="el" href="structarm__pid__instance__q15.html#ad77f3a2823c7f96de42c92a3fbf3246b">arm_pid_instance_q15::A0</a>, <a class="el" href="structarm__pid__instance__q15.html#a1b8412c517071962a9acfdc6778906ec">arm_pid_instance_q15::A1</a>, and <a class="el" href="structarm__pid__instance__q15.html#a4a3f0a878b5b6b055e3478a2f244cd30">arm_pid_instance_q15::state</a>.</p>
  365. </div>
  366. </div>
  367. <a class="anchor" id="ga5f6f941e7ae981728dd3a662f8f4ecd7"></a>
  368. <div class="memitem">
  369. <div class="memproto">
  370. <table class="mlabels">
  371. <tr>
  372. <td class="mlabels-left">
  373. <table class="memname">
  374. <tr>
  375. <td class="memname">static __INLINE <a class="el" href="arm__math_8h.html#adc89a3547f5324b7b3b95adec3806bc0">q31_t</a> arm_pid_q31 </td>
  376. <td>(</td>
  377. <td class="paramtype"><a class="el" href="structarm__pid__instance__q31.html">arm_pid_instance_q31</a> *&#160;</td>
  378. <td class="paramname"><em>S</em>, </td>
  379. </tr>
  380. <tr>
  381. <td class="paramkey"></td>
  382. <td></td>
  383. <td class="paramtype"><a class="el" href="arm__math_8h.html#adc89a3547f5324b7b3b95adec3806bc0">q31_t</a>&#160;</td>
  384. <td class="paramname"><em>in</em>&#160;</td>
  385. </tr>
  386. <tr>
  387. <td></td>
  388. <td>)</td>
  389. <td></td><td></td>
  390. </tr>
  391. </table>
  392. </td>
  393. <td class="mlabels-right">
  394. <span class="mlabels"><span class="mlabel">static</span></span> </td>
  395. </tr>
  396. </table>
  397. </div><div class="memdoc">
  398. <dl class="params"><dt>Parameters</dt><dd>
  399. <table class="params">
  400. <tr><td class="paramdir">[in,out]</td><td class="paramname">*S</td><td>points to an instance of the Q31 PID Control structure </td></tr>
  401. <tr><td class="paramdir">[in]</td><td class="paramname">in</td><td>input sample to process </td></tr>
  402. </table>
  403. </dd>
  404. </dl>
  405. <dl class="section return"><dt>Returns</dt><dd>out processed output sample.</dd></dl>
  406. <p><b>Scaling and Overflow Behavior:</b> </p>
  407. <dl class="section user"><dt></dt><dd>The function is implemented using an internal 64-bit accumulator. The accumulator has a 2.62 format and maintains full precision of the intermediate multiplication results but provides only a single guard bit. Thus, if the accumulator result overflows it wraps around rather than clip. In order to avoid overflows completely the input signal must be scaled down by 2 bits as there are four additions. After all multiply-accumulates are performed, the 2.62 accumulator is truncated to 1.32 format and then saturated to 1.31 format. </dd></dl>
  408. <p>References <a class="el" href="structarm__pid__instance__q31.html#aa5332635ce9c7078cdb4c1ecf442eadd">arm_pid_instance_q31::A0</a>, <a class="el" href="structarm__pid__instance__q31.html#a2f7492bd6fb92fae5e2de7fbbec39b0e">arm_pid_instance_q31::A1</a>, <a class="el" href="structarm__pid__instance__q31.html#a3e34537c53af4f9ad7bfffa4dff27c82">arm_pid_instance_q31::A2</a>, and <a class="el" href="structarm__pid__instance__q31.html#a228e4a64da6014844a0a671a1fa391d4">arm_pid_instance_q31::state</a>.</p>
  409. </div>
  410. </div>
  411. <a class="anchor" id="ga9ec860bcb6f8ca31205bf0f1b51ab723"></a>
  412. <div class="memitem">
  413. <div class="memproto">
  414. <table class="memname">
  415. <tr>
  416. <td class="memname">void arm_pid_reset_f32 </td>
  417. <td>(</td>
  418. <td class="paramtype"><a class="el" href="structarm__pid__instance__f32.html">arm_pid_instance_f32</a> *&#160;</td>
  419. <td class="paramname"><em>S</em></td><td>)</td>
  420. <td></td>
  421. </tr>
  422. </table>
  423. </div><div class="memdoc">
  424. <dl class="params"><dt>Parameters</dt><dd>
  425. <table class="params">
  426. <tr><td class="paramdir">[in]</td><td class="paramname">*S</td><td>Instance pointer of PID control data structure. </td></tr>
  427. </table>
  428. </dd>
  429. </dl>
  430. <dl class="section return"><dt>Returns</dt><dd>none. </dd></dl>
  431. <dl class="section user"><dt>Description: </dt><dd>The function resets the state buffer to zeros. </dd></dl>
  432. <p>References <a class="el" href="structarm__pid__instance__f32.html#afd394e1e52fb1d526aa472c83b8f2464">arm_pid_instance_f32::state</a>.</p>
  433. </div>
  434. </div>
  435. <a class="anchor" id="ga408566dacb4fa6e0458b2c75672e525f"></a>
  436. <div class="memitem">
  437. <div class="memproto">
  438. <table class="memname">
  439. <tr>
  440. <td class="memname">void arm_pid_reset_q15 </td>
  441. <td>(</td>
  442. <td class="paramtype"><a class="el" href="structarm__pid__instance__q15.html">arm_pid_instance_q15</a> *&#160;</td>
  443. <td class="paramname"><em>S</em></td><td>)</td>
  444. <td></td>
  445. </tr>
  446. </table>
  447. </div><div class="memdoc">
  448. <dl class="params"><dt>Parameters</dt><dd>
  449. <table class="params">
  450. <tr><td class="paramdir">[in]</td><td class="paramname">*S</td><td>Instance pointer of PID control data structure. </td></tr>
  451. </table>
  452. </dd>
  453. </dl>
  454. <dl class="section return"><dt>Returns</dt><dd>none. </dd></dl>
  455. <dl class="section user"><dt>Description: </dt><dd>The function resets the state buffer to zeros. </dd></dl>
  456. <p>References <a class="el" href="structarm__pid__instance__q15.html#a4a3f0a878b5b6b055e3478a2f244cd30">arm_pid_instance_q15::state</a>.</p>
  457. </div>
  458. </div>
  459. <a class="anchor" id="gaeecbacd3fb37c608ec25474d3a0dffa9"></a>
  460. <div class="memitem">
  461. <div class="memproto">
  462. <table class="memname">
  463. <tr>
  464. <td class="memname">void arm_pid_reset_q31 </td>
  465. <td>(</td>
  466. <td class="paramtype"><a class="el" href="structarm__pid__instance__q31.html">arm_pid_instance_q31</a> *&#160;</td>
  467. <td class="paramname"><em>S</em></td><td>)</td>
  468. <td></td>
  469. </tr>
  470. </table>
  471. </div><div class="memdoc">
  472. <dl class="params"><dt>Parameters</dt><dd>
  473. <table class="params">
  474. <tr><td class="paramdir">[in]</td><td class="paramname">*S</td><td>Instance pointer of PID control data structure. </td></tr>
  475. </table>
  476. </dd>
  477. </dl>
  478. <dl class="section return"><dt>Returns</dt><dd>none. </dd></dl>
  479. <dl class="section user"><dt>Description: </dt><dd>The function resets the state buffer to zeros. </dd></dl>
  480. <p>References <a class="el" href="structarm__pid__instance__q31.html#a228e4a64da6014844a0a671a1fa391d4">arm_pid_instance_q31::state</a>.</p>
  481. </div>
  482. </div>
  483. </div><!-- contents -->
  484. </div><!-- doc-content -->
  485. <!-- start footer part -->
  486. <div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  487. <ul>
  488. <li class="footer">Generated on Tue Sep 23 2014 18:52:44 for CMSIS-DSP by ARM Ltd. All rights reserved.
  489. <!--
  490. <a href="http://www.doxygen.org/index.html">
  491. <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.2
  492. -->
  493. </li>
  494. </ul>
  495. </div>
  496. </body>
  497. </html>