Design of a Low-Frequency Digital Phase Meter Based on a Microcontroller
2026-04-06 05:56:39··#1
Frequency is one of the important parameters of a signal, and obtaining accurate data for this signal has become increasingly important in the information field [1, 2]. Phase measurement has important applications in signal extraction, detection, and processing [3]. This design uses the 89C52 microcontroller and a programmable logic device (CPLD) as its core, utilizes the microcontroller for data processing and display of results, and implements the software in assembly language, thus forming a low-frequency signal frequency and phase measuring instrument. [b]1 System Working Principle[/b] This design uses the 89C52 microcontroller and a programmable logic device (CPLD) as its core to form a low-frequency signal frequency and phase measuring instrument. This instrument has two main functions: phase shifting and frequency and phase measurement. The phase-shifting circuit consists of a phase-shifting network and a signal amplification circuit, which can meet the phase shift requirements of -45 to +45 for fixed frequency signals (100 Hz, 1 kHz, 10 kHz); the frequency and phase measurement circuit consists of an impedance transformation circuit, a shaping circuit, a frequency division circuit, a counter circuit, a latch, a data processing circuit, and a display circuit, which can measure the frequency and phase of signals from 10 Hz to 20 kHz. The microcontroller system is the core of the entire hardware system. It is both the controller that coordinates the operation of the whole machine and the data processor, and it completes the control of the final display. (1) The microcontroller 89C52 (with 8 kB FLASH ROM), the address latch 74LS573, and the data memory 6264 (with 8 kB of internal RAM) are composed of [4]. (2) The data processing mainly determines whether the input signal is for frequency or phase measurement and completes the functions of frequency and phase measurement. (3) The display circuit consists of a control panel and a display interface chip 8279.**2 Accuracy Analysis** This design requires the absolute error of phase measurement to be ≤1°. Therefore, the requirement can only be met if the count value exceeds 360 times in one cycle of the measured signal. For a measured signal frequency of 20 kHz, its period is 50 μs. Within 50 μs, the count value is 360 times. From this, the frequency of the time base signal can be calculated as 20 kHz × 360 = 7.2 MHz. Therefore, using an 8 MHz crystal oscillator as the time base signal source can fully meet the accuracy requirements [5]. **3 System Design Block Diagram** The system design block diagram is shown in Figure 1. **4 Implementation of Frequency and Phase Measurement** The frequency and phase measurement circuit is the main content of this design. This part is completed using a programmable logic device (CPLD) and controlled by a microcontroller. The assembly program of the microcontroller is written according to the design principle of the CPLD [6, 7]. Figures 2 and 3 are the flowcharts for frequency and phase measurement, respectively. For ease of explanation, a system structure diagram is shown in Figure 4. CPLD circuit description: First, the P1.1 scan controls the 74257 (2-to-1) circuit to select whether to measure frequency or phase. If the level is high, frequency measurement is performed. The microcontroller generates a second signal (the number of pulses in 1 second) through 10 interrupts. The counter is a 24-bit counter composed of six 74193 chips, latched by a latch, waiting for the microcontroller to read it. If the level is low, phase measurement is performed. During phase measurement, the frequency measurement program is called first but not displayed; instead, it is stored for later use. Then, the D flip-flop is cleared; otherwise, the XOR value obtained will be different, as shown in Figure 3. a′ and b′ are XORed to generate a phase signal and an interrupt request is issued. The pulse generated by ANDing this signal with an 8 MHz time base signal is counted by a counter, and the count is then latched by a latch, waiting for the microcontroller to read it.[b]5 Conclusion[/b] This paper uses a microcontroller and a programmable logic device (CPLD) as the core components of a low-frequency digital phase measuring instrument. The 89C52 microcontroller is used for data control and processing, and the data is displayed on the monitor. The hardware structure is simple, and the software is implemented in assembly language, resulting in a simple, readable, and highly efficient program. Compared with traditional circuits, it has the advantages of fast processing speed, high stability, and high cost-effectiveness. References [1] Joseph J. CARR. Radio Frequency Circuit Design Theory and Application [M]. Beijing: Electronic Industry Press, 2002. [2] Ken C. Phkmann. Digital Audio Principles and Applications [M]. Beijing: Electronic Industry Press, 2002. [3] Zhang Juesheng, Zhang Huining, Xing Jing. Phase-Locked Loop Frequency and Computation [M]. Beijing: Electronic Industry Press, 1997. [4] Yu Yongquan. ATMLE89 Series Microcontroller Application Technology [M]. Beijing: Beijing University of Aeronautics and Astronautics Press, 2002. [5] Zhou Mingde. Microcomputer Principles and Applications [M]. Beijing: Tsinghua University Press, 1998. [6] Zhang Yingxin. Single-Chip Microcomputer Principles, Applications and Interface Technology [M]. Beijing: National Defense Industry Press, 2003. [7] Feng Tao, Wang Cheng. Programmable Logic Device Development Technology [M]. Beijing: Electronic Industry Press, 2002. Editor: He Shiping