⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main_8c.html

📁 Atmel算法(pid)-步进电机驱动源码 HOWTO,不好用你找我,绝对ok!
💻 HTML
📖 第 1 页 / 共 5 页
字号:
<a name="l00730"></a>00730   }<a name="l00731"></a>00731 }</pre></div><p>    </td>  </tr></table><a class="anchor" name="a24"></a><!-- doxytag: member="main.c::BlockCommutate" ref="a24" args="(const uint8_t direction, uint8_t hall)" --><p><table class="mdTable" cellpadding="2" cellspacing="0">  <tr>    <td class="mdRow">      <table cellpadding="0" cellspacing="0" border="0">        <tr>          <td class="md" nowrap valign="top">static void BlockCommutate           </td>          <td class="md" valign="top">(&nbsp;</td>          <td class="md" nowrap valign="top">const <a class="el" href="stdint_8h.html#a56">uint8_t</a>&nbsp;</td>          <td class="mdname" nowrap> <em>direction</em>, </td>        </tr>        <tr>          <td class="md" nowrap align="right"></td>          <td class="md"></td>          <td class="md" nowrap><a class="el" href="stdint_8h.html#a56">uint8_t</a>&nbsp;</td>          <td class="mdname" nowrap> <em>hall</em></td>        </tr>        <tr>          <td class="md"></td>          <td class="md">)&nbsp;</td>          <td class="md" colspan="2"><code> [static]</code></td>        </tr>      </table>    </td>  </tr></table><table cellspacing="5" cellpadding="0" border="0">  <tr>    <td>      &nbsp;    </td>    <td><p>Performs block commutation according to running direction and hall sensor input. <p>This function performs a block commutation according to the specified running direction and hall sensor input.<p><dl compact><dt><b>Note:</b></dt><dd>Do not use this function while the timers are configured for sine wave driving.</dd></dl><dl compact><dt><b>Parameters:</b></dt><dd>  <table border="0" cellspacing="2" cellpadding="0">    <tr><td valign="top"></td><td valign="top"><em>direction</em>&nbsp;</td><td>Direction of rotation. </td></tr>    <tr><td valign="top"></td><td valign="top"><em>hall</em>&nbsp;</td><td>Hall sensor value at the same form as returned by <a class="el" href="main_8c.html#a25">GetHall()</a>.</td></tr>  </table></dl><p>Definition at line <a class="el" href="main_8c-source.html#l00520">520</a> of file <a class="el" href="main_8c-source.html">main.c</a>.<p>References <a class="el" href="PMSMtables_8h-source.html#l00503">blockCommutationTableForward</a>, <a class="el" href="PMSMtables_8h-source.html#l00521">blockCommutationTableReverse</a>, <a class="el" href="PMSM_8h-source.html#l00061">DIRECTION_FORWARD</a>, and <a class="el" href="main_8c-source.html#l00800">DisablePWMOutputs()</a>.<p>Referenced by <a class="el" href="main_8c-source.html#l00816">CommutationTicksUpdate()</a>, and <a class="el" href="main_8c-source.html#l00930">HallChangeISR()</a>.<div class="fragment"><pre class="fragment"><a name="l00521"></a>00521 {<a name="l00522"></a>00522   <a class="code" href="stdint_8h.html#a56">uint8_t</a> <span class="keyword">const</span> __flash *pattern;<a name="l00523"></a>00523 <a name="l00524"></a>00524   <span class="keywordflow">if</span> (direction == <a class="code" href="PMSM_8h.html#a7">DIRECTION_FORWARD</a>)<a name="l00525"></a>00525   {<a name="l00526"></a>00526     pattern = <a class="code" href="PMSMtables_8h.html#a2">blockCommutationTableForward</a>;<a name="l00527"></a>00527   }<a name="l00528"></a>00528   <span class="keywordflow">else</span><a name="l00529"></a>00529   {<a name="l00530"></a>00530     pattern = <a class="code" href="PMSMtables_8h.html#a3">blockCommutationTableReverse</a>;<a name="l00531"></a>00531   }<a name="l00532"></a>00532   pattern += (hall * 2);<a name="l00533"></a>00533 <a name="l00534"></a>00534   <a class="code" href="main_8c.html#a35">DisablePWMOutputs</a>();<a name="l00535"></a>00535   DDRB |= *pattern++;<a name="l00536"></a>00536   DDRD |= *pattern;<a name="l00537"></a>00537 }</pre></div><p><p>Here is the call graph for this function:<p><center><img src="main_8c_a24_cgraph.png" border="0" usemap="#main_8c_a24_cgraph_map" alt=""></center><map name="main_8c_a24_cgraph_map"><area href="main_8c.html#a35" shape="rect" coords="179,5,326,32" alt=""></map>    </td>  </tr></table><a class="anchor" name="a21"></a><!-- doxytag: member="main.c::BlockCommutationSetDuty" ref="a21" args="(const uint8_t duty)" --><p><table class="mdTable" cellpadding="2" cellspacing="0">  <tr>    <td class="mdRow">      <table cellpadding="0" cellspacing="0" border="0">        <tr>          <td class="md" nowrap valign="top">static void BlockCommutationSetDuty           </td>          <td class="md" valign="top">(&nbsp;</td>          <td class="md" nowrap valign="top">const <a class="el" href="stdint_8h.html#a56">uint8_t</a>&nbsp;</td>          <td class="mdname1" valign="top" nowrap> <em>duty</em>          </td>          <td class="md" valign="top">&nbsp;)&nbsp;</td>          <td class="md" nowrap><code> [static]</code></td>        </tr>      </table>    </td>  </tr></table><table cellspacing="5" cellpadding="0" border="0">  <tr>    <td>      &nbsp;    </td>    <td><p>Sets duty cycle for block commutation. <p>This function sets duty cycle when block commutation is used. Never call this function when sine wave generation is used. <dl compact><dt><b>Note:</b></dt><dd>The duty cycle is not in percent, but a value from 0-255. Duty cycle in percent can be calculated as duty * 100 / 255.</dd></dl><dl compact><dt><b>Parameters:</b></dt><dd>  <table border="0" cellspacing="2" cellpadding="0">    <tr><td valign="top"></td><td valign="top"><em>duty</em>&nbsp;</td><td>New duty cycle. Range is 0-255.</td></tr>  </table></dl><p>Definition at line <a class="el" href="main_8c-source.html#l00461">461</a> of file <a class="el" href="main_8c-source.html">main.c</a>.<p>Referenced by <a class="el" href="main_8c-source.html#l01030">Timer1CaptureISR()</a>, and <a class="el" href="main_8c-source.html#l00373">TimersSetModeBlockCommutation()</a>.<div class="fragment"><pre class="fragment"><a name="l00462"></a>00462 {<a name="l00463"></a>00463   <span class="comment">// Set all compare registers to new duty cycle value.</span><a name="l00464"></a>00464   OCR0A = OCR0B = OCR1AL = OCR1BL = OCR2A = OCR2B = duty;<a name="l00465"></a>00465 }</pre></div><p>    </td>  </tr></table><a class="anchor" name="a15"></a><!-- doxytag: member="main.c::CheckEmergencyShutdown" ref="a15" args="(void)" --><p><table class="mdTable" cellpadding="2" cellspacing="0">  <tr>    <td class="mdRow">      <table cellpadding="0" cellspacing="0" border="0">        <tr>          <td class="md" nowrap valign="top">static void CheckEmergencyShutdown           </td>          <td class="md" valign="top">(&nbsp;</td>          <td class="md" nowrap valign="top">void&nbsp;</td>          <td class="mdname1" valign="top" nowrap>          </td>          <td class="md" valign="top">&nbsp;)&nbsp;</td>          <td class="md" nowrap><code> [static]</code></td>        </tr>      </table>    </td>  </tr></table><table cellspacing="5" cellpadding="0" border="0">  <tr>    <td>      &nbsp;    </td>    <td><p>Checks whether emergency shutdown is set at startup. <p>This function checks whether emergency shut-off signal is set at startup and takes action accordingly. This function is only needed at startup, since pin change interrupts are enabled for these signals.<p><dl compact><dt><b>Note:</b></dt><dd>In this version, nothing is done in these situations.</dd></dl><dl compact><dt><b><a class="el" href="todo.html#_todo000001">Todo:</a></b></dt><dd>Write code to handle a situation where either emergency shut-off set at startup. </dd></dl><p>Definition at line <a class="el" href="main_8c-source.html#l00290">290</a> of file <a class="el" href="main_8c-source.html">main.c</a>.<p>References <a class="el" href="PMSM_8h-source.html#l00146">EMERGENCY_SHUTDOWN_PIN</a>.<p>Referenced by <a class="el" href="main_8c-source.html#l00135">main()</a>.<div class="fragment"><pre class="fragment"><a name="l00291"></a>00291 {<a name="l00292"></a>00292   <span class="keywordflow">if</span> ( (PINB &amp; (1 &lt;&lt; <a class="code" href="PMSM_8h.html#a29">EMERGENCY_SHUTDOWN_PIN</a>)) != 0)<a name="l00293"></a>00293   {<a name="l00294"></a>00294     <span class="comment">//Insert code here to handle emercency shutdown signal at startup.</span><a name="l00295"></a>00295   }<a name="l00296"></a>00296 }</pre></div><p>    </td>  </tr></table><a class="anchor" name="a36"></a><!-- doxytag: member="main.c::CommutationTicksUpdate" ref="a36" args="(void)" --><p><table class="mdTable" cellpadding="2" cellspacing="0">  <tr>    <td class="mdRow">      <table cellpadding="0" cellspacing="0" border="0">        <tr>          <td class="md" nowrap valign="top">static void CommutationTicksUpdate           </td>          <td class="md" valign="top">(&nbsp;</td>          <td class="md" nowrap valign="top">void&nbsp;</td>          <td class="mdname1" valign="top" nowrap>          </td>          <td class="md" valign="top">&nbsp;)&nbsp;</td>          <td class="md" nowrap><code> [static]</code></td>        </tr>      </table>    </td>  </tr></table><table cellspacing="5" cellpadding="0" border="0">  <tr>    <td>      &nbsp;    </td>    <td><p>Updates the 'tick' counter and checks for stopped motor. <p>This function should be run at every PWM timer overflow to ensure that all 'ticks' are counted. It increases the 'tick' counter until it reaches the maximum tick limit that corresponds to what is considered a stopped or stalled motor. In that case, the global motor stopped flag is set.<p>Definition at line <a class="el" href="main_8c-source.html#l00816">816</a> of file <a class="el" href="main_8c-source.html">main.c</a>.<p>References <a class="el" href="main_8c-source.html#l00520">BlockCommutate()</a>, <a class="el" href="PMSM_8h-source.html#l00165">COMMUTATION_TICKS_STOPPED</a>, <a class="el" href="main_8c-source.html#l00071">commutationTicks</a>, <a class="el" href="pid_8h-source.html#l00079">FALSE</a>, <a class="el" href="main_8c-source.html#l00479">GetDesiredDirection()</a>, <a class="el" href="main_8c-source.html#l00556">GetHall()</a>, <a class="el" href="pid_8c-source.html#l00129">PID_Reset_Integrator()</a>, <a class="el" href="main_8c-source.html#l00373">TimersSetModeBlockCommutation()</a>, <a class="el" href="pid_8h-source.html#l00082">TRUE</a>, and <a class="el" href="PMSM_8h-source.html#l00149">WAVEFORM_BLOCK_COMMUTATION</a>.<p>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -