找回密码
 注册
查看: 327|回复: 1
打印 上一主题 下一主题

C51的PID算法

[复制链接]

该用户从未签到

跳转到指定楼层
1#
发表于 2020-1-7 10:11 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

EDA365欢迎您登录!

您需要 登录 才可以下载或查看,没有帐号?注册

x
//PID算法温控C语言2008-08-17 18:58
6 Q) A* y# q. d#include<w77e58.h>
4 O! O  ^  w/ }, O% d; i6 q5 j#include<intrins.h>   C2 u" E% a: K0 A. x7 I3 Z
#include<math.h> 5 Y; D% u, u4 ?( s  t) h. x
#include<string.h>
5 ^. s8 E- g6 B3 P4 h/ {9 _struct PID {
! |6 n- k0 G  {0 h( j' w; dunsigned int SetPoint; // 设定目标 Desired Value 7 A8 i. c' y8 X5 P9 l, l# x
unsigned int Proportion; // 比例常数 Proportional Const ( s1 u- b% O! d9 ^) ]; j
unsigned int Integral; // 积分常数 Integral Const $ P# j3 L- i) \4 P
unsigned int Derivative; // 微分常数 Derivative Const
' o! v" M# m+ e. s0 Wunsigned int LastError; // Error[-1] 7 p  D3 H, Y* P  |6 ]8 k
unsigned int PrevError; // Error[-2]
2 X; n5 E  Q" l3 f3 H: Yunsigned int SumError; // Sums of Errors : r& H+ f# X1 v5 q- W; P
};
* {$ b  Z9 v0 wstruct PID spid; // PID Control Structure 8 e% d; u3 U1 |& ^8 O1 |! M* {
unsigned int rout; // PID Response (Output)
+ Z. h7 K+ k' \unsigned int rin; // PID Feedback (Input) 1 |# ]# O3 ]/ n# q) X1 v/ {
sbit data1=P1^0;
5 M" {# _: }( y$ w4 p' Ksbit clk=P1^1;
5 C/ p/ r1 e+ A6 b5 }, o/ Lsbit plus=P2^0;
* n; H8 x/ e' W0 x) S2 h2 l4 Tsbit subs=P2^1;
5 j/ E, X; ~1 ^9 S: M/ Qsbit stop=P2^2; 8 `$ ~* M0 j; m# o1 N
sbit output=P3^4; 1 m; }+ S. x" m( ^1 c1 s- w$ z# M
sbit DQ=P3^3; ' V3 \4 b! t/ i
unsigned char flag,flag_1=0; ) x6 A/ `  b8 R8 J" n1 v
unsigned char high_time,low_time,count=0;//占空比调节参数
& w: w+ W/ Y% B. O& [3 `unsigned char set_temper=35;
' I( A& S* W9 K  }; t( F$ nunsigned char temper;
7 U: p4 X2 @  c# |; N' O8 \unsigned char i; ) R6 V& }( R# g; |; \1 X
unsigned char j=0; 1 w' a8 n; ^8 [) f0 L; L
unsigned int s;
$ ?3 ^2 p) a4 v! a' h* ~/*********************************************************** & R  W/ ^8 b6 V! s* r/ i! o/ \
游客,如果您要查看本帖隐藏内容请回复
6 A  ?- q4 X+ Q7 g

4 b  v( Z8 |6 J# T" O
  • TA的每日心情

    2019-11-19 15:55
  • 签到天数: 1 天

    [LV.1]初来乍到

    2#
    发表于 2020-1-7 17:56 | 只看该作者
    C51的PID算法,学习了
    您需要登录后才可以回帖 登录 | 注册

    本版积分规则

    关闭

    推荐内容上一条 /1 下一条

    EDA365公众号

    关于我们|手机版|EDA365电子论坛网 ( 粤ICP备18020198号-1 )

    GMT+8, 2025-5-30 19:42 , Processed in 0.078125 second(s), 26 queries , Gzip On.

    深圳市墨知创新科技有限公司

    地址:深圳市南山区科技生态园2栋A座805 电话:19926409050

    快速回复 返回顶部 返回列表