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.
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.
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
- Popular Resources
- Popular amplifiers
- MCU C language programming and Proteus simulation technology (Xu Aijun)
- Principles and Applications of Single Chip Microcomputers 3rd Edition (Zhang Yigang)
- Principles and Applications of Single Chip Microcomputers and C51 Programming (3rd Edition) (Xie Weicheng, Yang Jiaguo)
- STC32G Series MCU Technical Reference Manual
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- TGF4042 Function Signal Generator Review: Unboxing and Trial
- Wireless Alliance names Wi-Fi 6E for 802.11ax networks using 6GHz spectrum
- Exposing unscrupulous merchants [Jimu Microelectronics Flagship Store]
- esp32,stm32: add machine.I2S to support I2S protocol
- Two AT24C02 read and write examples on the I2C bus
- High power driver amplifier 55453 replacement problem, please recommend
- 【McQueen Trial】Python Programming (3)
- How to sign in on the mobile version?
- [Reprint] Summary of Zynq7010 NAND startup
- Free sharing of LDO and DCDC basic principle explanation video