CN-116520020-B - Self-adaptive frequency measuring device and method based on FPGA
Abstract
The invention aims to provide an FPGA-based self-adaptive frequency measuring device and a testing method, which have stronger adaptability, can be compatible with various measuring ranges, can improve measuring precision and can control measuring time. The invention comprises a high-speed voltage comparator, an FPGA frequency measuring module and an operation unit which are electrically connected in sequence, wherein the high-speed voltage comparator is connected with a measured signal, the high-speed voltage comparator converts the measured signal into digital pulses, the FPGA frequency measuring module performs measurement counting to obtain a counting result of the measured signal and a reference clock counting result, and the operation unit calculates the frequency of the measured signal. The invention is applied to the technical field of digital frequency measurement.
Inventors
- CHEN YUNJIA
- ZHANG GUOFU
- SONG XIAOFU
Assignees
- 成都市运泰利自动化设备有限公司
Dates
- Publication Date
- 20260512
- Application Date
- 20230330
Claims (2)
- 1. The self-adaptive frequency measurement device based on the FPGA is characterized by comprising a high-speed voltage comparator (1), an FPGA frequency measurement module (2) and an operation unit (3) which are electrically connected in sequence, wherein the high-speed voltage comparator (1) is connected with a measured signal (4), the high-speed voltage comparator (1) converts the measured signal (4) into digital pulses, the FPGA frequency measurement module (2) performs measurement counting to obtain a counting result of the measured signal (4) and a reference clock counting result, and the operation unit (3) calculates the frequency of the measured signal (4); The FPGA frequency measurement module (2) comprises a frequency prediction module (21), a frequency counting module (22) and a frequency output module (23) which are electrically connected in sequence, the frequency prediction module (21) comprises an edge detector (211), a prediction counter (212), a counting comparator (213), a low-frequency mark register (214) and a time setting register (215) which are electrically connected in sequence, the frequency counting module (22) comprises a timing counter (221), a first gate generator (222), a second gate generator (223) and a third gate generator (224) which are electrically connected in sequence, the second gate generator (223) is connected with a measured signal counter (225), the third gate generator (224) is connected with a reference clock counter (226), the frequency output module (23) comprises a measured signal counting result register (231), a data selector (232) and a reference clock counting result register (233), the measured signal counter (225) is connected with the measured signal counting result register (231) through a low-valid enable source code buffer, the reference clock counter (226) is connected with the reference clock counter (233) through the low-valid source code register, the edge detector (211) and the detected signal counter (225) are connected to the detected signal (4); The prediction counter (212) is connected with the reference clock counting result register (233) through a high-efficiency enabling source code buffer, the counting comparator (213) is connected with the time setting register (215) and the data selector (232), a 1-setting signal is connected with the measured signal counting result register (231) through the high-efficiency enabling source code buffer, the time setting register (215) is connected with the timing counter (221), the timing counter (221) is connected with the data selector (232), and the low-frequency flag register (214) is respectively connected with the enabling ends of the two low-efficiency enabling source code buffers and the two high-efficiency enabling source code buffers.
- 2. A test method for an FPGA-based adaptive frequency measurement device according to claim 1, the test method comprising the steps of: Step A, the high-speed voltage comparator (1) converts the detected signal (4) into digital pulses with the same frequency and transmits the digital pulses to the edge detector (211); Step B, the edge detector (211) detects a complete period of the detected signal (4), in which the prediction counter (212) is enabled to start counting the reference clock, and when the complete signal period is finished, the count value of the prediction counter (212) is sent to the count comparator (213), and the count comparator (213) outputs a comparison result by comparing the size range of the count value, so as to roughly judge the period size, namely the frequency range, of the detected signal (4); Step C, the low-frequency flag register (214) generates a low-frequency flag according to the size of the frequency range, so as to control whether the time setting register (215), the measured signal counter (225) and the reference clock counter (226) are disabled; the step C comprises the following subdivision steps: Step C1, when the comparison result shows that the count value is large enough, that is, the signal frequency is low enough, the low frequency flag register (214) generates a low frequency flag, the time setting register (215), the count value of the measured signal counter (225) and the count value of the reference clock counter (226) are disabled, the measured signal count result register (231) is set to 1, and the count value of the prediction counter (212) is transmitted to the reference clock count result register (233); Step C2, when the comparison result shows that the count value is small enough, that is, the signal frequency is high enough, the value of the measured signal count result register (231) is the count value of the measured signal counter (225), the value of the reference clock count result register (233) is the output value of the data selector (232), and the output value of the data selector (232) is determined by the comparison result of the count comparator (213); Step C2.1, when the comparison result shows that the frequency of the detected signal (4) is lower than the reference clock, the output value of the data selector (232) is the count value of the reference clock counter (226), the value of the detected signal count result register (231) is the count result of the second gate generator (223), and the value of the reference clock count result register (233) is the count result of the third gate generator (224); Step C2.2, when the frequency of the detected signal (4) is higher than a reference clock, the output of the data selector (232) is the measurement time count value of the timing counter (221), the value of the detected signal count result register (231) is the count result of the second gate generator (223), and the value of the reference clock count result register (233) is the count result of the first gate generator (222); And D, outputting a measured signal counting result S1 by the measured signal counting result register (231), outputting a reference clock counting result S2 by the reference clock counting result register (233), wherein the reference clock frequency S3 is a known value, and calculating the frequency f of the measured signal (4) by the operation unit (3) according to the measured signal counting result S1, the reference clock counting result S2 and the reference clock frequency S3, wherein the frequency f of the measured signal (4) is equal to the reference clock frequency S3, and the measured signal counting result S1/the reference clock counting result S2 are calculated by the operation unit (3).
Description
Self-adaptive frequency measuring device and method based on FPGA Technical Field The invention is applied to the technical field of digital frequency measurement, and particularly relates to an adaptive frequency measurement device and a test method based on an FPGA. Background The digital frequency measuring method includes three kinds of direct measuring method, indirect measuring method and other accurate measuring method. The direct measurement method is to generate a gate signal by counting a reference clock, count the period of a signal to be measured in the time of the gate signal, and calculate the frequency of the signal to be measured according to the proportional relationship among the frequency of the reference clock, the number of the reference clocks and the period of the signal to be measured. However, in the direct measurement method, when the frequency of the measured signal is measured directly by counting the measured signal through the reference clock, the measurement error is derived from +/-1 measured signal period. The larger the period of the measured signal is, the lower the frequency is, and the larger the error is, so that the method is only suitable for high-frequency measurement scenes. The indirect measurement method is to count the reference clock in one period of the measured signal, calculate the period of the measured signal and calculate the frequency of the measured signal. The indirect measurement method determines the period of the measured signal by counting the number of reference clocks in one period of the measured signal, so that the frequency of the measured signal is converted, and the measurement error is derived from +/-1 reference clock period. However, in order to ensure the measurement accuracy of this method, the period of the measured signal is required to be sufficiently large relative to the reference clock, and thus is only suitable for a low-frequency measurement scenario. The equal precision measurement method is to generate a gate signal by counting the period of a detected signal, count a reference clock in the gate signal time, and calculate the frequency of the detected signal according to the proportional relation among the frequency of the reference clock, the number of the reference clocks and the period of the detected signal. However, in the equal-precision measuring method, when the measured signal passes through, the reference clock is counted, the frequency of the measured signal is calculated according to the proportion relation, the measuring error of each frequency range is derived from +/-1 reference clock period, and the full-frequency range measuring and other precision is ensured. However, a reasonable count value needs to be set for the number of measured signal cycles, otherwise, the measurement result is still inaccurate or the measurement time is too long. In the digital frequency measurement technology, there are three main factors affecting digital frequency measurement, namely measurement range, measurement accuracy and measurement time. The three methods have the defects of limitation of measurement range or low measurement precision, so that an adaptive frequency measurement device and a test method based on an FPGA, which have stronger adaptability, can be compatible with various measurement ranges, can improve measurement precision and can control measurement time, are needed. Disclosure of Invention The invention aims to solve the technical problem of overcoming the defects of the prior art and providing the self-adaptive frequency measuring device and the testing method based on the FPGA, which have stronger adaptability, can be compatible with various measuring ranges, can improve the measuring precision and can control the measuring time. The technical scheme includes that the high-speed voltage comparator, the FPGA frequency measuring module and the operation unit are electrically connected in sequence, the high-speed voltage comparator is connected with a measured signal, the high-speed voltage comparator converts the measured signal into digital pulses, the FPGA frequency measuring module measures and counts to obtain a counting result of the measured signal and a reference clock counting result, and the operation unit calculates the frequency of the measured signal. According to the scheme, the self-adaptive frequency measuring device based on the FPGA is applied to frequency measurement of a wide-frequency signal, and the measuring range, the measuring precision and the measuring time are considered. The FPGA is utilized to realize accurate counting, and a proper measuring method and proper measuring time are set by analyzing the approximate range of the frequency of the measured signal, so that the problems in the traditional frequency measuring technology are solved, the adaptability is stronger, the low-frequency measuring scene and the high-frequency measuring scene are compatible, the measuring precision is