Frequency detection method and detection system based on timestamp circular queue

By using the frequency detection method of the timestamp cycle queue in the single -chip microcomputer, the time stamp of the timer and DMA is used to automatically transmit the timestamp, which solves the problem of high -precision multi -channel frequency measurement, and achieves efficient synchronization and accurate frequency solution.

CN119377145APending Publication Date: 2025-01-28BEIJING AUTOMATION CONTROL EQUIP INST
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411233532.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-04
Publication Date
2025-01-28

AI Technical Summary

Technical Problem

The prior art is difficult to achieve high-precision and multi-channel frequency measurement based on microcontrollers. It is mainly because the microcontroller is a serial processor, and it is difficult to monitor the signal edge jump in real time, resulting in a low-frequency counting ±1 error.

Method used

The frequency detection method based on the timestamp cycle queue is used to automatically trigger DMA transmission through the rising edge of the frequency measurement signal through the timer, and store the timestamp in the loop queue in memory, and use the queue to solve the frequency.

Benefits of technology

The efficient synchronization of multi -road measurement signals has been achieved, which greatly improves the frequency measurement accuracy, reduces the operating burden of the processor, supports multi -channel frequency measurement, and meets the frequency measurement needs of most scenarios.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure 00000000_0000_ABST
    Figure 00000000_0000_ABST
Patent Text Reader

Abstract

The invention provides a frequency detection method and system based on a timestamp circular queue. The method comprises the following steps: selecting one or more first preset channels of a timer in a minimum system board of a single-chip microcomputer as input channels of a to-be-detected frequency signal according to the path number of the to-be-detected frequency signal; selecting one or more second preset channels of the DMA in the minimum system board of the single chip microcomputer as timestamp output channels according to the number of the first preset channels; when the first preset channel captures the rising edge of the frequency signal to be measured once, the timer automatically triggers DMA transmission once so as to mark the count value of the timer at the current moment into a memory as a timestamp through a corresponding second preset channel; and cyclically reading the count value in the memory according to the main task period, pressing the count value into a queue, and removing the count value in the queue to calculate the frequency of the frequency signal to be measured. By applying the technical scheme of the invention, the technical problem that high-precision and multi-channel frequency measurement cannot be realized based on a single-chip microcomputer in the prior art is solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of frequency measurement, and in particular to a frequency detection method and a detection system based on a timestamp circular queue. Background Art

[0002] Silicon resonant pressure sensors are widely used in the aerospace field, and their output frequency signals need to be accurately measured to ensure the accuracy of pressure measurement. At present, the mainstream technical route for accurate measurement of frequency signals is the "equal-precision frequency measurement method". This method keeps the measurement accuracy constant and does not change with the changes in the measured signal. The hardware implementation is mainly based on FPGA, which can meet the requirements of high precision and multi-channel. However, FPGA chips are generally expensive, and the introduction of FPGA in a system controlled by a single-chip microcomputer will increase the complexity of the system. However, there are certain limitations to the high-precision and multi-channel frequency measurement based only on a single-chip microcomputer. The main difficulty is that the single-chip microcomputer is a serial processor and can only execute one instruction at a time. It is difficult to strictly ensure that the edge jump of the measured signal is monitored in real time, causing a low-frequency count error of ±1. This error is currently the bottleneck that restricts the improvement of the frequency measurement accuracy of single-chip microcomputers. If multi-channel frequency measurement of single-chip microcomputers is to be realized, it will put forward extremely stringent tests on the software and hardware systems. At present, no method has been found in the public literature that can perfectly solve the problem of high-precision and multi-channel frequency measurement based on single-chip microcomputers. Summary of the invention

[0003] The present invention provides a frequency detection method and a detection system based on a timestamp circular queue, which can solve the technical problem in the prior art that high-precision, multi-channel frequency measurement cannot be achieved based on a single-chip microcomputer.

[0004] According to one aspect of the present invention, a frequency detection method based on a timestamp circular queue is provided, the method comprising:

[0005] One or more first preset channels of the timer in the single-chip minimum system board are selected as input channels of the frequency signal to be measured according to the number of channels of the frequency signal to be measured, the number of the first preset channels is equal to the number of channels of the frequency signal to be measured and each channel of the frequency signal to be measured corresponds to each first preset channel one by one;

