版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
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. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- GB/T 46794-2025化工园区气体防护站建设运行指南
- 2025年兴业银行珠海分行社会招聘备考题库及参考答案详解一套
- 2026年建筑材料标准化合同
- 2026年建筑质量保证金合同
- 2025年达州银行股份有限公司社会招聘备考题库带答案详解
- 2026年药品含量测定方法学验证合同
- 2025年广西工艺美术研究院有限公司所属企业广西绢麻纺织科学研究所有限公司招聘备考题库及参考答案详解
- 急性乳腺炎沟通记录
- 2025年安全生产监管人员考试试题及答案(完整版)
- 2025年济南市检察机关公开招聘聘用制书记员25人备考题库及参考答案详解1套
- 墙壁维护施工方案(3篇)
- 人工智能安全风险测评白皮书(2025年)
- 2025下半年贵州遵义市第一人民医院招聘事业单位65人笔试备考重点试题及答案解析
- 围麻醉期应激反应的调控策略
- 2025年外贸实习合同协议
- 集成电路封装测试厂建设项目可行性研究报告
- 医院服务礼仪培训
- 亚朵酒店管理分析
- 弘历指标源码6个(仅提供源码)
- 新产品开发项目进度计划表
- 设计公司生产管理办法
评论
0/150
提交评论