收藏 分销(赏)

毕业设计方案基于ATC单片机的发动机转速电控系统程序设计及仿真.doc

上传人:二*** 文档编号:4556078 上传时间:2024-09-29 格式:DOC 页数:36 大小:753.04KB
下载 相关 举报
毕业设计方案基于ATC单片机的发动机转速电控系统程序设计及仿真.doc_第1页
第1页 / 共36页
亲,该文档总共36页,到这儿已超出免费预览范围,如果喜欢就下载吧!
资源描述

1、目 录摘要 21 引言 32 方案设计 42.1 系统设计方案论证 4 2.1.1第一方案 42.1.2 第二方案 42.2第二方案总体设计框图 43 系统硬件部分 53.1主控芯片 53.2 滤波电路及LM324芯片 73.3 显示设备 83.4 控制实施机构94系统软件设计104.1 设计思绪104.2 程序步骤图105 系统仿真和调试125.1 Proteus仿真软件125.2 仿真图建立125.3 仿真调试结果14结论 18致谢 19参考文件 20附录A 原理图 21附录B 程序编译图 22附录C 仿真图 23附录D 程序代码 25摘 要现在汽车安全性很关键,发动机转速高低也在安全范围

2、之列。本文介绍用AT89C52单片机设计制作发动机转速电控系统,仅需AT89C52最小系统,外接一个LCD1602、滤波电路和作为控制机构电动机。这么就能够对发动机转速进行检测并对应控制电机运作,并将转速显示在LCD1602上。关键词:转速 单片机 显示 控制 LCD16021 引 言 1.1 问题提出 现在汽车上转速表显示过于复杂,而且处于安全考虑,要用单片机知识及常见元器件搭建出能检测汽车发动机或其它装置转速,并对应进行控制将其显示在监视员视野之内,这么将降低因发动机转速而造成人身危害。1.2 任务和分析 本文是应用MCS-51单片机原理和控制理论设计发动机转速检测并控制硬件电路,利用C语

3、言进行程序设计。经过检测单片机外部中止触发信号来开启内部定时器定时两个信号之间时间,所得时间在程序中进行加权滤波、转换,最终将转速在LCD上显示,以此提醒驾驶人员注意发动机转速。2 方案设计2.1 发动机转速电控系统设计方案论证2.1.1 第一方案本设计程序采取定时计数器0定时一段时间,在此段时间内设置定时器计数1对外部进行计数,最终将所得个数进行滤波、转换,最终在数码管上显示。不过,这种方案采取数码管显示,较为复杂。第二方案和方案一相比,本方案将转速在LCD上显示并对应控制其实施机构。这种设计显示部分很简练,系统稳定性较高。2.2 第二方案总体设计框图本设计采取89C52作为主控芯片,经过滤

4、波电路处理输入信号,LCD作为输出设备显示转速。其中P3.2作为信号输入,P1口用作LCD数据线,P2.5、P2.6、P2.7口用作LCD控制信号。设计框图图一所表示。图2.1 发动机转速电控系统设计框图3 系统硬件介绍3.1 主控芯片设计中所采取主控芯片为AT89C52。因其价格廉价,在市场上已经很成熟,各个方面全部能够满足设计要求故选择它。其采取标准双列直插式引脚DIP-40大规模集成电路封装。它引脚排列以下图3.1所表示图3.1AT89C52引脚排列引脚介绍:VCC:供电电压。GND:接地。P0口:P0口为一个8位漏级开路双向I/O口,每脚可吸收8TTL门电流。当P1口管脚第一次写1时,

5、被定义为高阻输入。P0能够用于外部程序数据存放器,它能够被定义为数据/地址第八位。在FIASH编程时,P0 口作为原码输入口,当FIASH进行校验时,P0输出原码,此时P0外部必需被拉高。P1口:P1口是一个内部提供上拉电阻8位双向I/O口,P1口缓冲器能接收输出4TTL门电流。P1口管脚写入1后,被内部上拉为高,可用作输入,P1口被外部下拉为低电平时,将输出电流,这是因为内部上拉缘故。在FLASH编程和校验时,P1口作为第八位地址接收。 P2口:P2口为一个内部上拉电阻8位双向I/O口,P2口缓冲器可接收,输出4个TTL门电流,当P2口被写“1”时,其管脚被内部上拉电阻拉高,且作为输入。并所

6、以作为输入时,P2口管脚被外部拉低,将输出电流。这是因为内部上拉缘故。P2口当用于外部程序存放器或16位地址外部数据存放器进行存取时,P2口输出地址高八位。在给出地址“1”时,它利用内部上拉优势,当对外部八位地址数据存放器进行读写时,P2口输出其特殊功效寄存器内容。P2口在FLASH编程和校验时接收高八位地址信号和控制信号。P3口: P3口管脚是8个带内部上拉电阻双向I/O口,可接收输出4个TTL门电流。当P3口写入“1”后,它们被内部上拉为高电平,并用作输入。作为输入,因为外部下拉为低电平,P3口将输出电流(ILL)这是因为上拉缘故。P3口也可作为AT89C51部分特殊功效口,以下表所表示:

7、P3口管脚 备选功效:P3.0 RXD(串行输入口)P3.1 TXD(串行输出口)P3.2 INT0(外部中止0)P3.3 INT1(外部中止1)P3.4 T0(记时器0外部输入)P3.5 T1(记时器1外部输入)P3.6 WR(外部数据存放器写选通)P3.7 RD(外部数据存放器读选通)P3口同时为闪烁编程和编程校验接收部分控制信号。RST:复位输入。当振荡器复位器件时,要保持RST脚两个机器周期高电平时间。ALE/PROG:当访问外部存放器时,地址锁存许可输出电平用于锁存地址地位字节。在FLASH编程期间,此引脚用于输入编程脉冲。在平时,ALE端以不变频率周期输出正脉冲信号,此频率为振荡器

8、频率1/6。所以它可用作对外部输出脉冲或用于定时目标。然而要注意是:每当用作外部数据存放器时,将跳过一个ALE脉冲。如想严禁ALE输出可在SFR8EH地址上置0。此时, ALE只有在实施MOVX,MOVC指令是ALE才起作用。另外,该引脚被略微拉高。假如微处理器在外部实施状态ALE严禁,置位无效。PSEN: 外部程序存放器选通信号。在由外部程序存放器取指期间,每个机器周期两次/PSEN有效。但在访问外部数据存放器时,这两次有效/PSEN信号将不出现。EA/VPP:当/EA保持低电平时,则在此期间外部程序存放器(0000H-FFFFH),不管是否有内部程序存放器。注意加密方法1时,/EA将内部锁

9、定为RESET;当/EA端保持高电平时,此间内部程序存放器。在FLASH编程期间,此引脚也用于施加12V编程电源(VPP)。XTAL1:反向振荡放大器输入及内部时钟工作电路输入。XTAL2:来自反向振荡器输出。振荡器特征: XTAL1和XTAL2分别为反向放大器输入和输出。该反向放大器能够配置为片内振荡器。石晶振荡和陶瓷振荡均可采取。如采取外部时钟源驱动器件,XTAL2应不接。有余输入至内部时钟信号要经过一个二分频触发器,所以对外部时钟信号脉宽无任何要求,但必需确保脉冲高低电平要求宽度。图3.2 系统最小系统3.2 滤波电路及LM324芯片LM324芯片是差动输入四运算放大器。该运放放大器能够

10、工作在低到3.0伏或高到32伏电源下,静态电流为MC1741静态电流五分之一。共模输入范围包含负电源,所以消除了在很多应用场所中采取外部偏置元件必需性。每一组运算放大器可用图三所表示符号来表示,它有5个引出脚,其中“+”、“-”为两个信号输入端,“V+”、“V-”为正、负电源端,“Vo”为输出端。两个信号输入端中,Vi-为反相输入端,表示运放输出端Vo信号和该输入端相位相反;Vi+为同相输入端,表示运放输出端Vo信号和该输入端相位相同。图3.3 LM324管脚图霍尔传感器输出信号为正弦信号,而单片机只能处理高低电平信号,为此必需将正弦信号转换成TTL电平信号。设计中利用LM324比较作用将输入

11、信号和参考电压进行比较,到大于时LM324输出端为高电平,不然为低电平。因为LM324为模拟器件,其驱动能力不足。设计中在输入端串联了一片74LS04六非门芯片,提升输入驱动能力,方便于单片机处理。图3.4 信号输入滤波电路3.3 显示设备图3.5 转速显示设备LCD16023.3 控制实施机构经过汽车理论知识学习,我们知道汽车发动机不能超出某一转速。假如长久在高转速下运作,对汽车发动机寿命将大打折扣。为此,预防发动机高速情况发生,系统特意采取LED作为显示灯,提醒驾驶员此时发动机高转速运行情况,使其做对应处理。同时电机运作,将控制汽车油路电磁阀逐步闭合,使供油减小,发动机转速降低,直至电磁阀

12、完全闭合,停止供油。图3.6 控制机构及指示灯原理图4 系统软件设计4.1 设计思绪利用80C52单片机内部定时计数器和外部中止功效,经过检测P3.2端口信号开启定时计数器进行计时,当下一次触发信号到来时,定时器停止计时并保留目前值。再开启定时器计时,如此循环。保留值达成五次后,对其进行加权滤波处理。最终将所得值赋给数码管显示。当转速值大于设定值时,控制电机运作,指示灯亮。4.2 程序步骤图图4.1主程序步骤图图4.2定时器0中止函数步骤图图4.3外部中止函数步骤图5 系统仿真和调试5.1 Proteus软件介绍系统采取Proteus软件来进行程序仿真,这款软件是英国Labcenter ele

13、ctronics企业出版EDA工具软件。它不仅含有其它EDA工具软件仿真功效,还能仿真单片机及外围器件。它是现在最好仿真单片机及外围器件工具。即使现在中国推广刚起步,但已受到单片机爱好者、从事单片机教学老师、致力于单片机开发应用科技工作者青睐。5.2 仿真图建立系统采取Proteus软件进行仿真,利用软件自带仿真模块建立系统仿真图。图5.1为发动机转速电控系统最小系统图。图5.1 主控芯片仿真因为汽车上常见转速传感器为霍尔式,集成传感器其输出信号为脉冲信号。在仿真中,采取霍尔传感器原始信号即正弦信号来作为输入信号,利用LM324芯片比较功效对其进行滤波处理将其转换成对应脉冲信号。图5.2为滤波

14、转换电路。图5.2 系统滤波转换电路系统采取LCD1602作为显示器件,其具体仿真连接图以下。图5.3 系统显示器件当系统检测完后得到转速大于我所设定值时,控制实施机构运作同时指示灯将会点亮。当转速正常(小于设定值)时,电机停止工作,指示灯灭。在仿真中我选择直流电机作为实施机构。图5.5 实施机构仿真图5.3 仿真调试结果图5.5,图5.6,图5.7分别表示在不一样输入频率下,对应LCD显示转速情况及电机运作情况。图5.6 仿真图(一)当调整信号发生器改变输入频率值时,单片机经过对其进行计数并运算处理,在数码管上面对应显示目前值。调整信号发生器为图5.6所表示即为18HZ时,LCD显示值为10

15、80r/min,其值和18*60=1080相同。仿真结果正确。图5.7 仿真图(二)当调整信号发生器为50HZ时,LCD显示为3006r/min,这和理论值50*60=3000有一定误差。基础满足设计要求。图5.8 仿真图(三)继续调整信号发生器频率时直到超出设定值8000r/min时,电机将会转动,因为此为动态效果,我们能够从三极管基极为高电平能够判定出此情况,而且指示灯将点亮。此时输入频率为140HZ,输出为8450r/min,其和理论140*60=8400r/min有一定误差,在设计要求范围内。结论致谢参考文件1 徐峥颖编著.Protel99SE EDA 技术及应用M.北京:机械工业出版

16、社,.2 张靖武编著.单片机系统protues设计和仿真M.北京:电子工业出版社,.3 李朝青编著.单片机原理及接口技术M.北京:北京航空航天大学出版社,.4 边春远编著.MCS-51单片机应用开发实用子程序M.北京:人民邮电出版社,.5 刘守义编著.单片机应用技术M.西安:西安电子科技大学出版社,.6 韩志军编著.单片机应用系统设计M.北京:机械工业出版社,.7 张毅刚,刘喜元编著.新编MCS-51单片机应用设计M.哈尔滨:哈尔滨工业大学出版社,.8 唐岚编著.汽车测试技术M.北京:机械工业出版社,.附录A:原理图附录B:程序编译附录C:仿真图附录D:程序代码#include #define

17、 uchar unsigned char#define uint unsigned intsbit LED=P31;sbit MO=P33;bit Flag; /第一次中止标志bit Flag_s; /转换标志sbit E=P25;sbit RW=P26;sbit RS=P27;uchar COUNT; /溢出次数unsigned long T5;uchar W5=1,2,3,4,5; /权值void Init(void);unsigned int Smooth(void);void delay(uint N);void write_cmd(uchar cmd);void write_data

18、(uchar date);void LCD_Init();void LCD_Disp(uint d);void Write_Datas(uchar address,uchar Wdata);/-/ 主函数/-void main(void)uchar msg114=Current Rev is;uchar msg214= r/min ;uint i,dis_dat;Flag=0;Flag_s=0;COUNT=0;dis_dat=0;Init();LCD_Init();EA=1;write_cmd(0x80);for(i=0;i14;i+)write_data(msg1i);write_cmd(0

19、x80+0x40);for(i=0;i8000)LED=0;MO=1;elseLED=1;MO=0; LCD_Disp(dis_dat);void delay(uint N)/延时N毫秒子程序uint x,y;for(x=N;x0;x-)for(y=110;y0;y-);void write_cmd(uchar cmd)/写指令子程序RS=0;RW=0;P1=cmd;delay(1);E=1;delay(1);E=0;void write_data(uchar date)/写数据子程序RS=1;RW=0;P1=date;delay(1);E=1;delay(1);E=0;void LCD_in

20、it()E=0; write_cmd(0x38);/5*7点阵字符write_cmd(0x0c);/整体显示,关光标,不闪烁write_cmd(0x06);/AC自动增一,画面不动write_cmd(0x01);/清屏write_cmd(0x80);/设置DDRAM地址void Write_Datas(uchar address,uchar Wdata)write_cmd(0x80+address);write_data(0x30+Wdata);/写数据void LCD_Disp(uint d) unsigned char dd4,i;dd0=d/1000;dd1=d%1000/100;dd2

21、=d%1000%100/10;dd3=d%10;for(i=0;i4;i+)Write_Datas(0x42+i,ddi);/-/名称:定时器,中止初始化/功效:定时器0采取16位,中止下降沿触发/-void Init(void)TMOD=0x01;EX0=1;ET0=1;IT0=1;/-/名称:滤波函数/功效:加权滤波,权值1,2,3,4,5/- unsigned int Smooth(void)uchar i;uint dat;float sum;float avg;sum=0;for(i=0;i9999)dat=9999;return dat;/-/外部中止0中止函数/-void INT

22、(void) interrupt 0if(Flag)static unsigned char m=0; Tm=TH0*256+TL0+65536*COUNT;TH0=0;TL0=0;COUNT=0;m+;if(m=5)m=0;Flag_s=1;elseFlag=1;TH0=0;TL0=0;TR0=1;/-/定时器0中止函数/-void Time(void) interrupt 1COUNT+;TH0=0;TL0=0;g an employment tribunal claiEmployment tribunals sort out disagreements between employers

23、 and employees.You may need to make a claim to an employment tribunal if: you dont agree with the disciplinary action your employer has taken against you your employer dismisses you and you think that you have been dismissed unfairly.For more information about dismissal and unfair dismissal, seeDism

24、issal.You can make a claim to an employment tribunal, even if you haventappealedagainst the disciplinary action your employer has taken against you. However, if you win your case, the tribunal may reduce any compensation awarded to you as a result of your failure to appeal.Remember that in most case

25、s you must make an application to an employment tribunal within three months of the date when the event you are complaining about happened. If your application is received after this time limit, the tribunal will not usually accept i.If you are worried about how the time limits apply to you, take ad

26、vice from one of the organisations listed underFurther help.Employment tribunals are less formal than some other courts, but it is still a legal process and you will need to give evidence under an oath or affirmation.Most people find making a claim to an employment tribunal challenging. If you are t

27、hinking about making a claim to an employment tribunal, you should get help straight away from one of the organisations listed underFurther help.If you are being represented by a solicitor at the tribunal, they may ask you to sign an agreement where you pay their fee out of your compensation if you

28、win the case. This is known as adamages-based agreement. In England and Wales, your solicitor cant charge you more than 35% of your compensation if you win the case.If you are thinking about signing up for a damages-based agreement, you should make sure youre clear about the terms of the agreement.

29、It might be best to get advice from an experienced adviser, for example, at a Citizens Advice Bureau. To find your nearest CAB, including those that give advice by e-mail, click onnearest CAB.For more information about making a claim to an employment tribunal, seeEmployment tribunals.The (lack of) a

30、ir up there Watch mCayman Islands-based Webb, the head of Fifas anti-racism taskforce, is in London for the Football Associations 150th anniversary celebrations and will attend Citys Premier League match at Chelsea on Sunday.I am going to be at the match tomorrow and I have asked to meet Yaya Toure,

31、 he told BBC Sport.For me its about how he felt and I would like to speak to him first to find out what his experience was.Uefa hasopened disciplinary proceedings against CSKAfor the racist behaviour of their fans duringCitys 2-1 win.Michel Platini, president of European footballs governing body, ha

32、s also ordered an immediate investigation into the referees actions.CSKA said they were surprised and disappointed by Toures complaint. In a statement the Russian side added: We found no racist insults from fans of CSKA.Age has reached the end of the beginning of a word. May be guilty in his seems t

33、o passing a lot of different life became the appearance of the same day; May be back in the past, to oneself the paranoid weird belief disillusionment, these days, my mind has been very messy, in my mind constantly. Always feel oneself should go to do something, or write something. Twenty years of l

34、ife trajectory deeply shallow, suddenly feel something, do it.一字开头年纪已经到了尾声。或许是愧疚于自己似乎把转瞬即逝很多个不一样日子过成了同一天样子;或许是追溯过去,对自己那些近乎偏执怪异信念醒悟,这些天以来,思绪一直很凌乱,在脑海中不停纠缠。总认为自己自己似乎应该去做点什么,或写点什么。二十年人生轨迹深深浅浅,忽然就感觉到有些事情,非做不可了。The end of our life, and can meet many things really do?而穷尽我们一生,又能碰到多少事情是真正地非做不可?During my chi

35、ldhood, think lucky money and new clothes are necessary for New Year, but as the advance of the age, will be more and more found that those things are optional; Junior high school, thought to have a crush on just means that the real growth, but over the past three years later, his writing of alumni

36、in peace, suddenly found that isnt really grow up, it seems is not so important; Then in high school, think dont want to give vent to out your inner voice can be in the high school children of the feelings in a period, but was eventually infarction when graduation party in the throat, later again st

37、ood on the pitch he has sweat profusely, looked at his thrown a basketball hoops, suddenly found himself has already cant remember his appearance.童年时,认为压岁钱和新衣服是过年必备,不过伴随年纪推进,会越来越发觉,那些东西根本就可有可无;初中时,认为要有一场暗恋才意味着真正成长,但三年过去后,自己心平气和写同学录时候,忽然就发觉是不是真正成长了,仿佛并没有那么关键了;然后到了高中,认为非要吐露出自己心声才能为高中生涯里懵懂情愫划上一个句点,但毕业晚

38、会时候最终还是被梗塞在了咽喉,以后再次站在她曾经挥汗如雨球场,看着她投过篮球球框时,忽然间发觉自己已经想不起她容颜。Originally, this world, can produce a chemical reaction to an event, in addition to resolutely, have to do, and time.原来,这个世界上,对某个事件能产生化学反应,除了非做不可果断,还有,时间。A persons time, your ideas are always special to clear. Want, want, line is clear, as if

39、 nothing could shake his. Also once seemed to be determined to do something, but more often is he backed out at last. Dislike his cowardice, finally found that there are a lot of love, there are a lot of miss, like shadow really have been doomed. Those who do, just green years oneself give oneself a

40、n arm injection, or is a self-righteous spiritual.一个人时候,自己想法总是尤其地清楚。想要,不想要,界限明确,仿佛没有什么能够撼动自己。也曾经仿佛已经下定了决心去做某件事,但更多时候是最终又打起了退堂鼓。嫌恶过自己怯懦,最终却发觉有很多缘分,有很多错过,仿佛冥冥之中真已经注定。那些曾经所谓非做不可,只是青葱年华里自己给自己注射一支强心剂,或说,是自认为是精神寄托罢了。At the moment, the sky is dark, the air is fresh factor after just rained. Suddenly though

41、t of blue plaid shirt; Those were broken into various shapes of stationery; From the corner at the beginning of deep friendship; Have declared the end of the encounter that havent start planning. Those years, those days of do, finally, like youth, will end in our life.此刻,天空是阴暗,空气里有着刚下过雨以后清新因子。忽然想到那件蓝格子衬衫;那些被折成多种多样形状信纸;那段从街角深巷伊始友谊;还有那场还没有开始就宣告了终止邂逅计划那些年那些天非做不可,最终和青春一样,全部将在我们人生中谢幕。Baumgartner

展开阅读全文
部分上传会员的收益排行 01、路***(¥15400+),02、曲****(¥15300+),
03、wei****016(¥13200+),04、大***流(¥12600+),
05、Fis****915(¥4200+),06、h****i(¥4100+),
07、Q**(¥3400+),08、自******点(¥2400+),
09、h*****x(¥1400+),10、c****e(¥1100+),
11、be*****ha(¥800+),12、13********8(¥800+)。
相似文档                                   自信AI助手自信AI助手
搜索标签

当前位置:首页 > 学术论文 > 毕业论文/毕业设计

移动网页_全站_页脚广告1

关于我们      便捷服务       自信AI       AI导航        获赠5币

©2010-2024 宁波自信网络信息技术有限公司  版权所有

客服电话:4008-655-100  投诉/维权电话:4009-655-100

gongan.png浙公网安备33021202000488号   

icp.png浙ICP备2021020529号-1  |  浙B2-20240490  

关注我们 :gzh.png    weibo.png    LOFTER.png 

客服