[0006] According to the number of the first preset channels, one or more second preset channels of the DMA in the single-chip minimum system board are selected as timestamp output channels, and the number of the second preset channels is equal to the number of the first preset channels;

[0007] The mode of the first preset channel is configured as a capture mode, the DMA is configured as an automatic transmission mode, and the transmission direction of the second preset channel is configured as from the DMA to the memory in the single-chip minimum system board and the memory storage address is incremented;

[0008] Configure a one-to-one correspondence between the second preset channels and the first preset channels, as well as a memory start address, a transmission bit width, and an upper limit on the number of transmission data corresponding to each second preset channel;

[0009] The frequency signal to be measured is input through the first preset channel. When the first preset channel captures a rising edge of the frequency signal to be measured, the timer automatically triggers a DMA transmission to mark the count value of the timer at the current moment as a timestamp into the memory through the corresponding second preset channel. All count values ​​are cached in the memory according to the one-to-one correspondence between the second preset channel and the first preset channel configured above and the memory start address, transmission bit width and upper limit of the number of transmission data corresponding to each second preset channel;

[0010] The count value in the memory is read according to the main task cycle and pushed into the queue, and the count value in the queue is removed to calculate the frequency of the corresponding frequency signal to be measured.

[0011] Further, removing the count value in the queue to calculate the frequency of the corresponding frequency signal to be measured includes:

[0012] Remove the count value in the queue to get the total number of count values ​​in the queue and the first and last count values ​​in the queue;

[0013] The frequency of the corresponding frequency signal to be measured is obtained by solving the calculation according to the frequency of the timer, the total number of count values ​​in the queue, the first count value in the queue, and the last count value.

[0014] Furthermore, the frequency of the corresponding frequency signal to be measured is calculated according to the frequency of the timer, the total number of count values ​​in the queue, the first count value in the queue, and the last count value in the queue by the following formula:

[0015]

[0016] In the above formula, f represents the frequency of the frequency signal to be measured, A represents the total number of count values ​​in the queue, C2 represents the last count value in the queue, C1 represents the first count value in the queue, and f d Indicates the frequency of the timer.

[0017] Furthermore, the method further includes dividing the voltage of the frequency signal to be measured by a resistor to a level below a preset threshold before the frequency signal to be measured is input through the first preset channel.

[0018] Furthermore, the method also includes configuring the pin of the first preset channel for push-pull output multiplexing and leaving it suspended before the frequency signal to be measured is input through the first preset channel.

[0019] Furthermore, the single-chip microcomputer in the single-chip microcomputer minimum system board uses an arm processor.

[0020] According to another aspect of the present invention, a frequency detection system based on a timestamp circular queue is provided, the detection system comprising:

[0021] A single-chip minimum system board, the single-chip minimum system board includes a single-chip, a timer, a DMA and a memory, the timer is used to select one or more first preset channels as input channels of the frequency signal to be measured according to the number of channels of the frequency signal to be measured, the number of the first preset channels is equal to the number of channels of the frequency signal to be measured and each channel of the frequency signal to be measured corresponds to each first preset channel one by one, the DMA is used to select one or more second preset channels as timestamp output channels according to the number of the first preset channels, the number of the second preset channels is equal to the number of the first preset channels;

[0022] A configuration module, the configuration module is used to configure the mode of the first preset channel to be a capture mode, configure the DMA to be an automatic transmission mode, and configure the transmission direction of the second preset channel to be from the DMA to the memory in the minimum system board of the single-chip microcomputer and the memory storage address is incremented; configure a one-to-one correspondence between the second preset channel and the first preset channel, and configure the memory start address, transmission bit width and upper limit of the number of transmission data corresponding to each second preset channel;

[0023] The timer is also used to automatically trigger a DMA transmission when the first preset channel captures a rising edge of the frequency signal to be measured, so as to mark the count value of the timer at the current moment as a timestamp into the memory through the corresponding second preset channel, and all count values ​​are cached in the memory according to the one-to-one correspondence between the second preset channel and the first preset channel configured above and the memory start address, transmission bit width and upper limit of the number of transmission data corresponding to each second preset channel;

[0024] The solving module is used to read the count value in the memory according to the main task cycle and push it into the queue, and remove the count value in the queue to solve the frequency of the corresponding frequency signal to be measured.

