内容发布更新时间 : 2024/11/18 21:26:58星期一 下面是文章的全部内容请认真阅读。
摘 要
在电子领域内,频率是一种最基本的参数,并与其他许多电参量的测量方案和测量结果都有着十分密切的关系。由于频率信号抗干扰能力强、易于传输,可以获得较高的测量精度。因此,频率的测量就显得尤为重要,测频方法的研究越来越受到重视。
频率计作为测量仪器的一种,常称为电子计数器,它的基本功能是测量信号的频率和周期频率计的应用范围很广,它不仅应用于一般的简单仪器测量,而且还广泛应用于教学、科研、高精度仪器测量、工业控制等其它领域。随着微电子技术和计算机技术的迅速发展,特别是单片机的出现和发展,使传统的电子侧量仪器在原理、功能、精度及自动化水平等方面都发生了巨大的变化,形成一种完全突破传统概念的新一代侧量仪器。频率计广泛采用了高速集成电路和大规模集成电路,使仪器在小型化、耗电、可靠性等方面都发生了重大的变化。目前,市场上有各种多功能、高精度、高频率的数字频率计,但价格不菲。
为适应实际工作的需要,本次设计给出了一种较小规模和单片机(AT89S52)相结合的频率计的设计方案,不但切实可行,而且体积小、保密性强、设计简单、成本低、精度高、可测频带宽,大大降低了设计成本和实现复杂度。频率计的硬件电路是用Protel绘图软件绘制而成,软件部分的单片机控制程序,是以KeilC做为开发工具用C语言编写而成,而频率计的实现则是选用Ptotues仿真软件来进行模拟和测试。
关键词:单片机;AT89S52;频率计;C语言
ABSTRACT
In the electronic field, frequency is a kind of most basic parameter, and all there are close relations in the measurement schemes of many other electric parameters and result of measuring. Because the signal anti-interference ability of frequency is strong, easy to transmit, can obtain higher measurement precision. So, the measurement of frequency seems particularly important, the research of the method is being paid attention to.
The Frequency meter, as one kind of the measuring instrument, often called the electronic counter, its basic function is that frequency and application of cycle Frequency meter of measuring the signal are in a very large range, it not only applies to general simple instrument measurement but also apply to other fields such as teaching, scientific research, high-accuracy instrument measuring, industrial control extensively. With the rapid development of microelectric technique and computer technology, especially appearance and development of the one-chip computer, the instruments have all changed enormously in such aspects as principle, function, precision and automatic level to enable the traditional electronic side amount, form a kind of side amount instrument of new generation that totally broke through the traditional concept. The Frequency meter has adopted the high-speed integrated circuit and large scale integrated circuit extensively, make the instrument change greatly in such aspects as miniaturize, power consumptive, dependability. At present, there are various digital Frequency meter of multi-function, high precision, high frequency on the market, but the price is high.
In order to meet the need of the real work, design and provide one this time The design plan of Frequency meter combining with one-chip computer (AT89S52) on a small scale, not only feasible, and small, of good security, design simply, with low costs, the precision is high, can examine the bandwidth frequently, have reduced the design cost and realized complexity greatly. The hardware circuit of the Frequency meter is drawing with Protel mapping software, the one-chip computer control procedure of the software part, regarded KeilC as the developing instrument to write in C language, but the realization of the Frequency meter was to select to carry on imitating and test with Protues artificial software.
Key Words:single chip computer; AT89S52; frequency meter; C language
目 录
1 绪 论 ........................................................................................................................................ 1 1.1 课题的引入 ....................................................................................................................... 1 1.2 产生背景 ........................................................................................................................... 1 1.3 国内外研究现状 ............................................................................................................... 2 1.4 单片机频率计设计的目的及意义 ................................................................................... 2 2 AT89S52单片机介绍及其发展概况 ..................................................................................... 4 2.1 单片机的介绍 ................................................................................................................... 4 2.1.1 单片机概述 ................................................................................................................ 4 2.1.2 单片机的发展 ............................................................................................................ 5 2.1.3 单片机的特点及应用 ................................................................................................ 5 2.2 AT89S52系列单片机 ....................................................................................................... 6 2.2.1 AT89系列单片机 ...................................................................................................... 6 2.2.2 AT89S52系列单片机的基本结构 ............................................................................ 7 3 频率计总体方案设计 ............................................................................................................ 10 3.1 频率计设计原理 ............................................................................................................. 10 3.1.1 频率检测实现方法 .................................................................................................. 10 3.1.2 频率计测频原理 ...................................................................................................... 11 3.2 设计思路及方法 ............................................................................................................. 11 3.2.1 频率计方案概述 ...................................................................................................... 12 3.2.2 频率计的量程自动切换 .......................................................................................... 12 4 系统的硬件设计 .................................................................................................................... 14 4.1 时钟信号发生器 ............................................................................................................. 14 4.2 AT89S52 控制寄存器 .................................................................................................... 15 4.2.1 AT89S52中断控制系统 .......................................................................................... 15 4.2.2 AT89S52定时/计数器的控制 ................................................................................. 17
I
4.3 LCD1602显示电路 ........................................................................................................ 18 4.3.1 LCD1602的主要技术参数及接口说明 ................................................................. 19 4.3.2 控制器接口及时序 .................................................................................................. 19 4.3.3 频率计硬件电路整体设计 ...................................................................................... 20 5 系统的软件设计 .................................................................................................................... 22 5.1 Keil C简介 ..................................................................................................................... 22 5.2 频率计程序的建立过程 ................................................................................................. 23 5.3 软件功能模块设计 ......................................................................................................... 27 5.3.1 LCD初始化设置模块 ............................................................................................. 28 5.3.2 浮点数到ASCII码转换模块 ................................................................................. 28 5.3.3 定时/计数器初始化模块 ......................................................................................... 29 5.3.4 定时器中断服务模块子程序 .................................................................................. 29 6 系统的模拟及仿真 ................................................................................................................ 31 6.1 Proteus ISIS简介 ............................................................................................................. 31 6.1.1 Proteus ISIS的概况简介及特点 .............................................................................. 31 6.1.2 Proteus ISIS的运行概况 .......................................................................................... 31 6.1.3 用Proteus 软件虚拟单片机实验的优点 ............................................................... 32 6.2 系统的模拟与仿真过程 ................................................................................................. 33 6.3 频率计系统仿真分析 ..................................................................................................... 37 结束语 ........................................................................................................................................ 41 致谢 ............................................................................................................................................ 42 参考文献 .................................................................................................................................... 43
II
1 绪 论
1.1 课题的引入
在电子技术中,频率是一种计算单位时间内的信号变化的数值的仪器,是最基本的参数之一,由于频率信号抗干扰能力强、易于传输,可以获得较高的测量精度,并且与许多电参量的测量方案、测量结果都有十分密切的关系。因此,频率的测量就显得更为重要。
随着微电子技术和计算机技术的迅速发展,特别是单片机的出现和发展,使传统的电子测量仪器在原理、功能、精度及自动化水平等方面都发生了巨大的变化,形成一种完全突破传统概念的新一代测量仪器。从80年代单片机引入我国至今,单片机已广泛地应用于电子设计中,使频率计智能化水平在广度和深度上产生了质的飞跃,数字化也成为了电子设计的必由之路。运用单片机设计频率计,并采用适当的算法取代传统电路,克服了传统频率计结构复杂、稳定性差、精度不高的弊端,其体积小、保密性强、设计简单、成本低,不仅大大降低了设计成本和实现复杂度,而且频率计性能也将大幅提高,可实现精度较高、等精度和宽范围频率计的要求。[15]
1.2 产生背景
频率计作为测量仪器的一种,常称为电子计数器,它的基本功能是测量信号的频率和周期频率计的应用范围很广,它不仅应用于一般的简单仪器测量,而且还广泛应用于教学、科研、高精度仪器测量、工业控制等其它领域。
20世纪70年代,微电子技术正处于发展阶段,集成电路属于中规模发展时期,各种新材料新工艺尚未成熟,美国仙童(Fairchild)公司研制出世界上第一台单片微型机F8。此时单片机仍处在初级的发展阶段,元件集成规模还比较小,功能比较简单,一般均把CPU、RAM有的还包括了一些简单的I/O口集成到芯片上,它还需配上外围的其他处理电路方才构成完整的计算系统。
问世以来,单片机开始迅速发展,其功能不断增强和完善,应用领域也越来越广泛,现已成为微型计算机的重要分支。目前,单片机发展具体体现在CPU功能增强内部资源增多引脚的多功能化和低电压低功耗等方面。
随着嵌入式系统式系统片上系统等概念的提出.普遍接受及应用,单片机的发展又进入了一个新的阶段,单片机的体积更小功能更齐全可靠性更高.由于起明显的优势,单片机
- 1 -