基于AT89C2051的高精度数字频率计的设计
- 格式:pdf
- 大小:76.56 KB
- 文档页数:2
以AT89C2051单片机为控制核心的数字温度计设计
单片机控制已成为今天电子设计追-求的目标之一,本文将这种控制技术应用于温度测量中。
AT89C2051是美国Atmel公司生产的低电压、高性能CMOS8位单片机,片内含有2 KB的反复擦写的只读程序存储器和128 B的随机存取数据存储器(RAM)。
美国DALLAS半导体公司生产的DSl-8B20型单线智能温度传感器,属于新一代适配微处理器的智能传感器。
数字温度计是以DS18B20为检测元件,由AT89C2051作为主控制器的温度计,具有功耗低、结构简单、读数方便、测温范围广、测温准确的特点。
1 电路构成及工作原理
1.1 硬件设计
由AT89C2051构成的温度计主要由三部分组成:DSl8B20温度传感器、单片机AT89C2051、由LED数码管构成的显示模块。
其系统原理框图如图1所示。
DSl8B20作为单片机AT89C2051的外部信号源,把所采集到的温度转换为数字信号,通过I/O接口传给2051,2051启动ROM内的控制程序驱动LED数码管,通过I/O接口和数据线(单片机和数码管的接口)把数据传送给数码管,将采集到的温度显示出来。
1.2 总电路图。
//定时器晶体振荡器11.0592M. //T0定时,T1计数#include <REG2051.H>//#include<stdio.h>#include<INTRINS.H>#define uchar unsigned char#define uint unsigned int#define ulint unsigned long intsbit DAT=P1^2; //定义串行数据输入端sbit CLK=P1^3; //定义时钟端sbit RCLK=P1^4; //定义控制端//bit flag=0 ; //标志位uchar count; //计数ulint pinlv=0,pin; //频率——频率缓存uchar temp[4]; //数据缓存uchar DispBuf[4]; //4位数据显示uchar code DispTab[]={0x88, //"0"0xBE, //"1"0x91, //"2"0x92, //"3"0xA6, //"4"0xC2, //"5"0xC0, //"6"0x9E, //"7"0x80, //"8"0x82, //"9"/* 0x84, //"A"0xE0, //"B"0xC9, //"C"0xB0, //"D"0xC1, //"E"0xC5, //"F"0xA4, //"H"0xE9, //"L"0x8C, //"n"0xA8, //"u"0x85, //"P"0xF0, //"o"0xF7, //"-"0xFF, //熄灭0x82 //自定义*/};void SendDAT a(unsigned char SendDAT) //传送一个字节的数据数据{unsigned char i;for(i=0;i<8;i++){if((SendDAT&0x80)==0)DAT=0;elseDAT=1;_nop_();CLK=0;_nop_();CLK=1;SendDAT=SendDAT<<1;}}void Disp(){uchar c;uchar i;temp[3]=pin/1000%10; //千位temp[2]=pin/100%10; //百位temp[1]=pin%100/10; //十位temp[0]=pin%10; //个位DispBuf[0]=temp[0];DispBuf[1]=temp[1];DispBuf[2]=temp[2];DispBuf[3]=temp[3]; //显示d[]数据RCLK=0; //关闭存储寄存器的输入for(i=0;i<8;i++){c=DispBuf[i]; //取出待显示字符SendDATa(DispT ab[c]); //送出字形码数?}RCLK=1; //开启存储寄存器的输入}void time0(void) interrupt 1 using 1 //定时器0溢出中断模式2可重装载{TR0=0;count++;TH0=0x3c;TL0=0xb0;if(count==20){count=0;TR1=0;pinlv=TH1*235+TL1*0.93;pin=pinlv;TH1=0;TL1=0;TR1=0;}TR0=1;}void main(){EA=0; //关主中断TMOD=0x51; //方式寄存器,TO定时,T1计数功能TH0=0x3c; //0x3c 定时50msTL0=0xb0; //0xb0TH1=0;TL1=0;ET0=ET1=1; //T0允许中断EA=1; //开主中断TR0=1; //T0定时while(1){TR1=1; //T1计数Disp();}}。
目录第1章绪论 (2)1.1 摘要 (2)1.2 本设计任务和主要内容 (2)第2章元器件选型 (3)2.1 主控制器选择 (3)2.2 计时方案选择 (3)2.3 显示方案选择 (3)2.4 扩展接口选择 (4)第3章系统硬件电路设计 (4)3.1 系统原理框图 (4)3.2 时钟电路和复位电路 (5)3.3 基本电路设计 (6)3.4 数码管显示电路设计 (6)3.5 频率发生电路设计 (8)3.6 电源电路设计 (8)第4章程序流程图与源程序 (9)4.1 程序流程图 (9)4.2 主程序 (10)第5章系统功能分析与说明 (13)5.1 频率计的概述 (13)5.2 频率计的工作原理 (13)5.3 设计思想 (13)5.4 软硬件调试 (13)5.5 系统功能分析 (14)第6章课程设计总结 (14)参考文献 (14)附录 (15)第 1 章绪论1.1 摘要本文设计了一种以单片机AT89C51为核心的数字频率计。
介绍了单片机、数字译码和显示单元的组成和工作原理。
测量时,将被测输入信号送给单片机,通过程序控制计数,结果送8279驱动数码管显示频率值。
频率计具有电路结构简单、成本低、测量方便、精度较高等特点。
适合测量低频信号。
系统简单可靠、操作简易,能基本满足一般情况下的需求。
既保证了测频精度,又使系统具有较好的实时性。
本频率计设计简洁,便于携带,扩展能力强,适用范围广。
【关键字】:频率计、单片机、LED显示1.2 本设计任务和主要内容一、设计题目设计一个频率计,数字显示格式:X X X X。
二、设计内容与要求1、通过定时器计数方式采集频率信号。
2、通过8279在4位数码管上显示频率大小。
三、设计目的1.通过亲身的设计应用电路,将所用的理论知识应用到实践中,增强实践动手能力,进而促进理论知识的强化。
2.通过频率计的设计系统掌握51单片机的应用。
掌握采集频率与数码显示软件编程及硬件设计的方法,掌握根据课题的要求,提出选择设计方案,查找所需元器,设计并搭建硬件电路,编程写入EPROM并进行调试等。
基于at89c51单片机的频率计设计方法的研究【基于at89c51单片机的频率计设计方法的研究】一、引言在现代科技日新月异的今天,单片机作为一种微型计算机,已经被广泛应用于各个领域。
其中,at89c51单片机以其稳定、可靠、易用的特点,成为了广大电子爱好者和专业技术人员的首选。
频率计作为一种常见的电子测量仪器,通过对信号的计数或者对波形的周期进行时间测量,能够准确测量信号的频率。
基于at89c51单片机的频率计设计方法成为了研究的焦点。
二、基本原理1. at89c51单片机简介at89c51单片机是一款典型的8位微控制器,具有4 KB 的内部Flash 可编程存储器。
它集成了许多功能模块,包括定时器、串行总线接口、模数转换器等,非常适合用于频率计的设计。
2. 频率计的基本原理频率计主要通过计数或者时间测量来确定信号的频率。
在基于at89c51单片机的设计中,一般采用定时器/计数器模块来实现频率的测量。
三、设计方法1. 信号输入在频率计的设计中,首先需要考虑的是信号的输入。
可以通过外部引脚的方式输入信号,也可以通过模拟输入口进行信号的输入。
2. 信号计数利用at89c51单片机的定时器/计数器模块,可以很方便地对输入的信号进行计数。
通过对计数值的读取和处理,可以得到信号的频率。
3. 显示输出设计一个合适的显示模块,将测得的频率值以数字或者图形的方式呈现给用户,从而实现频率的测量和显示。
四、关键技术1. 定时器/计数器模块的应用at89c51单片机的定时器/计数器模块是实现频率计的关键。
通过合理的配置和使用,可以实现对复杂信号的准确测量。
2. 中断技术的应用在频率计的设计中,中断技术可以帮助我们实时地对信号进行处理,提高系统的实时性和准确性。
3. 数字滤波技术对于输入的信号,往往存在噪声和干扰,因此需要借助数字滤波技术对信号进行处理,提高测量的精度和稳定性。
五、实际应用基于at89c51单片机的频率计设计方法已经在许多实际应用中得到了广泛的应用。
基于AT89C51单片机嵌入式频率计的设计嵌入式频率计是一种用于测量频率的仪器,通常由单片机、显示屏、电源和输入输出接口等组成。
本文将以AT89C51单片机为核心,设计一种基于AT89C51单片机的嵌入式频率计。
首先,我们需要了解AT89C51单片机的特点和基本原理。
AT89C51是一款高性能、低功耗的8位CMOS单片机,具有4KB的闪存和128字节的数据RAM。
该单片机采用经典的8051核心,具备强大的计时/计数功能,适合于频率计的设计。
其次,我们需要确定输入输出接口和显示屏的类型和规格。
对于频率计来说,常用的输入方式有脉冲输入和信号输入,输出方式一般为显示屏或串口输出。
根据实际需求选择适合的输入输出接口和显示屏类型。
接下来,我们需要编写程序来实现频率计的功能。
首先,通过配置单片机的IO口为输入或输出,将脉冲输入连接到IO口上。
利用单片机的计时/计数功能,统计脉冲的数目,并将其转换成频率值。
然后,将频率值显示在显示屏上,以便用户查看。
在编写程序时,需要考虑到时钟频率和计数器的精度。
可以通过设置单片机的时钟频率,提高计数的精度。
同时,还可以根据实际情况选择合适的计数器,以适应不同的频率范围。
此外,还可以增加一些附加功能,如保存测量结果、设置警报阈值等。
通过设置相应的变量和标志位,可以实现这些功能,并通过显示屏或串口输出进行反馈。
最后,我们需要进行硬件连接和软件开发。
将单片机与显示屏、输入输出接口等相连,进行适当的调试和测试。
在开发过程中,需要注意硬件和软件的一致性,并及时修正错误和缺陷。
总之,基于AT89C51单片机的嵌入式频率计是一种简单而实用的测量仪器。
通过合理的硬件设计和软件开发,可以实现准确、稳定的频率测量,并具备一定的附加功能。
这种频率计不仅适用于实验室、工厂和仪表等领域,还可以用于学习和教育等用途。
基于测试调频信号的AT89C2051数字频率计的软件设计【摘要】数字频率计主要包含了对输入信号的整形、计数、显示三个部分。
本文介绍了软件部分主要包括实现选择对不同分频信号计数程序、对数据处理程序及显示程序。
在此采用了以AT89C2051单片机为核心的直接测频法。
【关键词】数字频率计;单片机;显示1.引言数字频率计是直接用十进制码来显示被测信号频率的一种测量装置。
作为一种基础测量仪器,已在教学、科研、高精度仪器测量、工业控制等领域有较广泛的应用。
试验中设计的频率计测量的频率范围在1Hz-10MHz之间。
能够测量任何该频率段内的周期信号的频率,延时要小,测量迅速,以十进制数显示,便于读数,单位以Hz或KHz显示,自动转换单位。
方案1:目前市场上的频率计多数使用专用计数芯片和数字逻辑电路计数,测量原理图如图1所示。
图1 计数芯片设计频率计的基本原理计数芯片是通过外部时钟电路产生的时间基准信号控制计数器的计数和保持状态的,计数器的测量精度很大程度上就取决于时间基准信号的精度。
其次,要实现量程转换,需要人为选择量程,对时钟电路产生的时间信号分频得到不同量程所需的时间基准信号,完成一次计数后要对电路产生控制信号送入计数器,使计数器清零以便下一次计数,这使得电路比较复杂。
再者,这种专用芯片的价格比较高,就决定了制作的频率计的成本会很高。
基于以上考虑,就否定了这种用计数芯片计数的方法。
方案2:现在单片机的使用比较广泛,我们可以考虑用单片机设计频率计。
使用单片机设计时通常采用两种办法:1)使用单片机自带的计数器对输入脉冲进行计数,或者测量信号的周期;2)单片机外部使用计数器对脉冲信号进行计数,计数值再由单片机读取。
这里我们用第一种的直接测频法。
以AT89C2051单片机为核心,利用其内部的定时(计数)器来完成待测信号频率的测量。
单片机的其中一个定时/计数器定时,另一个计数。
另外还可以通过软件编程实现自动换档,使电路结构大为简化。
无锡职业技术学院毕业设计说明书(英文翻译)A Digital Thermometer Design Using the AT89C2051IntroductionAlong with the time progress and the development, the monolithic integrated circuit technology already popularized to us lives, the work, the scientific research, each domain, will already become one kind of quite mature technology, this article introduced one kind the digital thermometer which controlled based on the monolithic integrated circuit.This design introduced the digital thermometer and the traditional thermometer compares, has the reading to be convenient, measured the warm scope is broad, measured warm accurate, its output temperature uses the numeral to demonstrate, mainly uses in to measured the warm quite accurate place, or the scientific research laboratory use.The system presented in this application note implements a simple digital thermometer thatincludes a built-in LCD and RS-485 communication port. It is designed aroundAtmel'AT89C2051 processor, a DS1620 digital thermometer /thermostat from Dallas Semiconductor, a small 8*2 LED backlit LCD, and an RS485 line interface. The system, shown in Figure 5.6, can be used as the basis for developing custom solutions for networked and stand alone data collection and control equipment. It can be centrally powered due to its low current requirement and its small size allows it to be placed almost anywhere.●SoftwareThe LCD driver is written entirely in C and compiled under Micro-C (from Dun-field Development Systems ) using the tiny memory model. Although a canonical stack-based implementation, Micro-C includes a number of special features that make it quite suitable for generating ROMable code for small systems. The overhead incurred performing stack manipulations is made up by the library functions that are all hand coded in a highly optimized assembler. As an added benefit, Micro-C comes with fully documented library source code so special modifications can be made as circumstances arise.The first few functions contained in the LCD driver module are conventional C library implementation. PutString displays a null terminated string by merely passing characters off to PutChar until a null byte is encountered. PutChar outputs a character at a time to the LCD and handles the newline character by advancing the cursor address to the value specified by the caller. The ClearLcd function is used to clear the entire LCD and home the cursor.The functions that follow concern themselves with actual physical communication to the LCD. Since there is not a direct correspondence between the LSI’s data RAM and the LCD’s physical mapping, it is necessary to keep watch for certain boundary conditions. When a boundary is encountered, the cursor must be repositioned in order to keep the output contiguous. Since all displayable data must pass through DataWr, it makes sense to contain the corrective actions here. To handle this problem, keep track of the logical cursor positon and invoke a remedial maneuver whenever discontinuity may occur, there are two ways you can accomplish this: Read the LCD’status re gister (to get the cursor address) or Keep a local copy just for your reference.Not wanting to waste a pin to control the LCD’s read/write line (it runs in write-only mode), the latter approach was adopted.Here, the global register (IRAM actually) variable Cursor is used for this purpose. Cursor is consulted prior to any data write operation. If a correction is necessary, a new cursor address is generated and dispatched to the LCD control register via Command Wr.Following this, DateWr splits the data byte into nibbles (remember the LCD operates using a 4-bit bus) and falls through to handle the actual physical transfer. Using Micro-C’s extended preprocessor allows bit manipulation macros that expand directly to 8051 SETB and CLR instructions. Here, clear ing DRS selects the LCD’data register and DEN is toggled to generate the data strobe. Command Wr operates similarly but does not have to deal with any cursor entanglement. It selects the command register as its destination by seting DRS high prior to clocking the nibbles across the interface.The initialization function InitLcd begins at a more rudimentary nibble oriented level since no assumption can be made as to the operational status of the LCD at this time. The first three sequences ensure that the transfer mode is set to operate over a 4-bit bus. Repeating the sequence three times ensures that the command will be recognized regardless of the operational mode of the LSI. (It is wise to make no assumptions when performing any low-level initialization.) Following this, the actual operating parameters are transferred to the LCD using the standard CommandWr function. Software for this application note may be downloaded from Atmel’s Web Site or BBS.●MCUAT89C2051 MCU is a series of 51 members, It is the 8051 version of SCM. It has the following characteristics: 2 k bytes EPROM, 128 bytes RAM, 15 I / O lines, two 16 regular /counter, two five vector interrupt structure, a full two-way serial port, and includes Precision analog comparator and on-chip oscillator, a 4.25 V to 5.5 V voltage scope of work and 12 MHz/24MHz frequency, and also offers the encryption array of two program memory locking, power-down and the clock circuit.In addition, AT89C2051 also supports two kinds of software-selectable power-saving mode power supply. During my free time, CPU stop and let RAM, timing / counter, serial port and interrupt system to continue to work. Power-down can preserve the contents of RAM, but will stop oscillator chip-to prohibit all the other functions until the next hardware reset.Therefore, AT89C2051 constitute the SCM system is a simple structure, the cost of the cheapest, most efficient micro-control system, eliminating the external RAM, ROM and interface devices, reducing hardware costs, cost savings, improved The cost-effective system.MCU clock signal used to provide various micro-chip microcontroller operation of the benchmark time, the clock signal is usually used by the form of two circuits: the internal and external shocks oscillation. MCS-51 has a microcontroller internal oscillator for a reverse of the high-gain amplifier, pin XTALl and XTAL2 are here to enlarge the electrical inputs and outputs, as in-house approach, a simple circuit, from the clock Signal relatively stable, and actually used often in this way, as shown in Figure 5.6 in its external crystal oscillator (crystal) or ceramic resonator constituted an internal oscillation, on-chip high-gain amplifier and a reverse Feedback components of the chip quartz crystal or ceramic resonator together to form a self oscillator and generate oscillation clock pulse. Figure 5.6 in the external crystal and capacitors C1 and C2 constitute a parallel resonant circuits, their stability from the oscillation frequency, rapid start-up role, and its value are about 33 PF, crystal frequency of elections 12 MHz.In order to initialize the internal MCU some special function register to be reset by the way, will reset after the CPU and system components identified in the initial state, and from the initial state began work properly.MCU is reset on the circuit to achieve, in the normal operation of circumstances, as long as the RST-pin on a two machine cycle time over the high, can cause system reset, but if sustained for the RST-pin HIGH, in a circle on the MCU reset state.There are two situations in which a power-on reset and manual (switch) reduction. The system uses a power-on reset mode. Figure 5.6 in the R0 and C0 formed a power-on reset circuit, and its value for R for 8.2 K, C for the 10 uF.Digital TemperatureTemperature acquisition is handled using the DS1620 thermometer/thermostat IC from Dallas Semiconductor. The DS1620 contains all temperature measurement and signal conditioning circuitry on-chip and presents the processor with a 3-wire digital interface composed of a bi-directional data line DQ, a reset input \RST, and a clock input CLK. The temperature reading is provided in a 9-bit, two’s complement format. The measurement range spans from -55℃ to +125℃ in 0.5℃ increments. Data transfers into and out of the DS1620 are initiated by driving /RST high. Once the DS1620’s reset is released, a series of clock pulses is emitted by the processor to actually transfer the data. For transmission to the DS1620, data must be valid during the rising edge of the clock pulse. Data bits received by the processor are output on the falling edge of the clock and remain valid through the rising edge. Taking the clock high results in DQ assuming a high impedance state. The sequence can be immediately terminated by pulling \RST low which forces DQ into a high impedance state and concludes the transfer. Temperature data is transmitted over the 3-wire bus in lsb first format. A total of nine bits are transmitted where the most significant bit is the sign bit. If all nine bits are not of interest, the transfer can be terminated at any time by asserting \RST.The DS1620 support routines are coded in assembly. The DS1620 also has nonvolatile EEPROM configuration register that hold thermostatic and operational control information. TempConfig is hard-coded to set the mode for operation under CPU control and continuoustemperature conversion. Once in continuous conversion mode, the actual conversion process is started by issuing the start conversion command through TempConvert. Now the DS1620 can be read at any time and the last temperature conversion that was performed will be returned. This is accomplished by calling TempRead. The result is returned in the 16bit accumulator as defined by Micro-C consisting of the B (msb) and ACC (lsb) register.●Mainline Glue 360毕业设计网Coordination of the support drivers is managed by the main module. This module takes control after the Micro-C startup routine finishes. On entry, the code initializes the serial prot, instructs the DS1620 to start performing temperature conversions, initializes the LCD, displays a log on message, and enters into an endless loop. This loop continuously reads the DS1620, performs a Celsius to Fahrenheit conversion, translates the resulting binary number to an ASCII string, and displays the conversion result on the LCD. Periodically the code falls through and toggles an LED and transmits the temperature data serially.The Celsius to Fahrenheit conversion is performed using the familiar equation: F=C*9/5+32.Since the DS1620 returns temperature in 5℃ increments the value is first divided by 2.Unlike the often impenetrable gyrations that result when working with numbers in assembler, the C representation of this calculation is perfectly clear in intent and function. A short sequence of divisions, modules, and logical OR operations results in decimal ASCII values that make up the output string.基于AT89C2051的数字温度计的设计●导言随着时代的进步和发展,单片机技术已经普及到我们生活、工作、科研和各个领域,已经成为一种比较成熟的技术。
・产品与市场・收稿日期:2006-12-14作者简介:钱进,女,实验师。
主要从事电工电子实验与实训教学及开发应用的研究。
基于AT89C2051的高精度数字频率计的设计钱进(湖南冶金职业技术学院,湖南株洲412000)摘要:针对普通频率计存在读数难、测量精度不高等缺点,提出了一种实用性较强的用单片机控制的高精度数字频率计控制电路系统的实现方法,具有广阔的应用前景。
关键词:单片机控制;高精度数字频率计;电路设计中图分类号:TP932文献标识码:A文章编号:1002-6673(2007)01-086-020引言针对普通频率计存在读数难、测量精度不高等问题,目前采用单片机控制的数字频率计,用于测量方波、正弦波或其它脉冲信号的频率,并用十进制数字显示,具有精度高、测量迅速、读数方便等优点,已在电子测量领域里得到了广泛应用。
本文利用单片机AT89C2051、74LS245总线接口实现最大读数(0~9999kHz),WD05011AG-10驱动器的数据显示,极大地方便了用户的使用。
1硬件电路的设计系统由AT89C2051-24PI中央处理单元、时钟芯片、译码/驱动器芯片、放大整形芯片、数据显示器WD05011AG-10等部分组成[1]。
硬件系统组成框图如图1所示。
1.1电路测量原理脉冲信号的频率就是在单位时间内所产生的脉冲个数,其表达式为f=N/T,其中f—被测信号的频率;N—计数器单位时间所累计的脉冲个数;T—单位时间。
如在1s内记录1000个脉冲,则被测信号的频率为1000kHz。
晶振产生较高的标准频率,经单片机电路分频后可获取各种时基信号(1ms、10ms、0.1s、1s等)。
被测频率的输入信号经放大整形后变成矩形脉冲直接加到单片机的主控门P3.5(T)计数端。
只有在闸门信号采样期内(时基信号的一个周期),输入信号才通过主控门。
若时基信号的周期为T,进入计数器的输入脉冲数为N,则被测信号的频率=N/T,改变时基信号的周期T,即可得到不同的测频范围。
当主控门关闭时,经延时整形电路的延时后,延时电路输出一个复位信号,使计数器和所有的触发器置0,为后续新的一次采样作好准备,即能锁住一次显示的时间,直到接受新的一次采样为止。
显示方式采用七段LED数码管显示读数,做到显示稳定、不跳变。
1.2主控单片机芯片的选择STC8051单片机与其它系列单片机存在的区别在于:第一,加密性强,无法解密;第二,超强抗干扰。
单片机内部的时钟电路、复位电路、看问狗电路都经过特殊处理,高抗静电、宽温度范围;第三,三大降低单片机时钟对外部电磁辐射的措施;第四,超低功耗;第五,在系统可编程,无须编程器,无须仿真器。
由于本设计的频率计的频率测量范围在0~1MHz,参照STC89系列单片机选型表,故选用质优价廉、功耗低、超强抗干扰的STC8051微处理器来完成即可[2]。
1.3脉冲整形电路的设计根据脉冲整形电路的要求,微分、整形电路如图2所示。
图中被测信号所产生的上升沿经微分电路后,送到由CD40106组成的斯密特整形电路的输入端,在其输出端可得到一个边沿十分陡峭且具有一定脉冲宽度的负脉机电产品开发与创新Development&Innovationofmachinery&electricalproductsVol.20,No.1Jan.,2007第20卷第1期2007年1月图1硬件系统组成框图Fig.1HardwareSystemcompositiondiagram复位电路晶振外测信号放大整形RSTAT89C205124PIP3.5(T1)74LS245译码/驱动数显LED86・产品与市场・DesignoftheMonolithicIntegratedCircuitControlsHighAccuracyNumeralFrequencyMeterQIANJin(HunanMetallurgicalProfessionalTechnologyCollege,ZhuzhouHunan412000,China)Abstract:Thisarticleinviewofordinaryfrequencymeterexistencereadingdifficult,measuringaccuracynothighershortcoming,proposedoneusabilitystrongthehighaccuracynumeralfrequencymetercontrolcircuitsystemrealizationmethodwhichcontrolswiththemonolithicintegratedcircuit,hasthebroadapplicationprospect.Keywords:MonolithicintegratedcircuitcontrolL HighaccuracynumeralfrequencymeterL Circuitdesign图2微分、整形电路Fig.2Differential、reshapingelectriccircuit外被测信号1K10μF/50VCD40106延时电路图3RC复位电路Fig.3RCRepositionstheelectriccircuitVCCD4148R110KRSTSBC122μC2104图4程序流程图Fig.4Programflowdiagram开始指向缓冲区指向最左一个显示位取出待显字符指向换码表首址段选码地址送R1输出段选码位选码地址送R1输出位选码延时指向一下待显示字符6位显示完否?NY结束冲[2],然后再送至单片机的延时电路。
1.4译码驱动显示电路的设计由于本设计被测信号的频率范围在0~1MHz,故选用74LS245BCD译码芯片进行译码,选用6个共阴数码管分别显示低三位和高三位的数据,由其中的一片VLN2003芯片的数据选择输出端DS1~DS3完成位控显示输出的控制即可。
1.5复位电路的设计复位电路的基本功能是在系统上电时提供复位信号,直至系统电源稳定后,撤消复位信号。
为可靠起见,电源稳定后还要经一定的延时才撤消复位信号,以防电源开关或电源插头分—合过程中引起的抖动而影响复位。
图3所示RC复位电路可以实现上述基本功能。
SB手动复位开关,C2可避免高频谐波对电路的干扰。
复位电路增加了二极管,在电源电压瞬间下降时使电容迅速放电,一定宽度的电源毛刺也会使系统可靠复位[3]。
2控制程序的设计将AT89C2051作为控制主机,C51的P1.0—P1.7口作为数据传送通道,P3.0(RXD)、P3.1(TXD)、P3.2(INT0)、P3.3(INT1)、P3.4(T0)、P3.7(RD)设置为输出控制位控控驱动的操作。
在数据检测过程中,外侧信号向C51的P3.5(T1)计数器端口发送数据并计数,C51接收数据后通过查询方式,调用接收数据子程序来实现数据的接收。
LED显示方式采用动态显示方式。
2.1七段LED的显示程序的设计为了直接驱动7段LED的段选码,必须实现代码转换。
首先要开辟一个显示缓冲区,将待显示的字符预先存放在缓冲区中,由于有6位7段LED显示器,不妨假设显示缓冲区为6B,显示缓冲区的地址为10H~15H,并约定10H与最左一位显示器相对应,15H与最右一位显示器相对应,通过软件实现轮流点亮每个7段LED[4]。
程序流程图如图4所示。
2.2段选码转换表程序段选码转换表程序清单如下:SEGTBLDB3FH;对应于字符0DB06H;对应于字符1DB5BH;对应于字符2DB4FH;对应于字符3DB66H;对应于字符4DB6DH;对应于字符5DB7DH;对应于字符6DB07H;对应于字符7DB7FH;对应于字符8DB67H;对应于字符9DB77H;对应于字符ADB7CH;对应于字符BDB39H;对应于字符CDB5EH;对应于字符DDB79H;对应于字符EDB71H;对应于字符FDB40H;查表偏移量为10HDB00H;不显示任何字符查表偏移量为11H延时1ms子程序(略)。
2.3显示子程序每次调用一次显示DISUP子程序,可以显示缓冲区中的6个字符轮流逐一显示一次,每个字符显示时间为1ms,为了使显示的字符稳定下来,必须反复调用该子程序,由于反复调用,给人以6个字符“同时”显示的感觉[4]。
程序(略)。
3结束语由于本设计采用了单片机控制与数字显示,有效地克服了普通频率计读数难、测量精度低等存在的问题。
实践证明,该系统的设计可以很好地满足方波、正弦波或其它脉冲信号的频率测量。
参考文献:[1]何立民.MCS-51系列单片机应用系统设计-系统配置与接口技术[M].北京:航空航天大学出版社,1991.[2]单片机与嵌入式系统应用[M].北京航空航天大学出版社,2006,8.[3]佟云峰.单片机原理及其应用[M].重庆大学出版社,2004.[4]白驹绗,等.单片计算机及其应用[M].电子科技大学出版社,2001.[5]刘守义,等.数字电子技术[M].西安电子科技大学出版社,2003.87。