[0025] The technical solution of the present invention is applied to provide a frequency detection method and detection system based on a timestamp circular queue. The method abandons the hardware framework of a signal to be measured + a reference (standard) signal in a traditional frequency measurement scheme, and only requires a single-chip minimum system board. The main control chip only has the signal to be measured input, and the reference signal is the clock of the chip's internal timer itself, that is, the main frequency of the chip's internal timer is used as the standard frequency signal, and no other peripheral circuits need to be added. The hardware composition is extremely simple, easy to achieve miniaturization, and low cost; furthermore, through the clever design of the software, the timer is used to automatically trigger DMA transmission when the rising edge of the frequency signal to be measured comes, and a timestamp is saved in the circular queue in the memory, which can realize efficient synchronization of multiple channels of measured signals, solve the ±1 error caused by the difficulty in synchronizing the signal to be measured in the traditional frequency measurement scheme in principle, greatly improve the frequency measurement accuracy, and by using a circular queue to store a large number of timestamps, it can effectively alleviate the processor operation burden, and no interrupt needs to be specially added, which provides the possibility for multi-channel frequency measurement and meets the frequency measurement requirements in most scenarios. BRIEF DESCRIPTION OF THE DRAWINGS

[0026] The included drawings are used to provide a further understanding of the embodiments of the present invention, which constitute a part of the specification, are used to illustrate the embodiments of the present invention, and together with the text description, explain the principles of the present invention. Obviously, the drawings in the following description are only some embodiments of the present invention, and for ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.

[0027] Figure 1 It shows a schematic diagram of the principle of a frequency detection method based on a timestamp circular queue provided according to a specific embodiment of the present invention;

[0028] Figure 2 A structural block diagram of a frequency detection system based on a timestamp circular queue provided according to a specific embodiment of the present invention is shown. DETAILED DESCRIPTION

[0029] It should be noted that, in the absence of conflict, the embodiments in this application and the features in the embodiments can be combined with each other. The technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. The following description of at least one exemplary embodiment is actually only illustrative and is by no means intended to limit the present invention and its application or use. Based on the embodiments in the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0030] It should be noted that the terms used herein are only for describing specific embodiments and are not intended to limit the exemplary embodiments according to the present application. As used herein, unless the context clearly indicates otherwise, the singular form is also intended to include the plural form. In addition, it should be understood that when the terms "comprise" and / or "include" are used in this specification, it indicates the presence of features, steps, operations, devices, components and / or combinations thereof.

[0031] Unless otherwise specifically stated, the relative arrangement, numerical expressions and numerical values ​​of the parts and steps described in these embodiments do not limit the scope of the present invention. At the same time, it should be understood that, for ease of description, the sizes of the various parts shown in the accompanying drawings are not drawn according to the actual proportional relationship. The technology, methods and equipment known to ordinary technicians in the relevant field may not be discussed in detail, but in appropriate cases, the technology, methods and equipment should be regarded as a part of the authorization specification. In all examples shown and discussed here, any specific value should be interpreted as being merely exemplary, rather than as a limitation. Therefore, other examples of exemplary embodiments may have different values. It should be noted that similar reference numerals and letters represent similar items in the following drawings, so once a certain item is defined in an accompanying drawing, it does not need to be further discussed in subsequent drawings.

[0032] According to a specific embodiment of the present invention, a frequency detection method based on a timestamp circular queue is provided, the method comprising:

[0033] One or more first preset channels of the timer in the single-chip minimum system board are selected as input channels of the frequency signal to be measured according to the number of channels of the frequency signal to be measured, the number of the first preset channels is equal to the number of channels of the frequency signal to be measured and each channel of the frequency signal to be measured corresponds to each first preset channel one by one, that is, the transmission line of the frequency signal to be measured is connected to the pin of the first preset channel of the timer;

[0034] According to the number of the first preset channels, one or more second preset channels of the DMA in the single-chip minimum system board are selected as timestamp output channels, and the number of the second preset channels is equal to the number of the first preset channels;

[0035] The mode of the first preset channel is configured as a capture mode, the DMA is configured as an automatic transmission mode, and the transmission direction of the second preset channel is configured as from the DMA to the memory in the single-chip minimum system board and the memory storage address is incremented;

[0036] Configure a one-to-one correspondence between the second preset channels and the first preset channels, as well as a memory start address, a transmission bit width, and an upper limit on the number of transmission data corresponding to each second preset channel;

[0037] The frequency signal to be measured is input through the first preset channel. When the first preset channel captures a rising edge of the frequency signal to be measured, the timer automatically triggers a DMA transmission to mark the count value of the timer at the current moment as a timestamp into the memory through the corresponding second preset channel. All count values ​​are cached in the memory according to the one-to-one correspondence between the second preset channel and the first preset channel configured above and the memory start address, transmission bit width and upper limit of the number of transmission data corresponding to each second preset channel;

[0038] The count value in the memory is read according to the main task cycle and pushed into the queue, and the count value in the queue is removed to calculate the frequency of the corresponding frequency signal to be measured.

[0039] Among them, the configuration function is realized by software. By configuring the one-to-one correspondence between the first preset channel and the second preset channel and the memory start address corresponding to each second preset channel, the relationship between each frequency signal to be measured and the memory storage position is indirectly established. That is to say, multiple storage spaces with preset lengths (for example, 1K) are opened in the memory for DMA cache. When the first preset channel captures the frequency signal to be measured, the count value of the timer at the current moment is marked as a timestamp to the storage space corresponding to the second preset channel in the memory through the corresponding second preset channel, so as to realize the partition storage of timestamps triggered by different frequency signals to be measured. At the same time, the queue is used to manage the data (count value) updated to the cache by DMA in each software running cycle. The queue cache and the DMA cache share a piece of memory. Each time the software runs, the DMA update data is checked and the updated data is pushed into the queue. When the signal frequency needs to be solved, the data is removed from the queue. In addition, the frequency detection method provided by the present invention is applicable to various frequency signals, including but not limited to the frequency signal output by the sensor.

[0040] Applying this configuration mode, a frequency detection method based on a timestamp circular queue is provided, which abandons the hardware framework of the signal to be measured + reference (standard) signal in the traditional frequency measurement scheme, and only requires a single-chip minimum system board, the main control chip has only the signal to be measured input, and the reference signal is the clock of the chip internal timer itself, that is, the main frequency of the chip internal timer is used as the standard frequency signal, and the remaining peripheral circuits do not need to be added. The hardware composition is extremely simple, easy to realize miniaturization, and the cost is low; furthermore, through the clever design of the software, the timer is used to automatically trigger DMA transmission when the rising edge of the frequency signal to be measured comes, and a timestamp is saved in the circular queue in the memory, which can realize efficient synchronization of multi-channel measured signals, and solve the ±1 error caused by the difficulty of synchronization of the signal to be measured in the traditional frequency measurement scheme in principle, greatly improve the frequency measurement accuracy, and by using the circular queue to store a large number of timestamps, the processor operation burden can be effectively alleviated, and no special interruption is required, which provides the possibility for multi-channel frequency measurement, and meets the frequency measurement requirements in most scenarios. Compared with the prior art, the technical solution of the present invention can solve the technical problem that the prior art cannot realize high-precision and multi-channel frequency measurement based on a single-chip microcomputer.

[0041] For further information, please refer to Figure 1 In an embodiment of the present invention, removing the count value in the queue to calculate the frequency of the corresponding frequency signal to be measured includes:

[0042] Remove the count value in the queue to get the total number of count values ​​in the queue and the first and last count values ​​in the queue;

[0043] The frequency of the corresponding frequency signal to be measured is obtained by solving the calculation according to the frequency of the timer, the total number of count values ​​in the queue, the first count value in the queue, and the last count value.

[0044] As a specific embodiment of the present invention, the frequency of the corresponding frequency signal to be measured is calculated according to the frequency of the timer, the total number of count values ​​in the queue, the first count value in the queue, and the last count value in the queue by the following formula:

[0045]

[0046] In the above formula, f represents the frequency of the frequency signal to be measured, A represents the total number of count values ​​in the queue, C2 represents the last count value in the queue, C1 represents the first count value in the queue, and f d Indicates the frequency of the timer.

[0047] In addition, in order to improve the applicability of the method, in an embodiment of the present invention, the method further includes dividing the frequency signal to be measured by a resistor to below a preset threshold before the frequency signal to be measured is input through the first preset channel, and configuring the pin of the first preset channel to multiplex push-pull output and to be suspended. The preset threshold is determined according to actual conditions.

[0048] Please refer to Figure 2 According to another aspect of the present invention, a frequency detection system based on a timestamp circular queue is provided, the detection system comprising:

[0049] A single-chip minimum system board, the single-chip minimum system board includes a single-chip, a timer, a DMA and a memory, the timer is used to select one or more first preset channels as input channels of the frequency signal to be measured according to the number of channels of the frequency signal to be measured, the number of the first preset channels is equal to the number of channels of the frequency signal to be measured and each channel of the frequency signal to be measured corresponds to each first preset channel one by one, the DMA is used to select one or more second preset channels as timestamp output channels according to the number of the first preset channels, the number of the second preset channels is equal to the number of the first preset channels;

[0050] A configuration module, the configuration module is used to configure the mode of the first preset channel to be a capture mode, configure the DMA to be an automatic transmission mode, and configure the transmission direction of the second preset channel to be from the DMA to the memory in the minimum system board of the single-chip microcomputer and the memory storage address is incremented; configure a one-to-one correspondence between the second preset channel and the first preset channel, and configure the memory start address, transmission bit width and upper limit of the number of transmission data corresponding to each second preset channel;

[0051] The timer is also used to automatically trigger a DMA transmission when the first preset channel captures a rising edge of the frequency signal to be measured, so as to mark the count value of the timer at the current moment as a timestamp into the memory through the corresponding second preset channel, and all count values ​​are cached in the memory according to the one-to-one correspondence between the second preset channel and the first preset channel configured above and the memory start address, transmission bit width and upper limit of the number of transmission data corresponding to each second preset channel;

[0052] The solving module is used to read the count value in the memory according to the main task cycle and push it into the queue, and remove the count value in the queue to solve the frequency of the corresponding frequency signal to be measured.

[0053] Through this configuration, a frequency detection system based on a timestamp circular queue is provided. The system abandons the hardware framework of the signal to be measured + the reference (standard) signal in the traditional frequency measurement scheme, and only requires a single-chip minimum system board. The main control chip only has the signal to be measured input, and the reference signal is the clock of the chip's internal timer itself, that is, the main frequency of the chip's internal timer is used as the standard frequency signal, and there is no need to add other peripheral circuits. The hardware composition is extremely simple, easy to miniaturize, and has low cost; furthermore, through the clever design of the software, the timer is used to automatically trigger DMA transmission when the rising edge of the frequency signal to be measured comes, and a timestamp is saved in the circular queue in the memory, which can realize efficient synchronization of multiple channels of measured signals, and solve the ±1 error caused by the difficulty in synchronizing the signal to be measured in the traditional frequency measurement scheme in principle, greatly improve the frequency measurement accuracy, and by using the circular queue to store a large number of timestamps, it can effectively alleviate the processor operation burden, and there is no need to specially add interrupts, which provides the possibility for multi-channel frequency measurement and meets the frequency measurement requirements in most scenarios.

[0054] In order to facilitate a clearer understanding of the frequency detection method and detection system provided by the present invention, the following will be described in detail with examples of practical applications. Relevant technical personnel in the field should know that this example is only for a clearer understanding of the frequency detection method and detection system provided by the present invention, and does not impose any technical limitation on them.

[0055] In this embodiment, the MCU in the MCU minimum system board uses an arm processor. First, the connection relationship of the processor GPIO pins is reasonably arranged according to the number of channels to detect the frequency signal. Taking the GD32F450 processor as an example, assuming that 3 frequency signals are to be detected, frequency 0 can be connected to pin PA0, frequency 1 can be connected to pin PA1, and frequency 2 can be connected to pin PA2. The three GPIO pins correspond to the three channels of timer TIM1: TIM1_CH0, TIM1_CH1 and TIM1_CH2.

[0056] Secondly, develop frequency measurement software to configure the resources of the minimum system board of the arm processor, specifically including: configuring the above three GPIO pins to multiplex push-pull output and leave them floating; configuring the three channels of timer TIM1 to capture mode; configuring the timer to automatically start DMA transmission after capturing the rising edge of GPIO, configuring the three DMA channels DMA0_CH5, DMA0_CH6, and DMA0_CH1 to correspond one to one with the three channels TIM1_CH0, TIM1_CH1, and TIM1_CH2 of timer TIM1, configuring the transmission direction of the three DMA channels DMA0_CH5, DMA0_CH6, and DMA0_CH1 to be from peripherals (DMA) to memory and the memory storage address to increase, configuring the three DMA channels DMA0_CH5, DMA0_CH6, and DMA0_CH1 to correspond to their respective memory start addresses, transmission bit widths (e.g., 32 bits), and upper limits on the number of transmitted data (e.g., 1000).

[0057] After configuration, DMA cyclic transmission is enabled. When the measured frequency signal has a rising edge, the timer automatically triggers a DMA transmission, and the count value of the timer at the current moment is used as a timestamp to mark the corresponding storage space in the memory, and the main task cycle of the software is started. Each time the software completes a main task cycle, it detects the timestamp refreshed in this operation cycle, that is, the count value, and pushes the updated count value into the sequence, and calculates the frequency of the measured frequency signal based on this.

[0058] The number of elements in the queue (the number of count values) represents the number of rising edges generated by the measured frequency signal in the last main task cycle. The main frequency of the timer is pre-configured and is a known quantity, so the value of each element represents the specific time when the rising edge arrives. Please refer to Figure 1 , within the 5ms main task cycle, a total of 28 data (timer count values) are stored in the DMA cache queue, that is, the corresponding frequency signal to be measured has 28 rising edges (low-frequency counts), the timer frequency is 100MHz, the first timer count in the queue is 1212, and the last one is 499488. The corresponding high-frequency count is: 499488-1212=498276. According to the formula The frequency to be measured is: low frequency count / high frequency count*timer frequency=28 / 498276*100000000=5619.4Hz.

[0059] If you want to achieve multi-channel frequency measurement, you can choose a processor with rich timer and DMA resources. Taking GD32F450IIH6 as an example, considering the combination of DMA channels and timer channels, up to 20 frequencies can be measured simultaneously, as shown in Table 1 and Table 2.

[0060] Table 1 GD32F450 processor DMA resource status - DMA0 peripheral request

[0061]

[0062] Table 2 GD32F450 processor DMA resource status - DMA1 peripheral request

[0063]

[0064] In summary, the present invention provides a frequency detection method and detection system based on a timestamp circular queue, which abandons the hardware framework of the signal to be measured + reference (standard) signal in the traditional frequency measurement scheme, and only requires a single-chip minimum system board, the main control chip has only the signal to be measured input, and the reference signal is the clock of the chip internal timer itself, that is, the main frequency of the chip internal timer is used as the standard frequency signal, and the remaining peripheral circuits do not need to be added. The hardware composition is extremely concise, easy to realize miniaturization, and low cost; furthermore, through the ingenious design of software, the timer is used to automatically trigger DMA transmission when the rising edge of the frequency signal to be measured comes, and a timestamp is saved in the circular queue in the memory, which can realize efficient synchronization of multi-channel measured signals, and solve the ±1 error caused by the difficulty of synchronization of the signal to be measured in the traditional frequency measurement scheme in principle, greatly improve the frequency measurement accuracy, and by using a circular queue to store a large number of timestamps, the processor operation burden can be effectively alleviated, and no special interruption is required, which provides the possibility for multi-channel frequency measurement, and meets the frequency measurement requirements in most scenarios. Compared with the prior art, the technical solution of the present invention can solve the technical problem that the prior art cannot realize high-precision and multi-channel frequency measurement based on a single-chip microcomputer.

[0065] For ease of description, spatially relative terms such as "above", "above", "on the upper surface of", "above", etc. may be used here to describe the spatial positional relationship between a device or feature and other devices or features as shown in the figure. It should be understood that spatially relative terms are intended to include different orientations of the device in use or operation in addition to the orientation described in the figure. For example, if the device in the accompanying drawings is inverted, the device described as "above other devices or structures" or "above other devices or structures" will be positioned as "below other devices or structures" or "below other devices or structures". Thus, the exemplary term "above" can include both "above" and "below". The device can also be positioned in other different ways (rotated 90 degrees or in other orientations), and the spatially relative descriptions used here are interpreted accordingly.

[0066] In addition, it should be noted that the use of terms such as "first" and "second" to limit components is only for the convenience of distinguishing the corresponding components. If not otherwise stated, the above terms have no special meaning and therefore cannot be understood as limiting the scope of protection of the present invention.

[0067] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. For those skilled in the art, the present invention may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.

Claims

