📄 sm__driver_8c.html
字号:
<td class="md" valign="top"> ) </td> <td class="md" nowrap></td> </tr> </table> </td> </tr></table><table cellspacing=5 cellpadding=0 border=0> <tr> <td> </td> <td><p>Move the stepper motor one step. <p>Makes the stepcounter inc/dec one value and outputs this to the steppermotor. This function works like a stepper motor controller, a call to the function is the stepping pulse, and parameter 'inc' is the direction signal.<p><dl compact><dt><b>Parameters:</b></dt><dd> <table border="0" cellspacing="2" cellpadding="0"> <tr><td></td><td valign=top><em>inc</em> </td><td>Direction to move. </td></tr> </table></dl><dl compact><dt><b>Returns:</b></dt><dd>Stepcounter value. </dd></dl><p>Definition at line <a class="el" href="sm__driver_8c-source.html#l00066">66</a> of file <a class="el" href="sm__driver_8c-source.html">sm_driver.c</a>.<p>References <a class="el" href="sm__driver_8h-source.html#l00026">CCW</a>, <a class="el" href="sm__driver_8c-source.html#l00108">sm_driver_StepOutput()</a>, and <a class="el" href="sm__driver_8c-source.html#l00045">stepPosition</a>.<p>Referenced by <a class="el" href="speed__cntr_8c-source.html#l00164">speed_cntr_TIMER1_COMPA_interrupt()</a>.<p><pre class="fragment"><div>00067 {00068 <span class="comment">// Counts 0-1-...-6-7 in halfstep, 0-2-4-6 in fullstep</span>00069 <span class="keyword">static</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> counter = 0;00070 <span class="comment">// Update</span>00071 <span class="keywordflow">if</span>(inc == <a class="code" href="sm__driver_8h.html#a1">CCW</a>){00072 <a class="code" href="sm__driver_8c.html#a5">stepPosition</a>--;00073 }00074 <span class="keywordflow">else</span>{00075 <a class="code" href="sm__driver_8c.html#a5">stepPosition</a>++;00076 }00077 00078 <span class="preprocessor">#ifdef HALFSTEPS</span>00079 <span class="preprocessor"></span> <span class="keywordflow">if</span>(inc){00080 counter++;00081 }00082 <span class="keywordflow">else</span>{00083 counter--;00084 }00085 <span class="preprocessor">#else</span>00086 <span class="preprocessor"></span> <span class="keywordflow">if</span>(inc){00087 counter += 2;00088 }00089 <span class="keywordflow">else</span>{00090 counter -= 2;00091 }00092 <span class="preprocessor">#endif</span>00093 <span class="preprocessor"></span>00094 <span class="comment">// Stay within the steptab</span>00095 counter &= 0x07;00096 <a class="code" href="sm__driver_8h.html#a12">sm_driver_StepOutput</a>(counter);00097 <span class="keywordflow">return</span>(counter);00098 }</div></pre><p>Here is the call graph for this function:<p><center><img src="sm__driver_8c_a7_cgraph.png" border="0" usemap="#sm__driver_8c_a7_cgraph_map" alt=""></center><map name="sm__driver_8c_a7_cgraph_map"><area href="sm__driver_8h.html#a12" shape="rect" coords="220,7,377,33" alt=""></map> </td> </tr></table><a class="anchor" name="a8" doxytag="sm_driver.c::sm_driver_StepOutput" ></a><p><table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> <tr> <td class="mdRow"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td class="md" nowrap valign="top"> void sm_driver_StepOutput </td> <td class="md" valign="top">( </td> <td class="md" nowrap valign="top">unsigned char </td> <td class="mdname1" valign="top" nowrap> <em>pos</em> </td> <td class="md" valign="top"> ) </td> <td class="md" nowrap></td> </tr> </table> </td> </tr></table><table cellspacing=5 cellpadding=0 border=0> <tr> <td> </td> <td><p>Convert the stepcounter value to signals for the stepper motor. <p>Uses the stepcounter value as index in steptab to get correct steppermotor control signals. Converts these signals to work with the stepper driver hardware.<p><dl compact><dt><b>Parameters:</b></dt><dd> <table border="0" cellspacing="2" cellpadding="0"> <tr><td></td><td valign=top><em>pos</em> </td><td>Stepcounter value. </td></tr> </table></dl><p>Definition at line <a class="el" href="sm__driver_8c-source.html#l00108">108</a> of file <a class="el" href="sm__driver_8c-source.html">sm_driver.c</a>.<p>References <a class="el" href="sm__driver_8h-source.html#l00041">SM_PORT</a>, and <a class="el" href="sm__driver_8c-source.html#l00035">steptab</a>.<p>Referenced by <a class="el" href="main_8c-source.html#l00042">Init()</a>, and <a class="el" href="sm__driver_8c-source.html#l00066">sm_driver_StepCounter()</a>.<p><pre class="fragment"><div>00109 {00110 <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> temp = <a class="code" href="sm__driver_8c.html#a4">steptab</a>[pos];00111 00112 <span class="comment">/*</span>00113 <span class="comment"> // Output bit by bit</span>00114 <span class="comment"> if(temp&(1<<BIT_A1))</span>00115 <span class="comment"> SM_PORT |= (1<<A1);</span>00116 <span class="comment"> else</span>00117 <span class="comment"> SM_PORT &= ~(1<<A1);</span>00118 <span class="comment"></span>00119 <span class="comment"> if(temp&(1<<BIT_A2))</span>00120 <span class="comment"> SM_PORT |= (1<<A2);</span>00121 <span class="comment"> else</span>00122 <span class="comment"> SM_PORT &= ~(1<<A2);</span>00123 <span class="comment"></span>00124 <span class="comment"> if(temp&(1<<BIT_B1))</span>00125 <span class="comment"> SM_PORT |= (1<<B1);</span>00126 <span class="comment"> else</span>00127 <span class="comment"> SM_PORT &= ~(1<<B1);</span>00128 <span class="comment"></span>00129 <span class="comment"> if(temp&(1<<BIT_B2))</span>00130 <span class="comment"> SM_PORT |= (1<<B2);</span>00131 <span class="comment"> else</span>00132 <span class="comment"> SM_PORT &= ~(1<<B2);</span>00133 <span class="comment"> */</span>00134 00135 <span class="comment">// Output the fast way</span>00136 <a class="code" href="sm__driver_8h.html#a3">SM_PORT</a> |= ((temp<<4)&0xF0);00137 <a class="code" href="sm__driver_8h.html#a3">SM_PORT</a> &= ((temp<<4)|0x0F);00138 }</div></pre> </td> </tr></table><hr><h2>Variable Documentation</h2><a class="anchor" name="a5" doxytag="sm_driver.c::stepPosition" ></a><p><table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> <tr> <td class="mdRow"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td class="md" nowrap valign="top"> int <a class="el" href="sm__driver_8h.html#a9">stepPosition</a> = 0 </td> </tr> </table> </td> </tr></table><table cellspacing=5 cellpadding=0 border=0> <tr> <td> </td> <td><p>Position of stepper motor. <p><p>Definition at line <a class="el" href="sm__driver_8c-source.html#l00045">45</a> of file <a class="el" href="sm__driver_8c-source.html">sm_driver.c</a>.<p>Referenced by <a class="el" href="main_8c-source.html#l00062">main()</a>, and <a class="el" href="sm__driver_8c-source.html#l00066">sm_driver_StepCounter()</a>. </td> </tr></table><a class="anchor" name="a4" doxytag="sm_driver.c::steptab" ></a><p><table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> <tr> <td class="mdRow"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td class="md" nowrap valign="top"> __flash unsigned char <a class="el" href="sm__driver_8c.html#a4">steptab</a>[] </td> </tr> </table> </td> </tr></table><table cellspacing=5 cellpadding=0 border=0> <tr> <td> </td> <td><p><b>Initial value:</b><pre class="fragment"><div> {((1<<<a class="code" href="sm__driver_8c.html#a0">BIT_A1</a>) | (0<<<a class="code" href="sm__driver_8c.html#a1">BIT_A2</a>) | (0<<<a class="code" href="sm__driver_8c.html#a2">BIT_B1</a>) | (0<<<a class="code" href="sm__driver_8c.html#a3">BIT_B2</a>)), ((1<<<a class="code" href="sm__driver_8c.html#a0">BIT_A1</a>) | (0<<<a class="code" href="sm__driver_8c.html#a1">BIT_A2</a>) | (1<<<a class="code" href="sm__driver_8c.html#a2">BIT_B1</a>) | (0<<<a class="code" href="sm__driver_8c.html#a3">BIT_B2</a>)), ((0<<<a class="code" href="sm__driver_8c.html#a0">BIT_A1</a>) | (0<<<a class="code" href="sm__driver_8c.html#a1">BIT_A2</a>) | (1<<<a class="code" href="sm__driver_8c.html#a2">BIT_B1</a>) | (0<<<a class="code" href="sm__driver_8c.html#a3">BIT_B2</a>)), ((0<<<a class="code" href="sm__driver_8c.html#a0">BIT_A1</a>) | (1<<<a class="code" href="sm__driver_8c.html#a1">BIT_A2</a>) | (1<<<a class="code" href="sm__driver_8c.html#a2">BIT_B1</a>) | (0<<<a class="code" href="sm__driver_8c.html#a3">BIT_B2</a>)), ((0<<<a class="code" href="sm__driver_8c.html#a0">BIT_A1</a>) | (1<<<a class="code" href="sm__driver_8c.html#a1">BIT_A2</a>) | (0<<<a class="code" href="sm__driver_8c.html#a2">BIT_B1</a>) | (0<<<a class="code" href="sm__driver_8c.html#a3">BIT_B2</a>)), ((0<<<a class="code" href="sm__driver_8c.html#a0">BIT_A1</a>) | (1<<<a class="code" href="sm__driver_8c.html#a1">BIT_A2</a>) | (0<<<a class="code" href="sm__driver_8c.html#a2">BIT_B1</a>) | (1<<<a class="code" href="sm__driver_8c.html#a3">BIT_B2</a>)), ((0<<<a class="code" href="sm__driver_8c.html#a0">BIT_A1</a>) | (0<<<a class="code" href="sm__driver_8c.html#a1">BIT_A2</a>) | (0<<<a class="code" href="sm__driver_8c.html#a2">BIT_B1</a>) | (1<<<a class="code" href="sm__driver_8c.html#a3">BIT_B2</a>)), ((1<<<a class="code" href="sm__driver_8c.html#a0">BIT_A1</a>) | (0<<<a class="code" href="sm__driver_8c.html#a1">BIT_A2</a>) | (0<<<a class="code" href="sm__driver_8c.html#a2">BIT_B1</a>) | (1<<<a class="code" href="sm__driver_8c.html#a3">BIT_B2</a>))}</div></pre>Table with control signals for stepper motor. <p><p>Definition at line <a class="el" href="sm__driver_8c-source.html#l00035">35</a> of file <a class="el" href="sm__driver_8c-source.html">sm_driver.c</a>.<p>Referenced by <a class="el" href="sm__driver_8c-source.html#l00108">sm_driver_StepOutput()</a>. </td> </tr></table><hr size="1"><address style="align: right;"><small>Generated on Mon May 8 15:05:04 2006 for AVR446 - Linear speed control of stepper motor by<a href="http://www.doxygen.org/index.html"><img src="doxygen.png" alt="doxygen" align="middle" border=0 ></a> 1.3.7 </small></address></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -