forked from ZhuYanzhen1/miniFOC
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpid_8h_source.html
124 lines (122 loc) · 16.8 KB
/
pid_8h_source.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
<meta name="generator" content="Doxygen 1.9.2"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>miniFOC: algorithm/pid.h Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
<tbody>
<tr style="height: 56px;">
<td id="projectlogo"><img alt="Logo" src="Acme_LOGO.png"/></td>
<td id="projectalign" style="padding-left: 0.5em;">
<div id="projectname">miniFOC<span id="projectnumber"> 1.0.2</span>
</div>
<div id="projectbrief">This open-source project aims to accomplish a FOC(Field Oriented Control) scheme that is operatable with minimum costs in China.</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.9.2 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt MIT */
var searchBox = new SearchBox("searchBox", "search",'Search','.html');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt MIT */
$(function() {
initMenu('',true,false,'search.php','Search');
$(document).ready(function() { init_search(); });
});
/* @license-end */
</script>
<div id="main-nav"></div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>
<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0"
name="MSearchResults" id="MSearchResults">
</iframe>
</div>
<div id="nav-path" class="navpath">
<ul>
<li class="navelem"><a class="el" href="dir_99d3723365464dd656f512988bb8dbbd.html">algorithm</a></li> </ul>
</div>
</div><!-- top -->
<div class="header">
<div class="headertitle"><div class="title">pid.h</div></div>
</div><!--header-->
<div class="contents">
<a href="pid_8h.html">Go to the documentation of this file.</a><div class="fragment"><div class="line"><a id="l00001" name="l00001"></a><span class="lineno"> 1</span><span class="comment">/**************************************************************************/</span></div>
<div class="line"><a id="l00010" name="l00010"></a><span class="lineno"> 10</span><span class="preprocessor">#ifndef MINIFOC_ALGORITHM_PID_H_</span></div>
<div class="line"><a id="l00011" name="l00011"></a><span class="lineno"> 11</span><span class="preprocessor">#define MINIFOC_ALGORITHM_PID_H_</span></div>
<div class="line"><a id="l00012" name="l00012"></a><span class="lineno"> 12</span> </div>
<div class="line"><a id="l00014" name="l00014"></a><span class="lineno"><a class="line" href="pid_8h.html#a8ffc8824a06f7892f9691a65b83982a7"> 14</a></span><span class="preprocessor">#define TORQUE_LOOP_CONTROL 1</span></div>
<div class="line"><a id="l00016" name="l00016"></a><span class="lineno"><a class="line" href="pid_8h.html#aa5ef3ead33ee14a82e7ee277d31e02d1"> 16</a></span><span class="preprocessor">#define SPEED_LOOP_CONTROL 2</span></div>
<div class="line"><a id="l00018" name="l00018"></a><span class="lineno"><a class="line" href="pid_8h.html#a7dad3a985101eaec7ac078f43747c928"> 18</a></span><span class="preprocessor">#define ANGLE_LOOP_CONTROL 3</span></div>
<div class="line"><a id="l00019" name="l00019"></a><span class="lineno"> 19</span> </div>
<div class="line"><a id="l00024" name="l00024"></a><span class="lineno"><a class="line" href="struct_p_i_d___structure__t.html"> 24</a></span><span class="keyword">typedef</span> <span class="keyword">struct </span>{</div>
<div class="line"><a id="l00025" name="l00025"></a><span class="lineno"><a class="line" href="struct_p_i_d___structure__t.html#a1f7add0f84d583bc2eceb290d6c4cc06"> 25</a></span> <span class="keywordtype">float</span> <a class="code hl_variable" href="struct_p_i_d___structure__t.html#a1f7add0f84d583bc2eceb290d6c4cc06">kp</a>; </div>
<div class="line"><a id="l00026" name="l00026"></a><span class="lineno"><a class="line" href="struct_p_i_d___structure__t.html#a050993b7ca6c97e62c1020017f716b91"> 26</a></span> <span class="keywordtype">float</span> <a class="code hl_variable" href="struct_p_i_d___structure__t.html#a050993b7ca6c97e62c1020017f716b91">ki</a>; </div>
<div class="line"><a id="l00027" name="l00027"></a><span class="lineno"><a class="line" href="struct_p_i_d___structure__t.html#ae7a5c6018507bb1361fcca170e069b9c"> 27</a></span> <span class="keywordtype">float</span> <a class="code hl_variable" href="struct_p_i_d___structure__t.html#ae7a5c6018507bb1361fcca170e069b9c">kd</a>; </div>
<div class="line"><a id="l00028" name="l00028"></a><span class="lineno"><a class="line" href="struct_p_i_d___structure__t.html#a5f567aec72ce48f24c2dbc06dcfa3a09"> 28</a></span> <span class="keywordtype">float</span> <a class="code hl_variable" href="struct_p_i_d___structure__t.html#a5f567aec72ce48f24c2dbc06dcfa3a09">summary</a>; </div>
<div class="line"><a id="l00029" name="l00029"></a><span class="lineno"><a class="line" href="struct_p_i_d___structure__t.html#ad0e13a810b1a4602c1ce625f9877cbf5"> 29</a></span> <span class="keywordtype">float</span> <a class="code hl_variable" href="struct_p_i_d___structure__t.html#ad0e13a810b1a4602c1ce625f9877cbf5">expect</a>; </div>
<div class="line"><a id="l00030" name="l00030"></a><span class="lineno"><a class="line" href="struct_p_i_d___structure__t.html#a466d4dab1bd38a43438c2e5e6ad5534e"> 30</a></span> <span class="keywordtype">float</span> <a class="code hl_variable" href="struct_p_i_d___structure__t.html#a466d4dab1bd38a43438c2e5e6ad5534e">maximum</a>; </div>
<div class="line"><a id="l00031" name="l00031"></a><span class="lineno"><a class="line" href="struct_p_i_d___structure__t.html#a1fac701369b1197497f7c698ad74386d"> 31</a></span> <span class="keywordtype">float</span> <a class="code hl_variable" href="struct_p_i_d___structure__t.html#a1fac701369b1197497f7c698ad74386d">minimum</a>; </div>
<div class="line"><a id="l00032" name="l00032"></a><span class="lineno"><a class="line" href="struct_p_i_d___structure__t.html#a51379d672c255e751fb020ef2394a8f0"> 32</a></span> <span class="keywordtype">float</span> <a class="code hl_variable" href="struct_p_i_d___structure__t.html#a51379d672c255e751fb020ef2394a8f0">sum_maximum</a>; </div>
<div class="line"><a id="l00033" name="l00033"></a><span class="lineno"><a class="line" href="struct_p_i_d___structure__t.html#a53bf2ded26ca455e1227890c20123cd9"> 33</a></span> <span class="keywordtype">float</span> <a class="code hl_variable" href="struct_p_i_d___structure__t.html#a53bf2ded26ca455e1227890c20123cd9">last_error</a>; </div>
<div class="line"><a id="l00034" name="l00034"></a><span class="lineno"> 34</span>} <a class="code hl_struct" href="struct_p_i_d___structure__t.html">PID_Structure_t</a>;</div>
<div class="line"><a id="l00035" name="l00035"></a><span class="lineno"> 35</span> </div>
<div class="line"><a id="l00036" name="l00036"></a><span class="lineno"> 36</span><span class="keyword">extern</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> <a class="code hl_variable" href="pid_8h.html#a48934d9569b54761658f7fe0484db10c">pid_parameter_available_flag</a>;</div>
<div class="line"><a id="l00037" name="l00037"></a><span class="lineno"> 37</span><span class="keyword">extern</span> <span class="keyword">volatile</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> <a class="code hl_variable" href="pid_8h.html#a2c7bcbec66fa40a2347b1cd253a5ae82">pid_control_mode_flag</a>;</div>
<div class="line"><a id="l00038" name="l00038"></a><span class="lineno"> 38</span><span class="keyword">extern</span> <span class="keyword">volatile</span> <a class="code hl_struct" href="struct_p_i_d___structure__t.html">PID_Structure_t</a> <a class="code hl_variable" href="pid_8h.html#ab051c8f4a730b934b146f330514efd95">speed_pid_handler</a>;</div>
<div class="line"><a id="l00039" name="l00039"></a><span class="lineno"> 39</span><span class="keyword">extern</span> <span class="keyword">volatile</span> <a class="code hl_struct" href="struct_p_i_d___structure__t.html">PID_Structure_t</a> <a class="code hl_variable" href="pid_8h.html#aaa8f5bad87ffc78a20f06863ab6bad5c">angle_pid_handler</a>;</div>
<div class="line"><a id="l00040" name="l00040"></a><span class="lineno"> 40</span><span class="keywordtype">void</span> <a class="code hl_function" href="pid_8h.html#a58a093011af03fae7427eb1980434a5e">pid_config</a>(<span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> mode);</div>
<div class="line"><a id="l00041" name="l00041"></a><span class="lineno"> 41</span><span class="keywordtype">float</span> <a class="code hl_function" href="pid_8h.html#abe6a9dce63d0eaad5a10d4c8c5ffcd07">pid_calculate_result</a>(<a class="code hl_struct" href="struct_p_i_d___structure__t.html">PID_Structure_t</a> *pid_handler, <span class="keywordtype">float</span> collect);</div>
<div class="line"><a id="l00042" name="l00042"></a><span class="lineno"> 42</span> </div>
<div class="line"><a id="l00043" name="l00043"></a><span class="lineno"> 43</span><span class="preprocessor">#endif </span><span class="comment">//MINIFOC_ALGORITHM_PID_H_</span></div>
<div class="ttc" id="apid_8h_html_a2c7bcbec66fa40a2347b1cd253a5ae82"><div class="ttname"><a href="pid_8h.html#a2c7bcbec66fa40a2347b1cd253a5ae82">pid_control_mode_flag</a></div><div class="ttdeci">volatile unsigned char pid_control_mode_flag</div><div class="ttdoc">flag variable of PID closed loop mode</div><div class="ttdef"><b>Definition:</b> <a href="pid_8c_source.html#l00020">pid.c:20</a></div></div>
<div class="ttc" id="apid_8h_html_a48934d9569b54761658f7fe0484db10c"><div class="ttname"><a href="pid_8h.html#a48934d9569b54761658f7fe0484db10c">pid_parameter_available_flag</a></div><div class="ttdeci">unsigned char pid_parameter_available_flag</div><div class="ttdoc">flag variable for PID parameter availability</div><div class="ttdef"><b>Definition:</b> <a href="pid_8c_source.html#l00016">pid.c:16</a></div></div>
<div class="ttc" id="apid_8h_html_a58a093011af03fae7427eb1980434a5e"><div class="ttname"><a href="pid_8h.html#a58a093011af03fae7427eb1980434a5e">pid_config</a></div><div class="ttdeci">void pid_config(unsigned char mode)</div><div class="ttdoc">configure pid loop parameters</div><div class="ttdef"><b>Definition:</b> <a href="pid_8c_source.html#l00034">pid.c:34</a></div></div>
<div class="ttc" id="apid_8h_html_aaa8f5bad87ffc78a20f06863ab6bad5c"><div class="ttname"><a href="pid_8h.html#aaa8f5bad87ffc78a20f06863ab6bad5c">angle_pid_handler</a></div><div class="ttdeci">volatile PID_Structure_t angle_pid_handler</div><div class="ttdoc">algorithm handler of PID angle loop</div><div class="ttdef"><b>Definition:</b> <a href="pid_8c_source.html#l00028">pid.c:28</a></div></div>
<div class="ttc" id="apid_8h_html_ab051c8f4a730b934b146f330514efd95"><div class="ttname"><a href="pid_8h.html#ab051c8f4a730b934b146f330514efd95">speed_pid_handler</a></div><div class="ttdeci">volatile PID_Structure_t speed_pid_handler</div><div class="ttdoc">algorithm handler of PID speed loop</div><div class="ttdef"><b>Definition:</b> <a href="pid_8c_source.html#l00024">pid.c:24</a></div></div>
<div class="ttc" id="apid_8h_html_abe6a9dce63d0eaad5a10d4c8c5ffcd07"><div class="ttname"><a href="pid_8h.html#abe6a9dce63d0eaad5a10d4c8c5ffcd07">pid_calculate_result</a></div><div class="ttdeci">float pid_calculate_result(PID_Structure_t *pid_handler, float collect)</div><div class="ttdoc">calculate result using sampling value</div><div class="ttdef"><b>Definition:</b> <a href="pid_8c_source.html#l00057">pid.c:57</a></div></div>
<div class="ttc" id="astruct_p_i_d___structure__t_html"><div class="ttname"><a href="struct_p_i_d___structure__t.html">PID_Structure_t</a></div><div class="ttdoc">structure of PID algorithm</div><div class="ttdef"><b>Definition:</b> <a href="pid_8h_source.html#l00024">pid.h:24</a></div></div>
<div class="ttc" id="astruct_p_i_d___structure__t_html_a050993b7ca6c97e62c1020017f716b91"><div class="ttname"><a href="struct_p_i_d___structure__t.html#a050993b7ca6c97e62c1020017f716b91">PID_Structure_t::ki</a></div><div class="ttdeci">float ki</div><div class="ttdoc">integral term coefficient in PID</div><div class="ttdef"><b>Definition:</b> <a href="pid_8h_source.html#l00026">pid.h:26</a></div></div>
<div class="ttc" id="astruct_p_i_d___structure__t_html_a1f7add0f84d583bc2eceb290d6c4cc06"><div class="ttname"><a href="struct_p_i_d___structure__t.html#a1f7add0f84d583bc2eceb290d6c4cc06">PID_Structure_t::kp</a></div><div class="ttdeci">float kp</div><div class="ttdoc">proportional term coefficient in PID</div><div class="ttdef"><b>Definition:</b> <a href="pid_8h_source.html#l00025">pid.h:25</a></div></div>
<div class="ttc" id="astruct_p_i_d___structure__t_html_a1fac701369b1197497f7c698ad74386d"><div class="ttname"><a href="struct_p_i_d___structure__t.html#a1fac701369b1197497f7c698ad74386d">PID_Structure_t::minimum</a></div><div class="ttdeci">float minimum</div><div class="ttdoc">minimum output in PID</div><div class="ttdef"><b>Definition:</b> <a href="pid_8h_source.html#l00031">pid.h:31</a></div></div>
<div class="ttc" id="astruct_p_i_d___structure__t_html_a466d4dab1bd38a43438c2e5e6ad5534e"><div class="ttname"><a href="struct_p_i_d___structure__t.html#a466d4dab1bd38a43438c2e5e6ad5534e">PID_Structure_t::maximum</a></div><div class="ttdeci">float maximum</div><div class="ttdoc">maximum output in PID</div><div class="ttdef"><b>Definition:</b> <a href="pid_8h_source.html#l00030">pid.h:30</a></div></div>
<div class="ttc" id="astruct_p_i_d___structure__t_html_a51379d672c255e751fb020ef2394a8f0"><div class="ttname"><a href="struct_p_i_d___structure__t.html#a51379d672c255e751fb020ef2394a8f0">PID_Structure_t::sum_maximum</a></div><div class="ttdeci">float sum_maximum</div><div class="ttdoc">maximum of anti saturation integral in PID</div><div class="ttdef"><b>Definition:</b> <a href="pid_8h_source.html#l00032">pid.h:32</a></div></div>
<div class="ttc" id="astruct_p_i_d___structure__t_html_a53bf2ded26ca455e1227890c20123cd9"><div class="ttname"><a href="struct_p_i_d___structure__t.html#a53bf2ded26ca455e1227890c20123cd9">PID_Structure_t::last_error</a></div><div class="ttdeci">float last_error</div><div class="ttdoc">error value of previous calculation in PID</div><div class="ttdef"><b>Definition:</b> <a href="pid_8h_source.html#l00033">pid.h:33</a></div></div>
<div class="ttc" id="astruct_p_i_d___structure__t_html_a5f567aec72ce48f24c2dbc06dcfa3a09"><div class="ttname"><a href="struct_p_i_d___structure__t.html#a5f567aec72ce48f24c2dbc06dcfa3a09">PID_Structure_t::summary</a></div><div class="ttdeci">float summary</div><div class="ttdoc">value of integral term in PID</div><div class="ttdef"><b>Definition:</b> <a href="pid_8h_source.html#l00028">pid.h:28</a></div></div>
<div class="ttc" id="astruct_p_i_d___structure__t_html_ad0e13a810b1a4602c1ce625f9877cbf5"><div class="ttname"><a href="struct_p_i_d___structure__t.html#ad0e13a810b1a4602c1ce625f9877cbf5">PID_Structure_t::expect</a></div><div class="ttdeci">float expect</div><div class="ttdoc">user expectations in PID</div><div class="ttdef"><b>Definition:</b> <a href="pid_8h_source.html#l00029">pid.h:29</a></div></div>
<div class="ttc" id="astruct_p_i_d___structure__t_html_ae7a5c6018507bb1361fcca170e069b9c"><div class="ttname"><a href="struct_p_i_d___structure__t.html#ae7a5c6018507bb1361fcca170e069b9c">PID_Structure_t::kd</a></div><div class="ttdeci">float kd</div><div class="ttdoc">differential term coefficient in PID</div><div class="ttdef"><b>Definition:</b> <a href="pid_8h_source.html#l00027">pid.h:27</a></div></div>
</div><!-- fragment --></div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated by <a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.9.2
</small></address>
</body>
</html>