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

📄 比较典型的pid算法控制程序源代码.htm

📁 典型的PID算法
💻 HTM
📖 第 1 页 / 共 2 页
字号:
    <TD colSpan=2>
      <TABLE class=main_title_760 style="WORD-BREAK: break-all" cellSpacing=0 
      cellPadding=0 width="100%" border=0>
        <TBODY>
        <TR>
          <TD vAlign=center width="3%"><IMG height=14 
            src="比较典型的PID算法控制程序源代码.files/arrow.gif" width=11 align=absMiddle></TD>
          <TD width="66%">比较典型的PID算法控制程序源代码</TD>
          <TD width="18%">&nbsp;&nbsp;&nbsp;<FONT 
            color=red>热</FONT>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<FONT 
            color=#009900></FONT></TD>
          <TD align=right width="13%">【字体:<A class=top_UserLogin 
            href="javascript:fontZoomA();">小</A> <A class=top_UserLogin 
            href="javascript:fontZoomB();">大</A>】</TD></TR></TBODY></TABLE></TD></TR>
  <TR vAlign=center align=middle>
    <TD class=main_ArticleTitle style="WORD-BREAK: break-all" colSpan=2 
    height=50>比较典型的PID算法控制程序源代码</TD></TR>
  <TR vAlign=center align=middle>
    <TD class=main_ArticleSubheading style="WORD-BREAK: break-all" colSpan=2 
    height=20></TD></TR>
  <TR class=left_tdbgall align=middle>
    <TD 
      colSpan=2>作者:未知&nbsp;&nbsp;&nbsp;&nbsp;文章来源:未知&nbsp;&nbsp;&nbsp;&nbsp;点击数:
      <SCRIPT language=javascript 
      src="比较典型的PID算法控制程序源代码.files/GetHits.htm"></SCRIPT>
      &nbsp;&nbsp;&nbsp;&nbsp;更新时间:2006-4-24</TD></TR>
  <TR>
    <TD class=main_tdbg_760 id=fontzoom style="WORD-BREAK: break-all" vAlign=top 
    colSpan=2 height=300>
      <TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
        <TBODY>
        <TR>
          <TD background=""></TD>
          <TD align=middle>
            <TABLE class=tf width="98%" align=center border=0>
              <TBODY>
              <TR>
                <TD class=bw width="100%"><FONT class=htd id=font_word 
                  style="FONT-SIZE: 14px; FONT-FAMILY: 宋体, Verdana, Arial, Helvetica, sans-serif">比较典型的PID处理程序<BR>[日期:2005-2-1]&nbsp;来源:21ICbbs&nbsp;作者:lookuper&nbsp;[字体:大中小]<BR>/*====================================================================================================<BR>这是一个比较典型的PID处理程序,在使用单片机作为控制cpu时,请稍作简化,具体的PID参数必须由具体对象通过实验确定。由于单片机的处理速度和ram资源的限制,一般不采用浮点数运算,而将所有参数全部用整数,运算<BR>到最后再除以一个2的N次方数据(相当于移位),作类似定点数运算,可大大提高运算速度,根据控制精度的不同要求,当精度要求很高时,注意保留移位引起的“余数”,做好余数补偿。这个程序只是一般常用pid算法的基本架构,没有包含输入输出处理部分。<BR>=====================================================================================================*/<BR>#include<BR>#include<BR>/*====================================================================================================<BR>PID&nbsp;Function<BR>The&nbsp;PID&nbsp;(比例、积分、微分)&nbsp;function&nbsp;is&nbsp;used&nbsp;in&nbsp;mainly<BR>control&nbsp;applications.&nbsp;PIDCalc&nbsp;performs&nbsp;one&nbsp;iteration&nbsp;of&nbsp;the&nbsp;PID<BR>algorithm.<BR>While&nbsp;the&nbsp;PID&nbsp;function&nbsp;works,&nbsp;main&nbsp;is&nbsp;just&nbsp;a&nbsp;dummy&nbsp;program&nbsp;showing<BR>a&nbsp;typical&nbsp;usage.<BR>=====================================================================================================*/<BR>typedef&nbsp;struct&nbsp;PID&nbsp;{<BR>double&nbsp;SetPoint;&nbsp;//&nbsp;设定目标Desired&nbsp;<I>value</I><BR>double&nbsp;Proportion;&nbsp;//&nbsp;比例常数Proportional&nbsp;Const<BR>double&nbsp;Integral;&nbsp;//&nbsp;积分常数Integral&nbsp;Const<BR>double&nbsp;Derivative;&nbsp;//&nbsp;微分常数Derivative&nbsp;Const<BR>double&nbsp;LastError;&nbsp;//&nbsp;Error[-1]<BR><BR>double&nbsp;PrevError;&nbsp;//&nbsp;Error[-2]<BR>double&nbsp;SumError;&nbsp;//&nbsp;Sums&nbsp;of&nbsp;Errors<BR>}&nbsp;PID;<BR>/*====================================================================================================<BR>PID计算部分<BR>=====================================================================================================*/<BR>double&nbsp;PIDCalc(&nbsp;PID&nbsp;*pp,&nbsp;double&nbsp;NextPoint&nbsp;)<BR>{<BR>double&nbsp;dError,<BR>Error;<BR>Error&nbsp;=&nbsp;pp-&gt;SetPoint&nbsp;-&nbsp;NextPoint;&nbsp;//&nbsp;偏差<BR>pp-&gt;SumError&nbsp;+=&nbsp;Error;&nbsp;//&nbsp;积分<BR>dError&nbsp;=&nbsp;pp-&gt;LastError&nbsp;-&nbsp;pp-&gt;PrevError;&nbsp;//&nbsp;当前微分<BR>pp-&gt;PrevError&nbsp;=&nbsp;pp-&gt;LastError;<BR>pp-&gt;LastError&nbsp;=&nbsp;Error;<BR>return&nbsp;(pp-&gt;Proportion&nbsp;*&nbsp;Error&nbsp;//&nbsp;比例项<BR>+&nbsp;pp-&gt;Integral&nbsp;*&nbsp;pp-&gt;SumError&nbsp;//&nbsp;积分项<BR>+&nbsp;pp-&gt;Derivative&nbsp;*&nbsp;dError&nbsp;//&nbsp;微分项<BR>);<BR>}<BR>/*====================================================================================================<BR>Initialize&nbsp;PID&nbsp;Structure<BR>=====================================================================================================*/<BR>void&nbsp;PIDInit&nbsp;(PID&nbsp;*pp)<BR>{<BR>memset&nbsp;(&nbsp;pp,0,sizeof(PID));<BR>}<BR>/*====================================================================================================<BR>Main&nbsp;Program<BR>=====================================================================================================*<BR>double&nbsp;sensor&nbsp;(void)&nbsp;//&nbsp;Dummy&nbsp;Sensor&nbsp;Function<BR>{<BR>return&nbsp;100.0;<BR>}<BR>void&nbsp;actuator(double&nbsp;rDelta)&nbsp;//&nbsp;Dummy&nbsp;Actuator&nbsp;Function<BR>{}<BR>void&nbsp;main(void)<BR>{<BR>PID&nbsp;sPID;&nbsp;//&nbsp;PID&nbsp;Control&nbsp;Structure<BR>double&nbsp;rOut;&nbsp;//&nbsp;PID&nbsp;Response&nbsp;(Output)<BR>double&nbsp;rIn;&nbsp;//&nbsp;PID&nbsp;Feedback&nbsp;(Input)<BR>PIDInit&nbsp;(&nbsp;&amp;sPID&nbsp;);&nbsp;//&nbsp;Initialize&nbsp;Structure<BR>sPID.Proportion&nbsp;=&nbsp;0.5;&nbsp;//&nbsp;Set&nbsp;PID&nbsp;Coefficients<BR>sPID.Integral&nbsp;=&nbsp;0.5;<BR>sPID.Derivative&nbsp;=&nbsp;0.0;<BR>sPID.SetPoint&nbsp;=&nbsp;100.0;&nbsp;//&nbsp;Set&nbsp;PID&nbsp;Setpoint<BR>for&nbsp;(;;)&nbsp;{&nbsp;//&nbsp;Mock&nbsp;Up&nbsp;of&nbsp;PID&nbsp;Processing<BR>rIn&nbsp;=&nbsp;sensor&nbsp;();&nbsp;//&nbsp;Read&nbsp;Input<BR>rOut&nbsp;=&nbsp;PIDCalc&nbsp;(&nbsp;&amp;sPID,rIn&nbsp;);&nbsp;//&nbsp;Perform&nbsp;PID&nbsp;Interation<BR>actuator&nbsp;(&nbsp;rOut&nbsp;);&nbsp;//&nbsp;Effect&nbsp;Needed&nbsp;Changes<BR>}<BR></FONT></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE></TD></TR>
  <TR>
    <TD class=left_tdbgall align=right colSpan=2>文章录入:<A 
      href="http://www.91tech.net/UserInfo.asp?UserName=Polylove">Polylove</A>&nbsp;&nbsp;&nbsp;&nbsp;责任编辑:Polylove&nbsp; 
    </TD></TR>
  <TR>
    <TD width=5></TD>
    <TD width=752>
      <LI>上一篇文章: <A 
      title="文章标题:增量式PID控制算法程序&#13;&#10;作    者:未知&#13;&#10;更新时间:2006-4-24 10:42:00" 
      href="http://www.91tech.net/Article/HardTech/ControlTech/200604/3783.html">增量式PID控制算法程序</A><BR>
      <LI>下一篇文章: <A 
      title="文章标题:标准的PID处理例程&#13;&#10;作    者:未知&#13;&#10;更新时间:2006-4-24 11:27:00" 
      href="http://www.91tech.net/Article/HardTech/ControlTech/200604/3785.html">标准的PID处理例程</A></LI></TD></TR>
  <TR class=left_tdbgall align=right>
    <TD colSpan=2>【<A 
      href="http://www.91tech.net/Article/Comment.asp?ArticleID=3784" 
      target=_blank>发表评论</A>】【<A 
      href="http://www.91tech.net/Article/SendMail.asp?ArticleID=3784" 
      target=_blank>告诉好友</A>】【<A 
      href="http://www.91tech.net/Article/Print.asp?ArticleID=3784" 
      target=_blank>打印此文</A>】【<A href="javascript:window.close();">关闭窗口</A>】 
  </TD></TR></TBODY></TABLE>
<TABLE class=center_tdbgall cellSpacing=0 cellPadding=0 width=760 align=center 
border=0>
  <TBODY>
  <TR>
    <TD class=main_shadow></TD></TR></TBODY></TABLE><!--文章显示代码结束--><!--最新热点、最新推荐、相关文章代码开始-->
<TABLE class=center_tdbgall style="WORD-BREAK: break-all" cellSpacing=0 
cellPadding=0 width=760 align=center border=0>
  <TBODY>
  <TR>
    <TD class=main_title_282 
      width="33%"><B>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;最新热点</B></TD>
    <TD width=5 rowSpan=2></TD>
    <TD class=main_title_282 
      width="33%"><B>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;最新推荐</B></TD>
    <TD width=5 rowSpan=2></TD>
    <TD class=main_title_282 
      width="33%"><B>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;相关文章</B></TD></TR>
  <TR>
    <TD class=main_tdbg_760 vAlign=top height=100>
      <SCRIPT language=javascript 
      src="比较典型的PID算法控制程序源代码.files/Article_Hot3.js"></SCRIPT>
    </TD>
    <TD class=main_tdbg_760 vAlign=top width="33%">
      <SCRIPT language=javascript 
      src="比较典型的PID算法控制程序源代码.files/Article_Elite3.js"></SCRIPT>
    </TD>
    <TD class=main_tdbg_760 vAlign=top width="33%">
      <LI><A 
      title="文章标题:一种新的自适应PID控制算法&#13;&#10;作    者:佚名&#13;&#10;更新时间:2006-6-28 16:21:00" 
      href="http://www.91tech.net/Article/SoftTech/TheoryTech/200606/3992.html">一种新的自适应PID控制算法</A><BR>
      <LI><A 
      title="文章标题:标准的PID处理例程&#13;&#10;作    者:未知&#13;&#10;更新时间:2006-4-24 11:27:00" 
      href="http://www.91tech.net/Article/HardTech/ControlTech/200604/3785.html">标准的PID处理例程</A><BR>
      <LI><A 
      title="文章标题:增量式PID控制算法程序&#13;&#10;作    者:未知&#13;&#10;更新时间:2006-4-24 10:42:00" 
      href="http://www.91tech.net/Article/HardTech/ControlTech/200604/3783.html">增量式PID控制算法程序</A><BR>
      <LI><A 
      title="文章标题:积分分离PID控制算法程序&#13;&#10;作    者:未知&#13;&#10;更新时间:2006-4-24 10:40:00" 
      href="http://www.91tech.net/Article/HardTech/ControlTech/200604/3782.html">积分分离PID控制算法程序</A><BR>
      <LI><A 
      title="文章标题:典型的PID处理程序(C51)(可改为061的)&#13;&#10;作    者:未知&#13;&#10;更新时间:2006-4-24 10:34:00" 
      href="http://www.91tech.net/Article/HardTech/ControlTech/200604/3781.html">典型的PID处理程序(C51)(…</A><BR>
      <LI><A 
      title="文章标题:PID控制C源程序&#13;&#10;作    者:未知&#13;&#10;更新时间:2006-4-24 10:21:00" 
      href="http://www.91tech.net/Article/HardTech/ControlTech/200604/3780.html">PID控制C源程序</A><BR></LI></TD></TR></TBODY></TABLE>
<TABLE class=center_tdbgall cellSpacing=0 cellPadding=0 width=760 align=center 
border=0>
  <TBODY>
  <TR>
    <TD class=main_shadow></TD></TR></TBODY></TABLE><!--最新热点、最新推荐、相关文章代码结束--><!--网友评论代码开始-->
<TABLE class=center_tdbgall style="WORD-BREAK: break-all" cellSpacing=0 
cellPadding=0 width=760 align=center border=0>
  <TBODY>
  <TR>
    <TD class=left_tdbgall height=25><STRONG>&nbsp;<IMG height=16 
      src="比较典型的PID算法控制程序源代码.files/TEAM.gif" width=16 align=absMiddle> 
      网友评论:</STRONG>(只显示最新10条。评论内容只代表网友观点,与本站立场无关!)</TD></TR>
  <TR>
    <TD>
      <SCRIPT language=javascript 
      src="比较典型的PID算法控制程序源代码.files/Comment.htm"></SCRIPT>
    </TD></TR></TBODY></TABLE>
<TABLE class=center_tdbgall cellSpacing=0 cellPadding=0 width=760 align=center 
border=0>
  <TBODY>
  <TR>
    <TD class=main_shadow></TD></TR></TBODY></TABLE><!--网友评论代码结束--><!-- ********网页中部代码结束******** --><!-- ********网页底部代码开始******** -->
<TABLE class=Bottom_tdbgall style="WORD-BREAK: break-all" cellSpacing=0 
cellPadding=0 width=760 align=center border=0>
  <TBODY>
  <TR align=middle>
    <TD class=Bottom_Adminlogo colSpan=2>| <A class=Bottom 
      onclick="this.style.behavior='url(#default#homepage)';this.setHomePage('http://www.91tech.net');" 
      href="http://www.91tech.net/Article/HardTech/ControlTech/200604/3784.html#">设为首页</A> 
      | <A class=Bottom 
      href="javascript:window.external.addFavorite('http://www.91tech.net','中国软硬件结合技术网');">加入收藏</A> 
      | <A class=Bottom href="mailto:polylove@126.com">联系站长</A> | <A 
      class=Bottom href="http://www.91tech.net/FriendSite/Index.asp" 
      target=_blank>友情链接</A> | <A class=Bottom 
      href="http://www.91tech.net/Copyright.asp" target=_blank>版权申明</A> | <A 
      class=Bottom href="http://www.91tech.net/Admin/Admin_Index.asp" 
      target=_blank>管理登录</A>&nbsp;|&nbsp;</TD></TR>
  <TR class=Bottom_Copyright>
    <TD width="20%"><IMG height=55 
      src="比较典型的PID算法控制程序源代码.files/powerease_logo.gif" width=165></TD>
    <TD width="80%">Copyright &copy;2004 - 2006 中国软硬件结合技术网 91tech.net 91tech.cn 
      91tech.com 站长:<A href="mailto:polylove@126.com">Polylove</A> 
</TD></TR></TBODY></TABLE><!-- ********网页底部代码结束******** --></BODY></HTML>

⌨️ 快捷键说明

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