Design of frequency measurement module circuit using microcontroller as core

Publisher:SparklingMoonLatest update time:2023-06-19 Source: elecfans Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

introduction

With the development and popularization of radio technology, "frequency" has become a physical quantity familiar to the general public. The emergence of microcontrollers has brought many major leaps to various measurement technologies, including frequency measurement. However, the advantages of small size, low price, and powerful functions also occupy a very important position in the electronic field. to this end. This article gives a design method for a frequency measurement system with a microcontroller as the core.


1. Hardware structure of frequency measurement system

Frequency measurement methods are generally divided into three types: passive frequency measurement method, active frequency measurement method and electronic counting method. Passive frequency measurement method (can be divided into resonance method and bridge method) is often used for rough frequency measurement, with an accuracy of about 1%. The active comparison method can be divided into beat frequency method and difference frequency method. The former uses the linear superposition of two signals to produce a beat frequency phenomenon, and then measures the frequency by detecting the zero beat phenomenon. It is often used for low-frequency measurements, and the error is within a few tenths of Hz; The latter uses the superposition of two nonlinear signals to produce a difference frequency phenomenon, and then measures the frequency by detecting the homodyne phenomenon. It is often used for high-frequency measurements, and the error is about ±20 Hz. The above methods have certain deficiencies in measurement range and accuracy, while the electronic counting method is mainly controlled by a microcontroller. Due to the strong control and computing functions of the microcontroller, the electronic counting method has a wide measurement frequency range, high precision, and is easy to implement. This design uses the microcontroller electronic counting method to measure frequency. The system hardware principle block diagram is shown in Figure 1.

Design of frequency measurement module circuit using microcontroller as core

In order to improve the measurement accuracy and expand the frequency measurement range of the microcontroller, this design adopts the method of frequency division of the signal. In the design, two synchronous decimal adding counters 74LS160 are used to form a 100 frequency divider. This 100 divider is designed by two synchronous decimal adding counters 74LS160 and a NAND gate 74LS00. Since a 74LS160 can divide the frequency to the power of ten, and when the first 74LS160 is working, if there is a carry, the output terminal TC will have a carry signal sent to the CEP terminal of the second chip, and at the same time, CET is also high level, so that the two The two working status control terminals CET and CEP will be high level at the same time. At this time, the second 74LS160 will start to work.


2. Circuit design of frequency measurement module

There are two ways to measure frequency using the microcontroller electronic counting method: frequency measurement method and period measurement method. The measurement frequency is mainly to count the pulses of the measured signal in unit timing time; the measurement period is to count the pulses of a certain reference clock in one cycle of the measured signal.

2.1 Error analysis of 8051 frequency measurement method

The electronic counter frequency measurement method mainly adds the measured frequency signal to the counting input end of the counter, and then allows the counter to count within the standard time Ts1 to obtain the count value N1. The relationship with the frequency fx1 of the signal under test is as follows:

The electronic counter cycle measurement rule is to send the standard frequency signal fs2 to the counting input end of the counter, and let the measured frequency signal fx2 control the counting time of the counter. The relationship between the obtained count value N2 and fx2 is as follows:

In fact, no matter which method is used for frequency measurement, the main source of error is the ±1 error caused by the fact that the counter can only count integers:

It can be seen that under the same Ts, the error at the low-frequency end of the frequency measurement method fx1 is much larger than the high-frequency end, while the error of the cycle measurement method at the high-frequency end of fx2 is much larger than the low-frequency end. Theoretical research shows that if n repeated measurements are taken and then averaged, the ±1 error will be reduced by n times. If the ±1 error ε0 is given, it is required that ε ≤ ε0. The frequency measurement method requires fx1 ≥ and the period measurement law requires fx2 ≤ ε0 fs2. Therefore, when measuring a given frequency signal fs, the lower the frequency measurement method fs1, the better. Using the week measurement rule, the higher the fs2, the better.

2.2 Frequency measurement range and frequency measurement time of 8051 microcontroller

For the timer/counter interface of the 8051 microcontroller, when the specific crystal oscillator frequency fc=12 MHz, the upper limit of the input signal frequency is fx≤fc/24=500 kHz. If the frequency measurement method is used, the upper limit of the frequency depends on 8051, so the measurement range of the frequency measurement method is:

That is: fx1≤500 kHz.

When measuring frequency by frequency measurement method, the counting time interval of the timer/counter can be completed by another timer/counter of 8051. When an external 100 frequency divider is connected, the frequency range of fx1 can be extended to 50MHz.

When designing with the cycle measurement method, the lower limit of its frequency depends on the limit of the 8051 counter. Considering that the 8051 is internally 16 bits, plus the TF flag, the counting range is 217, so its maximum counting time is seconds. If half-cycle measurement is used, the frequency measurement range is:

In the cycle measurement method, the standard frequency signal fs2 is generated by the internal timing structure of the 8051, and f s2 is always fc/12. Therefore, when ε0 is 0.0 1, fx2 has both a certain upper limit frequency and a certain lower limit frequency. . Right now:

It can be seen from this that: 4Hz ≤ fx1 ≤ 10 kHz can theoretically reach infinity, that is, fs1 can reach infinitesimal low, therefore, fx1 can reach infinitesimal. Therefore, it can be considered that the frequency measurement range of the frequency measurement method only has the upper limit frequency and no lower limit. frequency. And again, by superimposing the two frequency ranges, the frequency measurement range of the frequency meter can be obtained: 4 Hz ≤ fx1 ≤ 50 MHz. The accuracy can reach 1Hz. From the above analysis, it can be seen that the frequency coverage range measured by the frequency measurement method is wider, and the measurement accuracy at the high frequency end is higher, while the measurement accuracy at the low frequency band is lower, and the measurement time is longer. The frequency coverage range measured by the perimetric method is narrow, the measurement accuracy in the high frequency band is low, and the measurement accuracy in the low frequency band is high, and the measurement time is short. Therefore, the frequency measurement method is suitable for the measurement of high-frequency signals, and the cycle measurement method is suitable for the measurement of lower-frequency signals.

8051 can use software to control the working mode of the timer/counter to achieve dynamic switching between the frequency measurement method and the cycle measurement method. For wide-band, high-speed frequency measurement, software switching measurement methods can be used to improve measurement accuracy and measurement speed. Its frequency measurement circuit is shown in Figure 2.

3. Software design

It can be seen from the frequency measurement circuit shown in Figure 2 that after the waveform passes through the Schmitt trigger 74LS132, it can become a square wave after being shaped and amplified, and then the timer/counter T0 of 8051 is used to set the timing time to 10 ms. Then use the timer/counter T1 of 8051 as a counter to accumulate the square wave signal of the Schmitt trigger 74LS132 that has passed through 10 ms. When T0 timing reaches 10 ms, T0 sends an interrupt signal to the CPU to apply for an interrupt and perform frequency measurement. Assume that the set intermediate frequency is l00/10 ms=l00×100=10000 Hz=10 kHz, and fx=N/T. Therefore, the assumed given value 100 can be compared with Tl, and then the value in the Tl counter The calculated value is compared with the given value. Because when measuring frequency with the frequency measurement method, the error at smaller frequencies is larger (±l error). Therefore, l0 kHz is used as the intermediate frequency here, and its ±1 error is 9.9 kHz and 10.1 kHz, with an error rate of 1%. It can be seen that the error is not very large and is acceptable.

In fact, when the frequency is less than 10kHz, if the program chooses to use the measurement period method. The flow chart and procedures of the cycle measurement method are shown in Figure 3.

4 Conclusion

Through the design process introduced in this article, the frequency measurement requirements can be achieved, the measurement results can be stored well, and the expected results can be achieved.


Reference address:Design of frequency measurement module circuit using microcontroller as core

Previous article:51 driver circuits for commonly used devices in microcontrollers
Next article:Bus LED screen designed based on 51 microcontroller

Recommended ReadingLatest update time:2024-11-16 10:34

Brief description of 8051 microcontroller architecture
The basic knowledge and pin diagram description of the 8051 microcontroller have been introduced before. In this article, we will focus on the hardware aspects of the 8051 microcontroller, such as I/O ports, RAM, ROM, timers and Serial port etc. Basic components of a microcontroller The difference between microproce
[Microcontroller]
Brief description of 8051 microcontroller architecture
Application of Haisuxin 8051 microcontroller TM52F1376 in electronic voting machines
The application of 8051 microcontroller can reduce the size, cost and complexity of electronic products. This article mainly introduces the application of Haisu core 8051 microcontroller TM52F1376 in electronic voting machines. TM52F1376 electronic voting machine application Electronic voting machines are tools th
[Microcontroller]
Introduction to 21 special registers of 8051/89C51
 8051/89C51 has a total of 21 special registers, some of which are briefly introduced as follows: (1) Program Counter (PC) PC is a 16-bit counter that controls the execution order of the program. Its content is the address of the next instruction to be executed, and the addressing range is up to 64KB. PC has the fun
[Microcontroller]
Design of low-cost ECG monitoring system based on C8051F320 microcontroller
  1 Introduction   Virtual medical instruments make full use of the rich software and hardware resources of computers. Only a small number of special software and hardware modules are added to realize all the functions of traditional instruments and some functions that traditional instruments cannot realize, while s
[Test Measurement]
Design of low-cost ECG monitoring system based on C8051F320 microcontroller
Use C8051F's serial port to send and receive data from MAX3232
System functions Use the serial port of C8051F to transmit and receive data to MAX3232. hardware design Serial port chip MAX3232 control circuit schematic diagram software design The following part is copied from TXT and copied to the web page. There are many spaces missing in the code part, so it is a bit messy
[Microcontroller]
Use C8051F's serial port to send and receive data from MAX3232
Countdown timer based on 8051 (flashing in the last 3 seconds)
The last 3 seconds of flashing is achieved by the variable t.  t divides the countdown of 26s (0 ~ 25 is 26s) into 2600 10ms intervals. When the value of t is less than 300, the 1000ms interval is divided into "500ms refresh number + 500ms no number display". #include STC89C5xRC.H   unsigned char code DIG_CODE =
[Microcontroller]
C8051F32X MCU AD data acquisition program
  (1) Description of AD data acquisition program      1) Brief description of the process      Use the 10-bit AD in the C8051F32X chip to collect 256 data (each data is 10 bits, occupying 2 bytes) and 512 bytes of data.   The TIME2 timer overflow is used to trigger the start of AD conversion.   When the AD data conver
[Microcontroller]
C8051F32X MCU AD data acquisition program
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号