北方民族大学计算机控制课设按要求设置温度控制系统硬件仿真流程图程序_第1页
北方民族大学计算机控制课设按要求设置温度控制系统硬件仿真流程图程序_第2页
北方民族大学计算机控制课设按要求设置温度控制系统硬件仿真流程图程序_第3页
北方民族大学计算机控制课设按要求设置温度控制系统硬件仿真流程图程序_第4页
北方民族大学计算机控制课设按要求设置温度控制系统硬件仿真流程图程序_第5页
已阅读5页,还剩36页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、运算机掌握硬件图终极版仿真程序 主程序流程图 中断服务子程序流程图#include #include #include #include struct PID spid;/ PID Control structure unsigned int rout;/ PID response output unsigned int rin;/ PID feedbackinput sbit A0=P00; sbit A1=P01; sbit WR=P02; sbit RD=P03; sbit A0_2=P30; sbit A1_2=P31; sbit WR_2=P36; sbit RD_2=P37; un

2、signed char flag,flag_1=0;/标志未 初始化unsigned char high_time,low_time,count=0;/ 占空比 调剂参数unsigned char set_temper;/ 设定温 度unsigned char temper;/ 测量的温度 unsigned char i; unsigned char j=0; unsigned int s; /*1602 液晶初始化 */ uchar code table=Temper; uchar num; uchar num_cal; sbit rs=P15; / 数据命令挑选sbit rw=P16; /

3、 读写 挑选sbit en=P17; / 使能端sbit lcd_le=P34; sbit lcd_8253=P35; void delayuchar z / 延时 uchar x,y; forx=z;x0;x- fory=110;y0;y-; void lcd_comuchar com / 命令函数 rs=0; rw=0; en=0; lcd_8253=0; lcd_le=1; P0=com; lcd_8253=1; lcd_le=0; delay5; en=1; delay5; en=0; void lcd_datauchar date / 数据 rs=1; rw=0; en=0; lcd

4、_8253=0; lcd_le=1; P0=date; lcd_8253=1; lcd_le=0; delay5; en=1; delay5; en=0; void init_lcd / 初始化 lcd_com0 x38; lcd_com0 x0f; lcd_com0 x06; lcd_com0 x80; lcd_com0 x01; *LCD显示子程序*/ void display unsigned char disp_num6; unsigned int k,k1; k=high_time; k=k%1000; k1=k/100;/ 得到百位温度值 ifk1=1 disp_num0=0; e

5、lse disp_num0=0 x60; k=k%100;/得到十位的温度值 disp_num1=numberk/10; disp_num2=numberk%10; k=temper; k=k%100;/得到个位的温度值 disp_num3=numberk/10; disp_num4=numberk%10+1; disp_num5=numbers/10; disp_1disp_num; fornum=0;numSetPoint-NextPoint;/运算 出偏差pp-SumError+=Error;/积分dError=pp-LastError-pp-PrevError;/ 当前微分 pp-Pr

6、evError=pp-LastError; pp-LastError=Error; returnpp-Proportion*Error / 比例项+pp-Integral*pp-SumError / 积分项 +pp-Derinative*dError; / 微分项 compare_temper unsigned char i; ifset_tempertemper/ 判断温度 Ifset_temper-temper1/ 判定温差是否大于 1 度 high_time=100;low_time=0; else fori=0;i10;i+ get_tember;/ 得 到当前温度rin=s;/ 读输

7、入 rout=PIDCalc&spin,rin;/输 出 pid 运算结果 ifhigh_time=100 high_time=unsigned charrout/800; else high_time=100; low_time=100-high_time; else ifset_temper0 high_time=0; low_time=100; else fori=0;i10;i+ get_temper; rin=s;/ 读输入rout=PIDCalc&spin,rin;/ 输出 pid 运算结果 ifhigh_time100 high_time=unsigned char rout/1

8、0000; else high_time=0; low_time=100-high_time; /* T1 中断服务子程序 * * */ void serve_T1interrupt 1 using 1 ifnum_cal=20 num_cal=0; get_temper;/ 猎取温度;compare_temper;/Smith 算法及温度处理RD=1; WR=0; A0=0; A1=0; P1=rout;/ 更新 8253 脉冲 TH0=0 x2f; TL0=0 xe0; else=num_cal+; * * */ 主程序* * */ main unsigned char z; unsigned char a,b,flag_2=1,count1=0; unsigned char phil=2,0 xce,0 x60,0 x1c,2; TMOD=0 x21; TH0=0 x2f; TL0=0 x40; SCON=0 x50; PCON=0 x00; TH1=0 xfd; TL1=0 xfd; PS=1; EA=1; EX1=0; ET0=1; ES=1; TR0=1; TR1=1; high_time=50; low_time=50; / 高电平常间 / 低电平常间init_lcd; / 液晶初始化8253_init; /8253 初始化PIDInit&spid; /

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论