📄 main_8c.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"><title>AVR221 - PID controller: main.c File Reference</title><link href="doxygen.css" rel="stylesheet" type="text/css"></head><body><!-- Generated by Doxygen 1.3.7 --><div class="qindex"><a class="qindex" href="main.html">Main Page</a> | <a class="qindex" href="annotated.html">Data Structures</a> | <a class="qindex" href="files.html">File List</a> | <a class="qindex" href="functions.html">Data Fields</a> | <a class="qindex" href="globals.html">Globals</a> | <a class="qindex" href="pages.html">Related Pages</a></div><h1>main.c File Reference</h1><hr><a name="_details"></a><h2>Detailed Description</h2>Example of use of general PID implementation for AVR. <p>Example of how to setup and use the general PID implementation in <a class="el" href="pid_8c.html">pid.c</a>.<p><ul><li>File: <a class="el" href="main_8c.html">main.c</a></li><li>Compiler: IAR EWAAVR 4.11A</li><li>Supported devices: All AVR devices can be used.</li><li>AppNote: AVR221 - Discrete PID controller</li></ul><p><dl compact><dt><b>Author:</b></dt><dd>Atmel Corporation: <a href="http://www.atmel.com">http://www.atmel.com</a> <br> Support email: <a href="mailto:avr@atmel.com">avr@atmel.com</a></dd></dl><dl compact><dt><b>Name</b></dt><dd>RELEASE_1_0 </dd></dl><dl compact><dt><b>Revision</b></dt><dd>1.1 </dd></dl><dl compact><dt><b>RCSfile</b></dt><dd><a class="el" href="main_8c.html">main.c</a>,v </dd></dl><dl compact><dt><b>Date</b></dt><dd>2006/02/16 11:46:13 </dd></dl><p>Definition in file <a class="el" href="main_8c-source.html">main.c</a>.<p><code>#include <inavr.h></code><br><code>#include <ioavr.h></code><br><code>#include "<a class="el" href="stdint_8h-source.html">stdint.h</a>"</code><br><code>#include "<a class="el" href="pid_8h-source.html">pid.h</a>"</code><br><p>Include dependency graph for main.c:<p><center><img src="main_8c__incl.png" border="0" usemap="#main.c_map" alt="Include dependency graph"></center><map name="main.c_map"><area href="stdint_8h.html" shape="rect" coords="189,81,253,108" alt=""><area href="pid_8h.html" shape="rect" coords="228,156,279,183" alt=""></map><p><a href="main_8c-source.html">Go to the source code of this file.</a><table border=0 cellpadding=0 cellspacing=0><tr><td></td></tr><tr><td colspan=2><br><h2>Data Structures</h2></td></tr><tr><td class="memItemLeft" nowrap align=right valign=top>struct </td><td class="memItemRight" valign=bottom><a class="el" href="structGLOBAL__FLAGS.html">GLOBAL_FLAGS</a></td></tr><tr><td class="mdescLeft"> </td><td class="mdescRight">Flags for status information. <a href="structGLOBAL__FLAGS.html#_details">More...</a><br><br></td></tr><tr><td colspan=2><br><h2>Defines</h2></td></tr><tr><td class="memItemLeft" nowrap align=right valign=top>#define </td><td class="memItemRight" valign=bottom><a class="el" href="main_8c.html#a2">K_D</a> 0.00</td></tr><tr><td class="memItemLeft" nowrap align=right valign=top>#define </td><td class="memItemRight" valign=bottom><a class="el" href="main_8c.html#a1">K_I</a> 0.00</td></tr><tr><td class="memItemLeft" nowrap align=right valign=top>#define </td><td class="memItemRight" valign=bottom><a class="el" href="main_8c.html#a0">K_P</a> 1.00</td></tr><tr><td class="memItemLeft" nowrap align=right valign=top>#define </td><td class="memItemRight" valign=bottom><a class="el" href="main_8c.html#a3">TIME_INTERVAL</a> 157</td></tr><tr><td colspan=2><br><h2>Functions</h2></td></tr><tr><td class="memItemLeft" nowrap align=right valign=top><a class="el" href="stdint_8h.html#a57">int16_t</a> </td><td class="memItemRight" valign=bottom><a class="el" href="main_8c.html#a9">Get_Measurement</a> (void)</td></tr><tr><td class="mdescLeft"> </td><td class="mdescRight">Read system process value. <a href="#a9"></a><br><br></td></tr><tr><td class="memItemLeft" nowrap align=right valign=top><a class="el" href="stdint_8h.html#a57">int16_t</a> </td><td class="memItemRight" valign=bottom><a class="el" href="main_8c.html#a8">Get_Reference</a> (void)</td></tr><tr><td class="mdescLeft"> </td><td class="mdescRight">Read reference value. <a href="#a8"></a><br><br></td></tr><tr><td class="memItemLeft" nowrap align=right valign=top>void </td><td class="memItemRight" valign=bottom><a class="el" href="main_8c.html#a7">Init</a> (void)</td></tr><tr><td class="mdescLeft"> </td><td class="mdescRight">Init of PID controller demo. <a href="#a7"></a><br><br></td></tr><tr><td class="memItemLeft" nowrap align=right valign=top>void </td><td class="memItemRight" valign=bottom><a class="el" href="main_8c.html#a11">main</a> (void)</td></tr><tr><td class="mdescLeft"> </td><td class="mdescRight">Demo of PID controller. <a href="#a11"></a><br><br></td></tr><tr><td class="memItemLeft" nowrap align=right valign=top>void </td><td class="memItemRight" valign=bottom><a class="el" href="main_8c.html#a10">Set_Input</a> (<a class="el" href="stdint_8h.html#a57">int16_t</a> inputValue)</td></tr><tr><td class="mdescLeft"> </td><td class="mdescRight">Set control input to system. <a href="#a10"></a><br><br></td></tr><tr><td class="memItemLeft" nowrap align=right valign=top>__interrupt void </td><td class="memItemRight" valign=bottom><a class="el" href="main_8c.html#a6">TIMER0_OVF_ISR</a> (void)</td></tr><tr><td class="mdescLeft"> </td><td class="mdescRight">Timer interrupt to control the sampling interval. <a href="#a6"></a><br><br></td></tr><tr><td colspan=2><br><h2>Variables</h2></td></tr><tr><td class="memItemLeft" nowrap align=right valign=top><a class="el" href="structGLOBAL__FLAGS.html">GLOBAL_FLAGS</a> </td><td class="memItemRight" valign=bottom><a class="el" href="main_8c.html#a4">gFlags</a></td></tr><tr><td class="mdescLeft"> </td><td class="mdescRight">Flags for status information. <a href="#a4"></a><br><br></td></tr><tr><td class="memItemLeft" nowrap align=right valign=top><a class="el" href="structPID__DATA.html">PID_DATA</a> </td><td class="memItemRight" valign=bottom><a class="el" href="main_8c.html#a5">pidData</a></td></tr><tr><td class="mdescLeft"> </td><td class="mdescRight">Parameters for regulator. <a href="#a5"></a><br><br></td></tr></table><hr><h2>Define Documentation</h2><a class="anchor" name="a2" doxytag="main.c::K_D" ></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"> #define K_D 0.00 </td> </tr> </table> </td> </tr></table><table cellspacing=5 cellpadding=0 border=0> <tr> <td> </td> <td><p><dl compact><dt><b><a class="el" href="todo.html#_todo000003">Todo:</a></b></dt><dd></dd></dl><p>Definition at line <a class="el" href="main_8c-source.html#l00037">37</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#l00075">Init()</a>. </td> </tr></table><a class="anchor" name="a1" doxytag="main.c::K_I" ></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"> #define K_I 0.00 </td> </tr> </table> </td> </tr></table><table cellspacing=5 cellpadding=0 border=0> <tr> <td> </td> <td><p><dl compact><dt><b><a class="el" href="todo.html#_todo000002">Todo:</a></b></dt><dd></dd></dl><p>Definition at line <a class="el" href="main_8c-source.html#l00035">35</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#l00075">Init()</a>. </td> </tr></table><a class="anchor" name="a0" doxytag="main.c::K_P" ></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"> #define K_P 1.00 </td> </tr> </table> </td> </tr></table><table cellspacing=5 cellpadding=0 border=0> <tr> <td> </td> <td><p>The K_P, K_I and K_D values (P, I and D gains) need to be modified to adapt to the application at hand<p><dl compact><dt><b><a class="el" href="todo.html#_todo000001">Todo:</a></b></dt><dd></dd></dl><p>Definition at line <a class="el" href="main_8c-source.html#l00033">33</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#l00075">Init()</a>. </td> </tr></table><a class="anchor" name="a3" doxytag="main.c::TIME_INTERVAL" ></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"> #define TIME_INTERVAL 157 </td> </tr> </table> </td> </tr></table><table cellspacing=5 cellpadding=0 border=0> <tr> <td> </td> <td><p>Specify the desired PID sample time interval With a 8-bit counter (255 cylces to overflow), the time interval value is calculated as follows: TIME_INTERVAL = ( desired interval [sec] ) * ( frequency [Hz] ) / 255<p><dl compact><dt><b><a class="el" href="todo.html#_todo000004">Todo:</a></b></dt><dd></dd></dl><p>Definition at line <a class="el" href="main_8c-source.html#l00057">57</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#l00062">TIMER0_OVF_ISR()</a>. </td> </tr></table><hr><h2>Function Documentation</h2><a class="anchor" name="a9" doxytag="main.c::Get_Measurement" ></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"> <a class="el" href="stdint_8h.html#a57">int16_t</a> Get_Measurement </td> <td class="md" valign="top">( </td> <td class="md" nowrap valign="top">void </td> <td class="mdname1" valign="top" nowrap> </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>Read system process value. <p>This function must return the measured data <p>Definition at line <a class="el" href="main_8c-source.html#l00099">99</a> of file <a class="el" href="main_8c-source.html">main.c</a>.<p>References <a class="el" href="stdint_8h-source.html#l00028">int16_t</a>.<p>Referenced by <a class="el" href="main_8c-source.html#l00117">main()</a>.<p><pre class="fragment"><div>00100 {00101 <span class="keywordflow">return</span> 4;00102 }</div></pre> </td> </tr></table><a class="anchor" name="a8" doxytag="main.c::Get_Reference" ></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"> <a class="el" href="stdint_8h.html#a57">int16_t</a> Get_Reference </td> <td class="md" valign="top">( </td> <td class="md" nowrap valign="top">void </td> <td class="mdname1" valign="top" nowrap> </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>Read reference value. <p>This function must return the reference value. May be constant or varying <p>Definition at line <a class="el" href="main_8c-source.html#l00090">90</a> of file <a class="el" href="main_8c-source.html">main.c</a>.<p>References <a class="el" href="stdint_8h-source.html#l00028">int16_t</a>.<p>Referenced by <a class="el" href="main_8c-source.html#l00117">main()</a>.<p><pre class="fragment"><div>00091 {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -