




已阅读5页,还剩27页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
2011级小学期53组目录CHAPTER 1 TEMPERATURE AND HUMIDITY MEASURING PRINCIPLE21.1 THE SCHEME SELECTION OF TEMPERATURE AND HUMIDITY SENSOR2 1.2 THE SCHEME SELECTION OF TEMPERATURE AND HUMIDITY DISPLAY2 CHAPTER 2 THE HARDWARE DESIGN OF THE SYSTEM3 2.1 THE OVERALL DESIGN OF THE SYSTEM HARDWARE3 2.2 THE MAIN SCHEME SELECTION AND DESIGN OF THE CONTROL MODULE42.2.1 singlechip STC89C52 introduction62.2.2 The main control module circuit72.3 THE SELECTION AND DESIGN OF THE RTC MODULE SCHEME82.4 THE DESIGN OF INTERFACE MODULES8 CHAPTER 3 THE DESIGN OF SYSTEM SOFTWARE93.1 SYSTEM OF THE MAIN PROGRAM AND FLOW CHART93.2 THE READ OPERATION FLOW CHART OF DS1302 CLOCK CHIP103.3 WRITE OPERATION FLOW CHART THE OF LCD MODULE11 CHAPTER 4 THE EXPERIMENT AND DEBUGGING124.1 DIFFICULTIES AND SOLUTIONS14 CHAPTER 5 TEAM DIVISION OF LABOR AND COMMENTS15 APPENDIX A:ELECTRIC SCHEMATIC DIAGRAM18APPENDIX B:PROGRAM LIST19APPENDIX C:EXTERNAL VIEW3232第1章 温湿度测量原理单片机的接口信号是数字信号。要想用单片机获取温湿度这类非电信号的信息,必须将其转换为数字信号,因为如果电流或电压输出是模拟信号,还必须进行A/D转换,以满足单片机接口的需要。如果是数字信号就可以直接送往单片机进行数据处理。1.1温湿度传感器的方案选择DS18B20+HS1100因为HS1100在网上的资料相当匮乏,以及老师在课程开始前说HS1100输出为模拟信号,需要加A/D转换。以及,分别采用温度湿度传感器的话,占用电路板空间会更大。综合考虑以上因素,我们认为温湿度传感器SHT11/10更好。SHT11/10因为在中发电子市场,一下子找不到SHT11插针式的传感器,所以我们选用了精度稍低的SHT10。 1.2温湿度显示的方案选择方案一:时钟的显示可以用多位七段LED数码管显示,七段 LED数码管显示耗能多,而且显示位数有限,每增加一位都要在程序设计和硬件设计方面增加很多的工作量,不利于电路的扩展,而且无法显示年、月、日、星期这些汉字,使得显示不够直观,灵活。但是这种设计方案在显示位数比较少时性价比比较高,价格便宜,方案二:采用点阵式数码管显示。点阵式数码管是由八行八列的发光二极管组成,对于显示文字比较适合,而在本课题设计中的显示数字较多字符较少,而且此种方案耗能多,不符合现代的节能理念,所以不用此种作为显示。方案三:采用LCD液晶显示器显示。而LCD液晶显示则耗能少,能够显示年、月、日、星期等汉字,在显示方面更加灵活,而且改变显示时只要改变软件设计就可以,不用改变硬件电路的设计,易于电路的功能扩展。电路的软件设计也很简单。另外,这种设计硬件更加简洁。采用LCD液晶显示方案的缺点是在显示位数比较少时,价格也并不贵。比较上述两种方案可以看出方案三耗能少,显示灵活,易于电路扩展而且不管是软件设计还是硬件设计都比较简单,因此采用第三种设计方案。综上所述,本设计采用SHT10做温湿度传感器,引入DS1302时间模块的设计方案,显示使用LCD液晶显示。其中LCD1602性价比高,自带字模,选用LCD1602。第2章 系统硬件设计根据温湿度传感器的功能要求,基于单片机的设计方案要运用集成SHT10,实现实时数据记录与读取:(1)基本要求a) 具有读取温湿度并显示的功能(2)创新要求a) 具高温报警功能b) 具有日历功能2.1 系统硬件的整体设计主控芯片使用51系列STC89C52单片机,系统由主控制器STC89C52、时钟芯片DS1302、LCD1602液晶显示电路LED灯高温报警电路组成。系统硬件设计框图:系统硬件设计框图2.2 The main scheme selection and design of the control module It will definitely decrease complexity of hard circuits if main functions are realized by software. Thus we made our system a microcomputer-based one. To implement asked functions, we just need a simple featured microcomputer. I chose the STC89C52 to accomplish the mission in the light of its high cost performance.2.2.1 Description of STC89C52The STC89C52 is a low-power, high-performance CMOS 8-bit microcomputer with 8K bytes of Flash programmable and erasable read only memory (PEROM). The device is manufactured using Atmels high-density nonvolatile memory technology and is compatible with the industry-standard 80C51 and 80C52 instruction set and pin out. The on-chip Flash allows the program memory to be reprogrammed in-system or by a conventional nonvolatile memory programmer. By combining a versatile 8-bit CPU with Flash on a monolithic chip, the STC89C52 is a powerful microcomputer which provides a highly-flexible and cost-effective solution to many embedded control applications. Pin Configurations PDIP STC89C52 PDIP The AT89C52 provides the following standard features: 8K bytes of Flash, 256 bytes of RAM, 32 I/O lines, three 16-bit timer/counters, a six-vector two-level interrupt architecture, a full-duplex serial port, on-chip oscillator, and clock circuitry. In addition, the AT89C52 is designed with static logic for operation down to zero frequency and supports two software selectable power saving modes. The Idle Mode stops the CPU while allowing the RAM, timer/counters, serial port, and interrupt system to continue functioning. The Power-down mode saves the RAM contents but freezes the oscillator, disabling all other chip functions until the next hardware reset.2.2.2 The main control module circuitTaking the PO port of singlechip STC89C52 as the inpur port. Connecting the P1 ,the clock of SHT10 and data, taking the temperature and humidity data acquisition and connecting the DS1302 acquisition time information; the P0 Connects the D0D7 pin of LCD1602,The XTAL1 of singlechip connects the external crystal and One end of the trimmer capacitors. Although there is no strict requirements of the value of an external capacitor,The size of the capacitor will affect The oscillator frequency、the stability of oscillators、the rapidity of the vibration and the stability of the temperature。Therefore,In this system circuit, The value of crystal oscillator is 11.0592MHz. Capacitance should as far as possible the choice of the ceramic capacitor. Capacitance is about 22F. The 9 pin is reset input. Connecting the capacity, resister as the reset circuit. 20 pin is the ground terminal,40 pin is power terminal. /EA pin connects the +5V voltage. From this, The minimum system of single-chip microcomputer control module is maked up,as shown in figure:2.3 The selection and design OF The RTC module schemeThe DS1302 Trickle Charge Timekeeping Chip contains a real time clock/calendar and 31 bytes of static RAM. It communicates with a microprocessor via a simple serial interface. The real time clock/calendar provides seconds, minutes, hours, day, date, month, and year information. The end of the month date is automatically adjusted for months with less than 31 days, including corrections for leap year. The clock operates in either the 24hour or 12hour format with an AM/PM indicator.Compared with DS12887,which doesnt need any extra battery but kind of expensive approaching 30RMB,DS1302 can be work perfect with a 3.6V battery and these sum up only 5RMB.According to the high cost performance,we choose DS1302 to finish our RTC module. ds1302 program flow chart 2.4 The design of interface modulesThe design scheme uses the LCD liquid crystal display,because the design do not need a lot of contents. We chose the high performance cost ratio LCD1602。 liquid crystal display LCD1602 introduction omit chapter 3 The design of system software 3.1 System of the main program and flow chartThe main functions of the program are to display temperature and humidity information. In the main program, after the system will automatically reset, the electric system of liquid crystal display and the clock chip DS1302 initialized and read and write in the information such as temperature and humidity, time, to read and write data after the display information. The main program flow is shown in figure:The introduction of main program, when run the main program, to reset the sensors first, then put the LCD1602 initialization, and then it will display temperature and humidity and time.3.2 The read operation flow chart OF DS1302 clock chip First, Initializing of the clock chip DS1302, after judging the status register, to read in the operation of DS1302, the operation using the characteristics which the clock calendar address the adjacent, then judge whether the data is finished or not. If finished, return to the main program; if not, continue to increase the address, data until the reading is finished. As shown in figure:3.3 write operation flow chart The of LCD module The LCD module this circuit uses is 1602 LCD module, it can transpose ASCII and it is easy to operate.In the flow chart of display, there is no cursor on the display. The display of date is from the second line of the first character.chapter 4 The experiment and debugging The best way to verify the theory is practice, so this design uses experiment, debugging real object to verify the feasibility of the above design. Recent days, although a lot of designs use the simulation to simulate results, there are still some gaps with the reality. And some practical problems are not showed by the simulation, so we met quite a few problems while connecting the real circuit. Difficulties and solutions:1.the part of simulationBecause the version of protel is too old, many components are not in the component library. And it is very troublesome to add something to the component library. Therefore, we choose proteus to do simulation. Of course, we met some problems in the process of simulation. For example, the microcontroller we use is STC89C52, but there is only 89C52 there. For another example, we use LCD1602 to display, which is also not in the component library. Through online access, we know that AT and STC microcontrollers only differ in manufacturers and burning methods. And LCD1602 is replaced by another number LM016L in the component library. Whats more, LCD1602 misses two interfaces of adjusting LCD backlight brightness in the simulation diagram. Through the choice and connection of circuit element, we have completed the simulation. The following components are used in the simulation diagram: SinglechipAT89C52, SensorSHT10, CLKDS1302, Resistance1K and 10K,Resisters PacksRESPACK-8, Crystal OscillatorCRYSTAL(32.768Khz), Power source、Earthing terminal,Slide rheostat、LCD displayLM016L, NPN TransistorNPN,LED lightLED-RED.Communication problems between LCD display and singlechip emerged from the first try of bread plate.This design passed the Proteus simulation software without any problems, the hardware validation circuit is completed by the students responsible for theory and lap welding students in the form of mutual supervision, to ensure that the circuit is connected completely according to the theory. With 5V voltage source acting as power supply, LCD screen lights up normally, displaying a row of small black grids, then stop at this state.When we firstly encountered this kind of situation, we felt it difficult to understand, because in the beginning we greatly underestimated the differences between the simulation and reality, through data access, we know this kind of situation usually exists two possibilities:The improper adjustment of LCD backlight contrastThe abnormal communication of LCD screen and singlechip microcomputerFirstly, we saw the LCD lighted in the dark, with dot matrix clearly displayed, so we eliminated the first possibility. However, we still try to adjust the slide rheostat in the 3rd pin, finally determining that it is not backlit contrast of LCD to result in this problem.The second situation may be more, the reasons of abnormal communication of MCU and LCD may be a connection problem, or code, among the two code may have a problem of short delay. Because the refresh ability of LCD screen is not considered in the simulation, but in fact, when the singlechip microcomputer performs writing operations to LCD screen,it is like to pour a big barrel of water into a small mouth bottle of water, the data processing ability of singlechip microcomputer is much better than the receptivity of LCD screen, so a proper time delay makes the LCD screen to work normally.By looking up to some materials, we added some appropriate delay, finally the time delay between two cycles is set to 0.8s, but problems still exist. Then we use the multimeter to measure the communication between the singlechip microcomputer and the D0 D7 mouth of LCD1602, finding that the voltage value of individual tubes are not as imagined, so we considered that a poor contact causes the problem, planning to build a line once more. The second day after pitching line using another piece of bread plate, we can occasionally see flashes of digital temperature and humidity, which let us be firm that lap joint on the bread plate resulted in many poor contacts, so we started to weld the circuit.3.Problems during formal weldingAfter the first formal welding was completed, we found the circuit that worked well in the test cant display properly after real welding, but this time we can assert directly that is a line problem, so we reinforced the solder joints for consolidation, this time we can see normal steady temperature and humidity. Although there was a problem in the display of the time, everyone was very happy.The buzzer didnt work properlyIn the test of buzzer circuit, the buzzer rang as long as given electricity. We checked whether the buzzer triode was normal one by one, given the right answer, we consulted data and the teacher to learn that high and low level voltages of singlechip microcomputers each nozzle is not the same, under the teachers advice, we changed the communication buzzer circuit of 3 nozzle which we will not generally use to 2 nozzle, also modified some code. Then the buzzer didnt ring, so didnt it when arriving at the alarming temperature, finally we found the working voltage of the buzzer we bought is greater than the power supply voltage of the circuit, we also took the high-temperature alarming humanized problem into consideration, so we changed the buzzer to LED light, and all worked.Date display is not correctThe final problem that was not solved of the whole process is the wrong time display, we still dare not to tell what the problem was. Of the time display, the month information can be read and displayed normally, but the day cant, which was always accompanied by some messy code. And each time we reset the microcontroller, display of the day would be different. The situation is roughly showed as follows: After doing the comparison of the existing online calendar program, we found the address while querying calendar chip in the program had no errors, and read and display of month is very normal, also with the simulation. At start we thought may be the two lattice which display the day information on the LCD screen were broken, so we changed the their positions, but still only month normally displayed. We replaced the clock chip to get the same result. At last, we found everything would be all right after joining the initialization of time in the header files of ds1302, the cause of the problem was that if ds1302 was not initialized, the day would be a random value rather than a morally system time. 第5章 组员分工及心得体会 组员分工及完成情况:我组十一个人,其中电商专业负责网站设计与制作部分(3人):董笑言郝天琪欧子豪电信工程及管理专业负责温湿度传感器电路部分和外形设计(8人):焊接:商文熙、刘驰、王珂电路设计:周雪、邹嘉桐、赵舒玄仿真设计:周雪程序设计:石康采购:石康、邹嘉桐AutoCAD以及外观设计:郭媛媛 完成情况:除了赵舒玄因赴台湾交流项目无法完成出勤,其余组员均出勤良好。全组上下齐心协力,虽然大体分工如上但是每个部分基本都是组员间相互帮助完成的。最终达到老师基本要求温湿度显示,完成额外功能高温报警。其中额外功能日期显示未完成。心得体会: 结束了紧张的期末考试,我们又迎来了小学期实践活动。这次小学期需要我们设计,制作一个温湿度传感器。从电路设计、电路焊接、材料选购、外观设计,到网站设计、宣传出售,全部要我们自己完成。 在基于单片机的温湿度传感器电路设计过程中,我们学到了很多重要的东西,其中最重要的是如何将实践和理论相联系,怎样将所学到的知识运用到我以后的工作中去。大学的课堂的学习只是在给我们灌输专业知识,而我们应把所学的用到我们现实的生活中去,此次的温湿度传感器设计给我奠定了一个实践基础。本系统的设计应用到了电路分析,模拟电路基础,数字电路设计,C语言基础等多方面的知识。 电路焊接部分听起来容易,但实际操作起来难度很大。不仅要考虑焊接的牢固程度,还要考虑器件布局,导线连接,焊点大小。最难最麻烦的部分是后期的故障排查,因为在茫茫多的焊点、线路中,任何一个小错误都会导致最终电路的工作异常,所以每一个点都要排查,需要极大的耐心。除了耐心,智慧也是必不可少的。有时候,往往多思考一下,改动一个线路的位置,就会大大减少工作量,并且降低电路的错误率。因此,电路焊接大大锻炼了我们的耐心、毅力,而且令我们更深刻的体会到做事要有智慧,有计划,不能头脑一热,说做就做。选择外观时需要综合考虑很多因素:如是否好看、是否易实现、是否具有创意、是否利于结构设计等。最后要对外观进行包装,确保没有电路板裸露在外,并加以装饰。尽量做到外观美、功能全和易操作的统一。 总的来说,这次小学期不得不说是对每一个人的挑战,一切知识都是新的。它考验的是我们的学习能力,怎么样快速入门一个自己从未接触过的知识是需要技巧以及好学的精神的。我们在这次小学期学到的很多,至少每个人都能说出基于单片机的设计是怎样的工作原理,至少每个人都不会忘了给我们造成无限麻烦的LCD1602是一个2X16液晶屏每个字块用点阵显示,至少提到时钟芯片,晶振大家都会想起这次忙得不可开交的小学期。由于时间比较仓促,我们只能做到达到现在这样的水平;其他的希望以后的学习中,能够再做进一步尝试。 附录A:电路原理图附录B:程序清单main.c/*端口定义* P1.0-SCK (SHT10) P1.1-DATA (SHT10) P0-D0D7 (LCD1602) P2.0-RS (LCD1602) P2.1-RW (LCD1602) P2.2-E (LCD1602)*/#include #include #include #include #include #include #include ds1302.h#define uchar unsigned char#define uint unsigned int/1602液晶端口定义 *sbit LcdRs= P20;sbit LcdRw= P21;sbit LcdEn= P22;sbit LED= P27;sbit ACC0 = ACC0;sbit ACC7 = ACC7;uchar str7;unsigned dispbuff=0,OldSecond=0; /dispbuff是显示输出的临时变量unsigned int AlarmVal=40;/设置的报警温度/向LCD写入命令或数据*#define LCD_COMMAND0 / Command#define LCD_DATA1 / Data#define LCD_CLEAR_SCREEN0x01 / 清屏#define LCD_HOMING 0x02 / 光标返回原点/设置显示模式*#define LCD_SHOW0x04 /显示开#define LCD_HIDE0x00 /显示关 #define LCD_CURSOR0x02 /显示光标#define LCD_NO_CURSOR0x00 /无光标 #define LCD_FLASH0x01 #define LCD_NO_FLASH0x00 /设置输入模式*#define LCD_AC_UP0x02#define LCD_AC_DOWN0x00 / default#define LCD_MOVE0x01 / 画面可平移#define LCD_NO_MOVE0x00 /defaultsbit SCK = P10; /定义通讯时钟端口sbit DATA = P11; /定义通讯数据端口typedef union unsigned int i; float f; value; enum TEMP,HUMI; /TEMP=0,HUMI=1 #define noACK 0 #define ACK 1 /adr command r/w #define STATUS_REG_W 0x06 /000 0011 0 #define STATUS_REG_R 0x07 /000 0011 1 #define MEASURE_TEMP 0x03 /000 0001 1 #define MEASURE_HUMI 0x05 /000 0
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 文创公司人员管理制度
- 机具设备领用管理制度
- 扬州龙飞桑拿管理制度
- 残疾人岗前培训管理制度
- Msoffice在信息管理中的应用解析试题及答案
- 煤矿调度业务管理制度
- 预防传染病管理制度
- 芯片测试流程管理制度
- 抽汲捞油安全管理制度
- 高分秘籍系统集成试题及答案
- 云南邮政面试题及答案
- 国开2024《人文英语4》边学边练参考答案
- 2025至2030年中国海参市场分析及竞争策略研究报告
- 新版水利工程监理日志
- 音乐课堂基础知识教学
- 生产月度工作总结汇报
- 他达拉非临床应用
- 中职高教版(2023)语文职业模块-第一单元1.4闪亮的坐标,劳模王进喜【课件】
- 冠脉介入对比剂使用专家共识课件
- 替尔泊肽在肥胖人群中的应用
- 医疗行业项目进驻流程解析
评论
0/150
提交评论