forked from ZhuYanzhen1/miniFOC
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathencoder_8h.html
263 lines (229 loc) · 15.7 KB
/
encoder_8h.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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
<!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.4"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>miniFOC: algorithm/encoder.h File Reference</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 id="projectrow">
<td id="projectlogo"><img alt="Logo" src="Acme_LOGO.png"/></td>
<td id="projectalign">
<div id="projectname">miniFOC<span id="projectnumber"> 1.0.3</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.4 -->
<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="summary">
<a href="#func-members">Functions</a> |
<a href="#var-members">Variables</a> </div>
<div class="headertitle"><div class="title">encoder.h File Reference</div></div>
</div><!--header-->
<div class="contents">
<p>this is the header file of <a class="el" href="encoder_8c.html" title="this file contains the code implementation of angle acquisition and initialization functions of sc602...">encoder.c</a>.
<a href="#details">More...</a></p>
<p><a href="encoder_8h_source.html">Go to the source code of this file.</a></p>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="func-members" name="func-members"></a>
Functions</h2></td></tr>
<tr class="memitem:ad28e37c20d065e5014ea3a5f2de91e82"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="encoder_8h.html#ad28e37c20d065e5014ea3a5f2de91e82">encoder_zeroing</a> (void)</td></tr>
<tr class="memdesc:ad28e37c20d065e5014ea3a5f2de91e82"><td class="mdescLeft"> </td><td class="mdescRight">correct the mechanical angle zero deviation between the magnetic encoder and FOC. <a href="encoder_8h.html#ad28e37c20d065e5014ea3a5f2de91e82">More...</a><br /></td></tr>
<tr class="separator:ad28e37c20d065e5014ea3a5f2de91e82"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:a28beb7b571ff9e6d39118c8d1324e154"><td class="memItemLeft" align="right" valign="top">unsigned short </td><td class="memItemRight" valign="bottom"><a class="el" href="encoder_8h.html#a28beb7b571ff9e6d39118c8d1324e154">encoder_get_mechanical_angle</a> (void)</td></tr>
<tr class="memdesc:a28beb7b571ff9e6d39118c8d1324e154"><td class="mdescLeft"> </td><td class="mdescRight">read mechanical angle directly from encoder <a href="encoder_8h.html#a28beb7b571ff9e6d39118c8d1324e154">More...</a><br /></td></tr>
<tr class="separator:a28beb7b571ff9e6d39118c8d1324e154"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:a8fbcb19c2f15c20c1a862e0cf64f6771"><td class="memItemLeft" align="right" valign="top">float </td><td class="memItemRight" valign="bottom"><a class="el" href="encoder_8h.html#a8fbcb19c2f15c20c1a862e0cf64f6771">encoder_get_electronic_angle</a> (void)</td></tr>
<tr class="memdesc:a8fbcb19c2f15c20c1a862e0cf64f6771"><td class="mdescLeft"> </td><td class="mdescRight">according to the electrical angle calculated from the mechanical angle, this function will call <a class="el" href="encoder_8c.html#a28beb7b571ff9e6d39118c8d1324e154" title="read mechanical angle directly from encoder">encoder_get_mechanical_angle()</a> function. <a href="encoder_8h.html#a8fbcb19c2f15c20c1a862e0cf64f6771">More...</a><br /></td></tr>
<tr class="separator:a8fbcb19c2f15c20c1a862e0cf64f6771"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:a82c51d78a1f7bb4a5976974ab8d7ffe5"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="encoder_8h.html#a82c51d78a1f7bb4a5976974ab8d7ffe5">encoder_update_speed</a> (void)</td></tr>
<tr class="memdesc:a82c51d78a1f7bb4a5976974ab8d7ffe5"><td class="mdescLeft"> </td><td class="mdescRight">called every 2 milliseconds to calculate the speed. <a href="encoder_8h.html#a82c51d78a1f7bb4a5976974ab8d7ffe5">More...</a><br /></td></tr>
<tr class="separator:a82c51d78a1f7bb4a5976974ab8d7ffe5"><td class="memSeparator" colspan="2"> </td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="var-members" name="var-members"></a>
Variables</h2></td></tr>
<tr class="memitem:a562eacc7259f25574b1ab8ce9d7c6a3e"><td class="memItemLeft" align="right" valign="top">volatile unsigned short </td><td class="memItemRight" valign="bottom"><a class="el" href="encoder_8h.html#a562eacc7259f25574b1ab8ce9d7c6a3e">machine_angle_offset</a></td></tr>
<tr class="memdesc:a562eacc7259f25574b1ab8ce9d7c6a3e"><td class="mdescLeft"> </td><td class="mdescRight">mechanical angle offset, which is used to align the mechanical angle with the zero point of the electrical angle. <a href="encoder_8h.html#a562eacc7259f25574b1ab8ce9d7c6a3e">More...</a><br /></td></tr>
<tr class="separator:a562eacc7259f25574b1ab8ce9d7c6a3e"><td class="memSeparator" colspan="2"> </td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><p >this is the header file of <a class="el" href="encoder_8c.html" title="this file contains the code implementation of angle acquisition and initialization functions of sc602...">encoder.c</a>. </p>
<dl class="section author"><dt>Author</dt><dd>Lao·Zhu </dd></dl>
<dl class="section version"><dt>Version</dt><dd>V1.0.1 </dd></dl>
<dl class="section date"><dt>Date</dt><dd>10. October 2021 </dd></dl>
<p class="definition">Definition in file <a class="el" href="encoder_8h_source.html">encoder.h</a>.</p>
</div><h2 class="groupheader">Function Documentation</h2>
<a id="a8fbcb19c2f15c20c1a862e0cf64f6771" name="a8fbcb19c2f15c20c1a862e0cf64f6771"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a8fbcb19c2f15c20c1a862e0cf64f6771">◆ </a></span>encoder_get_electronic_angle()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">float encoder_get_electronic_angle </td>
<td>(</td>
<td class="paramtype">void </td>
<td class="paramname"></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>according to the electrical angle calculated from the mechanical angle, this function will call <a class="el" href="encoder_8c.html#a28beb7b571ff9e6d39118c8d1324e154" title="read mechanical angle directly from encoder">encoder_get_mechanical_angle()</a> function. </p>
<dl class="retval"><dt>Return values</dt><dd>
<table class="retval">
<tr><td class="paramname">register</td><td>raw data reading back </td></tr>
</table>
</dd>
</dl>
<p class="definition">Definition at line <a class="el" href="encoder_8c_source.html#l00093">93</a> of file <a class="el" href="encoder_8c_source.html">encoder.c</a>.</p>
<p class="reference">References <a class="el" href="foc_8h_source.html#l00026">ELECANGLE_COEFFICIENT</a>, <a class="el" href="encoder_8c_source.html#l00076">encoder_get_mechanical_angle()</a>, <a class="el" href="config_8h_source.html#l00017">ENCODER_RESO</a>, <a class="el" href="foc_8c_source.html#l00020">FOC_Struct</a>, <a class="el" href="foc_8h_source.html#l00024">MECHANGLE_COEFFICIENT</a>, <a class="el" href="foc_8h_source.html#l00018">FOC_Structure_t::mechanical_angle</a>, and <a class="el" href="config_8h_source.html#l00015">POLAR_PAIRS</a>.</p>
<p class="reference">Referenced by <a class="el" href="gd32f1x0__it_8c_source.html#l00104">TIMER2_IRQHandler()</a>.</p>
</div>
</div>
<a id="a28beb7b571ff9e6d39118c8d1324e154" name="a28beb7b571ff9e6d39118c8d1324e154"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a28beb7b571ff9e6d39118c8d1324e154">◆ </a></span>encoder_get_mechanical_angle()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">unsigned short encoder_get_mechanical_angle </td>
<td>(</td>
<td class="paramtype">void </td>
<td class="paramname"></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>read mechanical angle directly from encoder </p>
<dl class="retval"><dt>Return values</dt><dd>
<table class="retval">
<tr><td class="paramname">register</td><td>raw data reading back </td></tr>
</table>
</dd>
</dl>
<p class="definition">Definition at line <a class="el" href="encoder_8c_source.html#l00076">76</a> of file <a class="el" href="encoder_8c_source.html">encoder.c</a>.</p>
<p class="reference">References <a class="el" href="encoder_8c_source.html#l00056">encoder_read_data()</a>, <a class="el" href="config_8h_source.html#l00017">ENCODER_RESO</a>, <a class="el" href="encoder_8c_source.html#l00029">last_mechanical_angle</a>, <a class="el" href="encoder_8c_source.html#l00023">machine_angle_offset</a>, and <a class="el" href="encoder_8c_source.html#l00034">total_machine_angle</a>.</p>
<p class="reference">Referenced by <a class="el" href="encoder_8c_source.html#l00093">encoder_get_electronic_angle()</a>, and <a class="el" href="foc_8c_source.html#l00033">foc_calibrate_phase()</a>.</p>
</div>
</div>
<a id="a82c51d78a1f7bb4a5976974ab8d7ffe5" name="a82c51d78a1f7bb4a5976974ab8d7ffe5"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a82c51d78a1f7bb4a5976974ab8d7ffe5">◆ </a></span>encoder_update_speed()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void encoder_update_speed </td>
<td>(</td>
<td class="paramtype">void </td>
<td class="paramname"></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>called every 2 milliseconds to calculate the speed. </p>
<p class="definition">Definition at line <a class="el" href="encoder_8c_source.html#l00106">106</a> of file <a class="el" href="encoder_8c_source.html">encoder.c</a>.</p>
<p class="reference">References <a class="el" href="filter_8c_source.html#l00056">filter_update_value()</a>, <a class="el" href="foc_8c_source.html#l00020">FOC_Struct</a>, <a class="el" href="foc_8h_source.html#l00019">FOC_Structure_t::rotate_speed</a>, <a class="el" href="encoder_8c_source.html#l00039">systick_mechanical_angle_last</a>, <a class="el" href="encoder_8c_source.html#l00034">total_machine_angle</a>, and <a class="el" href="filter_8c_source.html#l00019">velocity_filter</a>.</p>
<p class="reference">Referenced by <a class="el" href="gd32f1x0__it_8c_source.html#l00077">SysTick_Handler()</a>.</p>
</div>
</div>
<a id="ad28e37c20d065e5014ea3a5f2de91e82" name="ad28e37c20d065e5014ea3a5f2de91e82"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ad28e37c20d065e5014ea3a5f2de91e82">◆ </a></span>encoder_zeroing()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void encoder_zeroing </td>
<td>(</td>
<td class="paramtype">void </td>
<td class="paramname"></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>correct the mechanical angle zero deviation between the magnetic encoder and FOC. </p>
<p class="definition">Definition at line <a class="el" href="encoder_8c_source.html#l00119">119</a> of file <a class="el" href="encoder_8c_source.html">encoder.c</a>.</p>
<p class="reference">References <a class="el" href="config_8h_source.html#l00019">CALI_TORQUE</a>, <a class="el" href="system_8c_source.html#l00030">delayms()</a>, <a class="el" href="encoder_8c_source.html#l00056">encoder_read_data()</a>, <a class="el" href="foc_8c_source.html#l00099">foc_calculate_dutycycle()</a>, <a class="el" href="encoder_8c_source.html#l00023">machine_angle_offset</a>, <a class="el" href="encoder_8c_source.html#l00034">total_machine_angle</a>, and <a class="el" href="timer_8c_source.html#l00020">update_pwm_dutycycle()</a>.</p>
<p class="reference">Referenced by <a class="el" href="main_8c_source.html#l00139">main()</a>.</p>
</div>
</div>
<h2 class="groupheader">Variable Documentation</h2>
<a id="a562eacc7259f25574b1ab8ce9d7c6a3e" name="a562eacc7259f25574b1ab8ce9d7c6a3e"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a562eacc7259f25574b1ab8ce9d7c6a3e">◆ </a></span>machine_angle_offset</h2>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname">volatile unsigned short machine_angle_offset</td>
</tr>
</table>
</td>
<td class="mlabels-right">
<span class="mlabels"><span class="mlabel">extern</span></span> </td>
</tr>
</table>
</div><div class="memdoc">
<p>mechanical angle offset, which is used to align the mechanical angle with the zero point of the electrical angle. </p>
<p class="definition">Definition at line <a class="el" href="encoder_8c_source.html#l00023">23</a> of file <a class="el" href="encoder_8c_source.html">encoder.c</a>.</p>
<p class="reference">Referenced by <a class="el" href="encoder_8c_source.html#l00076">encoder_get_mechanical_angle()</a>, <a class="el" href="encoder_8c_source.html#l00119">encoder_zeroing()</a>, <a class="el" href="flash_8c_source.html#l00046">flash_read_parameters()</a>, <a class="el" href="flash_8c_source.html#l00026">flash_write_parameters()</a>, and <a class="el" href="report_8c_source.html#l00015">report_local_variable()</a>.</p>
</div>
</div>
</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.4
</small></address>
</body>
</html>