Design and implementation of frequency measurement based on MCS-51 series single chip microcomputer

Publisher:心语如画Latest update time:2017-12-25 Source: eefocus Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

    There are many methods for measuring the frequency of periodic waves, but most of them are to calculate the frequency indirectly through measurement. This article introduces the use of the widely used MCS-51 series single-chip microcomputer to measure the frequency of periodic waves, and uses LED to intuitively display the frequency in digital form, realizing intelligent measurement and eliminating the trouble and errors of indirect frequency calculation. The article explains its measurement principle, design and implementation, introduces the main procedures, and conducts error analysis.

    At present, single-chip microcomputers are widely used in many fields of national economic construction and daily life, and have become an indispensable and important tool for the modernization of measurement and control technology. This article adapts to this development trend and applies the MCS-51 series single-chip microcomputer to the measurement of periodic wave frequency, which is automatically displayed through the LED display, which brings great convenience to the frequency measurement.


    Design Thoughts

    Schmitt triggers are used to transform periodic signals with slowly changing edges, such as sine waves, triangle waves, or analog signals of any shape, into rectangular pulses of the same frequency. The number of external pulses within a certain period of time is measured by two 16-bit timers/counters inside the MCS-51 series microcontrollers. After processing, the frequency of the added signal is directly displayed through the LED. TO inside the microcontroller is used for timing, and Tl is used for counting (falling edge triggering). When a counting pulse comes, it counts once. When TO starts timing, T1 starts counting; when TO timing 1s is up, T1 stops counting. The block diagram is shown in the figure below.

Block Diagram

    hardware design

Circuit

    The hardware circuit for measuring frequency mainly consists of two parts: counting pulse forming circuit and counting display circuit. The counting pulse forming circuit uses a "555" timer to form a Schmitt trigger to transform the external periodic wave so that the output is a rectangular pulse. The circuit is shown in the figure above, and the counting display circuit is shown in the figure below, which mainly includes:

Counting display circuit

    (1) An 89S02 single-chip microcomputer produced by INTEL with a crystal oscillator frequency of 12 MHz . Through software programming, its internal timer TO is set to time, and T1 counts the external pulses. Then the measurement result value is output through the PO port. The 89S02 has an 8K flash memory, which can store 90 to 100 field measurement data for playback and adjustment.

    (2) 4-digit seven-segment common cathode LED display.

    (3) Since the 4-bit common cathode dynamic scanning display is adopted, the segment code is provided by the PO port of 89S02, and the bit select line is provided by P2.0~P2.3 ​​of the P2 port of 89S02. Since the input and output ports of 89S02 cannot provide enough sink current , G1~G4 are used to provide enough display current to the LED.

    software design

    The program for measuring frequency using MCS-51 single chip microcomputer mainly includes: initialization program, timing counting program, LED display program. The initialization program is omitted. The main program of timing counting:

Time counting main program

Time counting main program

    Measuring range

    The maximum measurement frequency under the above program is 255Hz. After proper adjustment of the program, the maximum measurement frequency can be 1/12 of the main frequency of 89S02, but under the premise of ensuring measurement accuracy, the maximum measurement frequency should be arranged below 1/100 of the main frequency.

    Error Analysis

    The maximum measurement frequency of the above program is 255Hz. Since the microcontroller has 2 to 6 machine cycles when responding to an interrupt, according to the maximum error calculation, 6-2=4 machine cycles, the interrupt response occurs 20 times in 1s, and the most unfavorable cumulative error time is 4×20=80 microseconds. Therefore, the maximum error under this program is 80/1000000=0.08/1000. This accuracy can fully meet the needs of on-site detection.


Reference address:Design and implementation of frequency measurement based on MCS-51 series single chip microcomputer

Previous article:An Example of Extended Application of MCS-51 Single-Chip Data Memory RAM
Next article:51 MCU floating point operation principle

Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号