1. A frequency detection method based on a timestamp circular queue, characterized in that: The method comprises: According to the number of the frequency signals to be measured, one or more first preset channels of the timer in the single-chip minimum system board are selected as input channels of the frequency signals to be measured, wherein the number of the first preset channels is equal to the number of the frequency signals to be measured and each frequency signal to be measured corresponds to each first preset channel one by one; According to the number of the first preset channels, one or more second preset channels of the DMA in the single-chip minimum system board are selected as timestamp output channels, and the number of the second preset channels is equal to the number of the first preset channels; The mode of the first preset channel is configured as a capture mode, the DMA is configured as an automatic transmission mode, and the transmission direction of the second preset channel is configured as from the DMA to the memory in the single-chip minimum system board and the memory storage address is incremented; Configure a one-to-one correspondence between the second preset channel and the first preset channel, as well as a memory start address, a transmission bit width, and an upper limit on the number of transmitted data corresponding to each second preset channel; The frequency signal to be measured is input through the first preset channel. When the first preset channel captures a rising edge of the frequency signal to be measured, the timer automatically triggers a DMA transmission to mark the count value of the timer at the current moment as a timestamp into the memory through the corresponding second preset channel. All count values ​​are cached in the memory according to the one-to-one correspondence between the second preset channel and the first preset channel configured above and the memory start address, transmission bit width and upper limit of the number of transmission data corresponding to each second preset channel; The count value in the memory is read in a cycle according to the main task and pushed into a queue, and the count value in the queue is removed to calculate the frequency of the corresponding frequency signal to be measured.

2. The method according to claim 1, characterized in that: Shifting the count value in the queue to calculate the frequency of the corresponding frequency signal to be measured includes: Shifting the count values ​​in the queue to obtain the total number of count values ​​in the queue and the first count value and the last count value in the queue; The frequency of the corresponding frequency signal to be measured is obtained by calculating according to the frequency of the timer, the total number of count values ​​in the queue, the first count value and the last count value in the queue.

3. The method according to claim 2, characterized in that The frequency of the corresponding frequency signal to be measured is calculated by the following formula according to the frequency of the timer, the total number of count values ​​in the queue, the first count value and the last count value in the queue: In the above formula, f represents the frequency of the frequency signal to be measured, A represents the total number of count values ​​in the queue, C2 represents the last count value in the queue, C1 represents the first count value in the queue, and f d Indicates the frequency of the timer.

4. The method according to claim 1, characterized in that: The method further includes dividing the frequency signal to be measured by a resistor to a voltage below a preset threshold before the frequency signal to be measured is input through the first preset channel.

5. The method according to claim 1, characterized in that The method further comprises configuring the pin of the first preset channel to be multiplexed push-pull output and leaving it suspended before the frequency signal to be measured is input through the first preset channel.

6. The method according to any one of claims 1 to 5, characterized in that The single-chip microcomputer in the single-chip microcomputer minimum system board uses an arm processor.

7. A frequency detection system based on a timestamp circular queue, characterized in that: The detection system comprises: A single-chip minimum system board, the single-chip minimum system board comprising a single-chip, a timer, a DMA and a memory, the timer being used to select one or more first preset channels as input channels of the frequency signal to be measured according to the number of channels of the frequency signal to be measured, the number of the first preset channels being equal to the number of channels of the frequency signal to be measured and each channel of the frequency signal to be measured having a one-to-one correspondence with each first preset channel, the DMA being used to select one or more second preset channels as timestamp output channels according to the number of the first preset channels, the number of the second preset channels being equal to the number of the first preset channels; A configuration module, the configuration module is used to configure the mode of the first preset channel to be a capture mode, configure the DMA to be an automatic transmission mode, and configure the transmission direction of the second preset channel to be from the DMA to the memory in the minimum system board of the single-chip microcomputer and the memory storage address is incremented; configure a one-to-one correspondence between the second preset channel and the first preset channel, and a memory start address, a transmission bit width, and an upper limit on the number of transmission data corresponding to each second preset channel; The timer is also used to automatically trigger a DMA transmission when the first preset channel captures a rising edge of the frequency signal to be measured, so as to mark the count value of the timer at the current moment as a timestamp into the memory through the corresponding second preset channel, and all count values ​​are cached in the memory according to the one-to-one correspondence between the second preset channel and the first preset channel configured above and the memory start address, transmission bit width and upper limit of the number of transmission data corresponding to each second preset channel; The solving module is used to read the count value in the memory according to the main task cycle and push it into the queue, and remove the count value in the queue to solve the frequency of the corresponding frequency signal to be measured.