Digital signal sampling method, device and equipment
By adjusting the phase difference and band number during the capture clock cycle, multiple capture clocks are generated, which solves the problem of accuracy limitation caused by fixed capture clock frequency, and realizes high-precision signal sampling without increasing the sampling frequency. Signal transmission quality verification and abnormality detection.
Patent Information
- Application Number
- CN202411035122.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-30
- Publication Date
- 2024-11-15
AI Technical Summary
In the field of industrial control, the frequency of the input capture clock is fixed and difficult to adjust, resulting in limited signal sampling accuracy and the inability to improve capture accuracy without increasing the sampling frequency.
By determining the specified phase difference and number of bands of the capture clock in the period, a plurality of different capture clocks are generated using a delay circuit, the capture clock is adjusted to generate a plurality of different second capture clocks for sampling the signal to be sampled, and the calculation is performed. High-level width and low-level width periods.
Without increasing the sampling frequency, the sampling accuracy of the capture clock for the signal to be sampled is improved, and the number of high-level periods and low-level periods of the signal to be sampled is quickly and accurately calculated to assist in verifying the signal transmission quality and detecting abnormalities.
Smart Images

Figure CN118963640A_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present invention relate to the field of input capture technology, and in particular to a digital signal sampling method, device and equipment. Background Art
[0002] In the field of industrial control, such as motor control and vehicle-mounted system applications, there will be a large number of signal measurement needs. To achieve this demand, input capture is a common method in signal measurement, which can measure the high level width and low level width of the input signal.
[0003] However, the accuracy of the high-level width and low-level width of the signal obtained by input capture depends on the frequency of the capture clock. Therefore, the higher the capture clock frequency, the higher the accuracy. For example, if the capture clock frequency is 100mhz, then the capture accuracy is equal to the clock period 10ns. However, the capture clock frequency is usually fixed in the production stage, so it is very difficult to adjust the capture clock frequency later, so the capture accuracy is limited. Summary of the invention
[0004] The present invention provides a digital signal sampling method, device and equipment which can effectively improve the capture accuracy of input capture without changing the capture clock frequency.
[0005] In order to solve the above technical problems, an embodiment of the present invention provides a digital signal sampling method, comprising:
[0006] Determine the bands and number of bands in which the first capture clock has a specified phase difference within a period;
[0007] Determine a first number of delay units corresponding to the band in the delay circuit;
[0008] The first number of delay units are used as adjustment units, and the delay circuit adjusts the first capture clock based on different numbers of adjustment units respectively to generate a plurality of different second capture clocks, each of the second capture clocks being delayed by n bands relative to the first capture clock, where n is a positive integer and is less than the number of bands;
[0009] Based on the first capture clock and the second capture clock, the signal wave to be sampled is sampled to obtain multiple groups of sampling results that meet the timing, each group of the sampling results corresponds to a sampling period of the first capture clock, and includes sampling data of the first capture clock and the second capture clock in the sampling period;
[0010] The number of high-level width periods and the number of low-level width periods of the signal wave to be sampled are calculated and determined based on the multiple groups of sampling results.
[0011] In some embodiments, the method further comprises:
[0012] Capturing a third number of the delay units corresponding to the first capture clock within a specified period range based on the phase-locked circuit;
[0013] The determining a first number of delay units corresponding to the band in the delay circuit includes:
[0014] Determining the number of the bands included in the specified period range;
[0015] The first number of delay units corresponding to each of the bands is determined based on the third number of delay units and the number of the bands included in the specified period range.
[0016] In some embodiments, the method further comprises:
[0017] Obtaining a preset sampling accuracy value of the signal wave to be sampled, wherein the preset sampling accuracy value is a multiple of the sampling accuracy value of the current first capture clock;
[0018] The first capture clock within a period is divided based on the multiple relationship to form a plurality of bands with a specified phase difference, and the number of the bands is at most the same as the multiple value corresponding to the multiple relationship.
[0019] In some embodiments, the first number of delay units are used as adjustment units, and the delay circuit adjusts the first capture clock based on different numbers of adjustment units to generate a plurality of different second capture clocks, including:
[0020] The first number of delay units are used as adjustment units, and the delay circuit controls the first capture clock to pass through different numbers of adjustment units respectively, so that the first capture clock is delayed to different phases respectively, thereby forming a plurality of different second capture clocks;
[0021] The delayed phase and the specified phase difference are in a multiple relationship, and the number of adjustment units that the first capture clock passes through each time is one more than the number of adjustment units that the first capture clock passes through last time.
[0022] In some embodiments, sampling the signal wave to be sampled based on the first capture clock and the second capture clock includes:
[0023] sorting or marking the first capture clock and a plurality of second capture clocks according to delay durations;
[0024] The signal wave to be sampled is sampled based on the sorted or marked first capture clock and multiple second capture clocks.
[0025] In some embodiments, the method further comprises:
[0026] Obtaining a first sampling result of the first capture clock and a second sampling result of each of the second capture clocks;
[0027] The plurality of second sampling results are divided into sampling periods based on the sampling frequency of the first capture clock to obtain a plurality of groups of acquisition results corresponding to different sampling periods, and the sampling periods corresponding to the sampling results in the same group are the same.
[0028] In some embodiments, the calculating and determining the number of high level width cycles of the signal wave to be sampled based on the multiple groups of sampling results includes:
[0029] Counting the number of first values in each group of the sampling results in chronological order, the first values representing that the signal is at a high level at the corresponding sampling moment;
[0030] Calculating a ratio of the number of first values to the number of capture clocks in each group of the sampling results, where the number of capture clocks is the sum of the first capture clock and the number of the plurality of second capture clocks;
[0031] Based on the ratio in each group of the sampling results, the ratios of the continuous groups of first sampling results that meet the high-level sampling characteristics are summed, and the sampling periods corresponding to the continuous groups of first sampling results cover the number of high-level width periods of the signal wave to be sampled;
[0032] The number of high level width cycles is calculated based on the frequency of the first capture clock and the obtained ratio.
[0033] In some embodiments, the step of calculating and determining the number of low-level width cycles of the signal wave to be sampled based on the plurality of sampling results comprises:
[0034] Counting the number of second values in each group of the sampling results in chronological order, the second value representing that the signal is at a low level at the corresponding sampling moment;
[0035] Calculating a ratio of the number of second values in each group of the sampling results to the number of capture clocks, where the number of capture clocks is the sum of the first capture clock and the number of the plurality of second capture clocks;
[0036] Based on the ratio in each group of the sampling results, the ratios of the continuous groups of second sampling results that meet the low-level sampling characteristics are summed, and the sampling periods corresponding to the continuous groups of second sampling results cover the number of low-level width periods of the signal wave to be sampled;
[0037] The number of low level width cycles is calculated based on the frequency of the first capture clock and the obtained ratio.
[0038] Another embodiment of the present invention also provides a digital signal sampling device, including:
[0039] A first determination module, used for determining the band and number of bands in which the first capture clock has a specified phase difference within a period;
[0040] A second determining module, used to determine a first number of delay units corresponding to the band in the delay circuit;
[0041] a first adjustment module, configured to use the first number of delay units as adjustment units, and to adjust the first capture clock by the delay circuit based on different numbers of adjustment units respectively, so as to generate a plurality of different second capture clocks, each of the second capture clocks being delayed by n of the bands relative to the first capture clock, where n is a positive integer and is less than the number of the bands;
[0042] A sampling module, used for sampling the signal wave to be sampled according to the first capture clock and the second capture clock to obtain multiple groups of sampling results that meet the timing, each group of the sampling results corresponds to a sampling period of the first capture clock, and includes sampling data of the first capture clock and the second capture clock in the sampling period;
[0043] The third determination module is used to calculate and determine the number of high-level width cycles and the number of low-level width cycles of the signal wave to be sampled according to the multiple groups of sampling results.
[0044] Another embodiment of the present invention further provides an electronic device, including:
[0045] at least one processor; and,
[0046] a memory communicatively connected to the at least one processor; wherein,
[0047] The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to implement the digital signal sampling method as described in any one of the embodiments above.
[0048] Based on the disclosure of the above embodiments, it can be known that the beneficial effects of the embodiments of the present invention include improving the sampling accuracy of the capture clock for the sampled signal without increasing the sampling frequency, so that the system can quickly and accurately calculate the number of high-level cycles and low-level cycles of the signal to be sampled, and the auxiliary system can verify the signal transmission quality based on the number of high-level cycles and low-level cycles of the signal to be sampled, and determine whether a transmission abnormality occurs. BRIEF DESCRIPTION OF THE DRAWINGS
[0049] Figure 1 Schematic diagram of a digital signal sampling method according to an embodiment of the present invention.
[0050] Figure 2 Schematic diagram of the application process of the digital signal sampling method in an embodiment of the present invention.
[0051] Figure 3 Schematic diagram of the application process of the digital signal sampling method in an embodiment of the present invention.
[0052] Figure 4 4 is a structural block diagram of a digital signal sampling device in an embodiment of the present invention. DETAILED DESCRIPTION
[0053] The specific embodiments of the present invention are described in detail below with reference to the accompanying drawings, but are not intended to limit the present invention.
[0054] It should be understood that various modifications may be made to the embodiments disclosed herein. Therefore, the following description should not be considered as limiting, but merely as an example of an embodiment. Other modifications within the scope and spirit of the present disclosure will occur to those skilled in the art.
[0055] The accompanying drawings, which are incorporated in and constitute a part of the specification, illustrate embodiments of the present disclosure and, together with the general description of the present disclosure given above and the detailed description of the embodiments given below, serve to explain the principles of the present disclosure.
[0056] These and other characteristics of the invention will become apparent from the following description of a preferred form of embodiment given as a non-limiting example, with reference to the accompanying drawings.
[0057] It should also be understood that, although the invention has been described with reference to some specific examples, those skilled in the art will be able to realize many other equivalent forms of the invention that have the characteristics recited in the claims and are therefore within the scope of protection defined thereby.
[0058] The above and other aspects, features and advantages of the present disclosure will become more apparent from the following detailed description when taken in conjunction with the accompanying drawings.
[0059] Specific embodiments of the present disclosure are described hereinafter with reference to the accompanying drawings; however, it should be understood that the disclosed embodiments are merely examples of the present disclosure, which may be implemented in a variety of ways. Well-known and / or repeated functions and structures are not described in detail to avoid obscuring the present disclosure with unnecessary or redundant details. Therefore, the specific structural and functional details disclosed herein are not intended to be limiting, but merely serve as a basis and representative basis for the claims to teach those skilled in the art to use the present disclosure in a variety of ways with substantially any suitable detailed structure.
[0060] This specification may use the phrases "in one embodiment," "in another embodiment," "in a further embodiment," or "in other embodiments," all of which may refer to one or more of the same or different embodiments according to the present disclosure.
[0061] The embodiments of the present invention are described in detail below with reference to the accompanying drawings.
[0062] In the field of industrial control, such as motor control and vehicle-mounted system applications, there will be a large number of signal measurement needs. To achieve this demand, input capture is a common method of signal measurement. The principle of input capture includes: using the capture clock to sample the input signal, and calculating the number of high-level cycles and low-level cycles of the input signal by counting the number of consecutive 1s and consecutive 0s in the sampled values. Multiplying the different cycle numbers by the cycle of the capture clock can get the high-level width and low-level width of the input signal.
[0063] The accuracy of the high-level width and low-level width of the signal obtained by input capture depends on the frequency of the capture clock. Therefore, the higher the capture clock frequency, the higher the accuracy. For example, if the capture clock frequency is 100mhz, then the capture accuracy is equal to the clock period 10ns. However, the capture clock frequency is usually fixed in the production stage, so it is very difficult to adjust the capture clock frequency later, so the capture accuracy is limited.
[0064] In order to improve the capture accuracy, Figure 1 As shown, an embodiment of the present invention provides a digital signal sampling method, comprising:
[0065] S1: Determine the band and number of bands in which the first capture clock has a specified phase difference within a period;
[0066] S2: Determine a first number of delay units corresponding to the band in the delay circuit;
[0067] S3: using the first number of delay units as adjustment units, the delay circuit adjusts the first capture clock based on different numbers of adjustment units respectively to generate a plurality of different second capture clocks, each of the second capture clocks being delayed by n bands relative to the first capture clock, where n is a positive integer and is less than the number of bands;
[0068] S4: Sampling the signal wave to be sampled based on the first capture clock and the second capture clock to obtain multiple groups of sampling results that meet the timing, each group of the sampling results corresponds to a sampling period of the first capture clock and includes sampling data of the first capture clock or the second capture clock in the sampling period;
[0069] S5: Calculate and determine the number of high-level width periods and the number of low-level width periods of the signal wave to be sampled based on the multiple groups of sampling results.
[0070] The solution in this embodiment can be applied to any scenario where digital signal sampling is required to determine the high level width and low level width of the signal, such as the scenario of input capture. Figure 2 As shown, first determine the bands and band numbers of the first capture clock with a specified phase difference within a cycle, such as the bands with a phase difference of 1 / 2 cycle, etc. Then determine the first number of delay units corresponding to the selected band in the delay circuit, that is, how many delay units can be covered on the delay circuit within the transmission time of a single band, each of which is a delay unit, corresponding to one cycle of the delay signal waveform. After that, the system uses the first number of delay units as adjustment units, and the delay circuit adjusts the first capture clock based on different numbers of adjustment units, and generates multiple second capture clocks with different delay states based on the first capture clock prototype. The multiple second capture clocks are delayed by different numbers of adjustment units relative to the first capture clock, that is, delayed by different numbers of bands, for example, the first capture clock differs from the first second capture clock by one band in the cycle, and the second second capture clock differs from the first capture clock by two bands in the cycle, etc. The specific number is not unique. After obtaining multiple first capture clocks, the system will sample the signal wave to be sampled based on the first capture clock and the second capture clock to obtain multiple groups of sampling results that meet the timing, for example, the first capture clock and multiple second capture clocks are sorted according to the delay length, and then multiple groups of sampling results are obtained in the order of the capture clocks, and the timing between the multiple groups of sampling results meets the delay timing between the capture clocks. Each group of sampling results corresponds to a sampling period of the first capture clock, and includes the sampling data of the first capture clock or the second capture clock in the sampling period, or includes the sampling data of the first capture clock, the second capture clock, or the sampling data of two different capture clocks at the same time. For example, the end segment of the previous capture clock and the initial segment of the next capture clock may be located in the same period, so the collected data may include the collection data of two or even three adjacent capture clocks. When the system obtains multiple groups of sampling results, since the multiple groups of sampling results are collected in time sequence by capture clocks with different delay states, they involve a wider range of signal collection, that is, the signal collection frequency is improved, and the sampled signal wave can be collected more comprehensively and effectively, thereby improving the sampling accuracy. Therefore, the system can more accurately calculate the number of high-level width periods and the number of low-level width periods of the signal wave to be sampled based on the multiple sets of sampling results.
[0071] Based on the above embodiments, it can be seen that the scheme of this embodiment can improve the sampling accuracy of the capture clock for the signal to be sampled without increasing the sampling frequency, so that the system can quickly and accurately calculate the number of high-level cycles and low-level cycles of the signal to be sampled, and the auxiliary system can verify the signal transmission quality based on the number of high-level cycles and low-level cycles of the signal to be sampled, and determine whether a transmission abnormality occurs.
[0072] In one embodiment, the method further comprises:
[0073] S6: capturing a third number of the delay units corresponding to the first capture clock within a specified period range based on a phase-locked circuit;
[0074] The determining a first number of delay units corresponding to the band in the delay circuit includes:
[0075] S7: Determine the number of the bands included in the specified period range;
[0076] S8: Determine a first number of delay units corresponding to each of the bands based on the third number of delay units and the number of the bands included in a specified period range.
[0077] For example, the third number of delay units corresponding to the first capture clock within the range of 1 / 2 cycle can be captured by the phase-locked circuit, or the third number of delay units corresponding to the range of one cycle, which is not determined in detail. Then, the system can compare based on the waveform of the first capture clock and the waveform of the clock signal output by the delay circuit to determine the number of bands corresponding to the specified cycle range in the delay waveform, that is, to determine the number of bands included in the specified cycle range. After that, the system can calculate and determine the number of delay units corresponding to each of the said bands based on the third number of delay units and the number of bands included in the specified cycle range, that is, the first number. Alternatively, the system can also identify and determine the first number of delay units corresponding to each of the said bands only by comparing the signal waveform of the capture clock and the signal waveform of the delay circuit.
[0078] Furthermore, the method further comprises:
[0079] S9: obtaining a preset sampling accuracy value of the signal wave to be sampled, wherein the preset sampling accuracy value is a multiple of the sampling accuracy value of the current first capture clock;
[0080] S10: Dividing the waveform of the first capture clock within a period based on the multiple relationship to form a plurality of bands with specified phase differences, wherein the number of the bands is at most the same as the multiple value corresponding to the multiple relationship.
[0081] Exemplarily, the sampling accuracy preset value of the signal wave to be sampled can be a multiple adjustment value based on the sampling accuracy of the current first capture clock. For example, if the current capture accuracy is 32, then the sampling accuracy preset value can be 2 times, 4 times, etc., up to 32 times. That is, in this embodiment, the maximum value of the multiple that can be increased is the acquisition accuracy value of the current first capture clock, that is, the frequency value, such as collecting 32 signals in one cycle. Of course, the maximum value of the multiple is not necessarily limited to the acquisition accuracy value of the first capture clock, and can also be a larger value, specifically, it can be set in multiples of 2. After the sampling accuracy preset value is obtained, that is, after the multiple value of the accuracy to be improved is obtained, the waveform of the first capture clock in the cycle can be divided based on the multiple value to form a plurality of bands with a specified phase difference. The number of the bands is at most the same as the multiple relationship, that is, the same as the sampling accuracy preset value. For example, if the multiple value corresponding to the multiple relationship is 32, then the sampling wave of the first capture clock in one cycle can be divided to obtain bands with a phase difference corresponding to 1 / 32 cycle, and the number of such bands is 32, and the maximum number is 32. Therefore, if you want to improve the accuracy by a certain number of times, you can divide the waveform of the first capture clock in one cycle by the multiple value, and the obtained band with a specified phase difference is the adjustment unit used for delay to form the second capture clock later, that is, the unit adjustment band.
[0082] Specifically, in one embodiment, the first number of delay units are used as adjustment units, and the delay circuit adjusts the first capture clock based on different numbers of adjustment units respectively to generate a plurality of different second capture clocks, including:
[0083] S11: using the first number of delay units as adjustment units, the delay circuit controls the first capture clock to pass through different numbers of adjustment units respectively, so that the first capture clock is delayed to different phases respectively, thereby forming a plurality of different second capture clocks;
[0084] The delayed phase and the specified phase difference are in a multiple relationship, and the number of adjustment units that the first capture clock passes through each time is one more than the number of adjustment units that the first capture clock passes through last time.
[0085] In this embodiment, the first number of delay units are used as adjustment units, and the adjustment units mean adjustment units whose delay differences between two capture clocks satisfying the delay timing are all different integer multiples. After the adjustment units are determined, the system will control the first capture clock through different numbers of adjustment units through the delay circuit, that is, the waveform of the first capture clock is delayed and adjusted based on different numbers of adjustment units, so that the signal wave of the first capture clock corresponds to different delayed phases, that is, the clock signal wave corresponds to different numbers of the above-mentioned bands, thereby forming multiple different second capture clocks. In this embodiment, each capture clock generated later is based on the previous capture clock and delayed by one adjustment unit, that is, it is formed by delaying one of the above-mentioned bands.
[0086] After obtaining a plurality of second capture clocks, sampling the signal wave to be sampled based on the first capture clock and the second capture clock includes:
[0087] S12: sorting or marking the first capture clock and a plurality of second capture clocks according to delay durations;
[0088] S13: Sampling the signal wave to be sampled based on the sorted or marked first capture clock and multiple second capture clocks.
[0089] For example, the first capture clock and multiple second capture clocks are sorted according to the delay length, and the timing positions can be marked. Then, all the sorted or marked capture clocks are used simultaneously to participate in the sampling of the signal wave to be sampled, and multiple sampling results corresponding to each capture clock are obtained.
[0090] In another embodiment, the method further comprises:
[0091] S14: Obtain a first sampling result of the first capture clock and a second sampling result of each of the second capture clocks;
[0092] S15: Divide the plurality of second sampling results into sampling periods based on the sampling frequency of the first capture clock to obtain a plurality of groups of acquisition results corresponding to different sampling periods, wherein the sampling periods corresponding to the sampling results in the same group are the same.
[0093] In this embodiment, in order to facilitate the subsequent use of multiple sampling results to identify and calculate the high-level width and low-level width of the signal to be sampled, the system first obtains the sampling results corresponding to different capture clocks, and then divides the sampling results of multiple second capture clocks, i.e., the second sampling results, into sampling periods based on the sampling frequency of the first capture clock to obtain multiple groups of acquisition results corresponding to different sampling periods of the first capture clock, respectively. The sampling results in the same group have the same corresponding sampling period, and each group of sampling results includes the sampling results of all the second capture clocks within the corresponding sampling period.
[0094] Furthermore, the step of calculating and determining the number of high level width cycles of the signal wave to be sampled based on the plurality of sampling results comprises:
[0095] S16: counting the number of first values in each group of the sampling results in chronological order, the first value representing that the signal is at a high level at the corresponding sampling moment;
[0096] S17: Calculate the ratio of the number of first values to the number of capture clocks in each group of the sampling results, where the number of capture clocks is the sum of the first capture clock and the number of the plurality of second capture clocks;
[0097] S18: summing the ratios of a plurality of consecutive groups of first sampling results satisfying the high-level sampling feature based on the ratios in each group of the sampling results, wherein the sampling periods corresponding to the plurality of consecutive groups of first sampling results cover the number of high-level width periods of the signal wave to be sampled.
[0098] The method further comprises:
[0099] S19: Calculate the high level width based on the frequency of the first capture clock and the obtained ratio.
[0100] For example, when the capture clock collects a high-level signal, the corresponding sampling value is 1, and when the capture clock collects a low-level signal, the corresponding sampling value is 0. For example, the system needs to arrange and count all the sampling values 1 in each group of sampling results in chronological order, and then calculate the ratio of the number of sampling values 1 to the total number of capture clocks. After the ratio is obtained, the ratios of the continuous groups of first sampling results that meet the high-level sampling characteristics are summed based on the ratio, and finally the number of high-level width cycles is calculated based on the sum of the ratios and the sampling frequency of the first capture clock. In this embodiment, the sampling cycles corresponding to the continuous groups of first sampling results cover the number of high-level width cycles of the sampling signal wave. Among them, the first sampling result that meets the high-level sampling characteristics is that the sampling value 1 is in a continuous state, without the alternation of 1 and 0 values, such as 111111, 111110, etc., all meet the sampling results, 0101110, this kind of sampling result does not meet the sampling requirements, and for the sampling values in the sampling results that do not meet the sampling requirements, the number of sampling values 1 is not counted. When a single sampling value 1 appears at the beginning of the acquisition and a single sampling value 1 appears at the end of the acquisition, if the sampling values collected in the next sampling period are multiple continuous sampling values 1 at the beginning or end, then the currently collected sampling value 1 is meaningful and meets the high-level sampling characteristics. That is, if the sampling value 1 is continuous in the current sampling period, or is continuous in the current sampling period and the next sampling period, it means that the sampling value 1 meets the high-level sampling characteristics and needs to be counted to calculate the number of high-level width cycles.
[0101] The step of calculating and determining the number of low level width cycles of the signal wave to be sampled based on the plurality of sampling results comprises:
[0102] S20: counting the number of second values in each group of the sampling results in chronological order, the second value indicating that the signal is at a low level at the corresponding sampling moment;
[0103] S21: Calculate the ratio of the number of second values in each group of the sampling results to the number of capture clocks, where the number of capture clocks is the sum of the first capture clock and the number of the plurality of second capture clocks;
[0104] S22: summing the ratios of multiple consecutive groups of second sampling results that meet the low-level sampling feature based on the ratios in each group of the sampling results, wherein the sampling periods corresponding to the multiple consecutive groups of second sampling results cover the number of low-level width periods of the signal wave to be sampled.
[0105] The method further comprises:
[0106] S23: Calculate the low level width based on the frequency of the first capture clock and the obtained ratio.
[0107] For example, as described above, taking the sampling value corresponding to the low-level signal collected by the capture clock as 0, and the sampling value corresponding to the high-level signal collected as 1 as an example, the system needs to arrange and count all the sampling values 0 in each group of sampling results in chronological order, and then calculate the ratio of the number of sampling values 0 to the total number of capture clocks. After obtaining the ratio, the ratios of the continuous groups of second sampling results that meet the low-level sampling characteristics are summed based on the ratio, and finally the number of high-level width cycles is calculated based on the sum of the ratios and the sampling frequency of the first capture clock. In this embodiment, the sampling cycles corresponding to the continuous groups of second sampling results cover the number of high-level width cycles of the sampling signal wave. Among them, the second sampling result that meets the high-level sampling characteristics is that the sampling value 0 is in a continuous state, without the alternation of 1 and 0 values, such as 000000, 100000, etc., all meet the sampling results, 0101110, this kind of sampling result does not meet the sampling requirements, and for the sampling values in the sampling results that do not meet the sampling requirements, the number of sampling values 0 is not counted. When a single sampling value 0 appears at the beginning of the acquisition and a single sampling value 0 appears at the end of the acquisition, if the sampling values collected in the next sampling period are multiple consecutive sampling values 0 in the initial stage or the end stage, then the currently collected sampling value 0 is meaningful and meets the low-level sampling characteristics. That is, if the sampling value 0 is continuous in the current sampling period, or is continuous in the current sampling period and the next sampling period, it means that the sampling value 0 meets the low-level sampling characteristics and needs to be counted to calculate the number of low-level width cycles.
[0108] In practical application, such as the following application examples:
[0109] 1) Use the phase-locked circuit to generate the number of delay units in the constant signal wave output by the delay circuit corresponding to 1 / 2 cycle (specified cycle, or one cycle or other number of cycles) of the capture clock as the reference delay;
[0110] 2) The proposed accuracy preset value is 32, and the reference delay generated by the phase-locked circuit is used to calculate the number of delay units corresponding to the phase difference of N / 32 (N=1~31). The number of delay units is multiplied by the number of delay units corresponding to the 1 / 32 phase. When the capture clock passes through different numbers of delay units, 31 new clocks with different phases can be obtained, namely the second capture clock. Together with the original first capture clock, there are 32 clocks in total, and the phase difference of each clock is 1 / 32 clock cycle.
[0111] 3) Use 32 clocks with different phases to sample the input signal to obtain a 32-bit sampling value.
[0112] 4) By calculating the number of 1s in the 32bit sample value, the number of high-level width cycles and low-level width cycles of the input signal can be obtained. Assuming that the capture clock cycle is 10ns, using the above solution, the final capture accuracy is 10ns / 32=312.5ps.
[0113] Specifically, Figure 2 and Figure 3 As shown, taking the first capture clock numbered as 0 as an example, 31 second capture clocks are numbered in sequence, and the numbering satisfies the delay timing between multiple capture clocks. The waveform diagram of the sampling signal wave output by all capture clocks is as follows Figure 3 As shown in the figure, it can be seen that the second capture clock continues backwards by 1 / 32 of the sampling period of the first capture clock based on the waveform of the first capture clock, and the 32nd capture clock is delayed by exactly 1 / 2 of the sampling period of the first capture clock. Taking the calculation of the number of high-level width cycles as an example, and continuing to combine with the figure, when the sampling values of the 32 capture clocks are all 1, it means that the input signal is sampled into a complete cycle of high level; when the sampling values of the 32 capture clocks are not all 1, then the ratio of the number of sampling values 1 x to 32 is equal to the proportion of the signal high-level width in a complete cycle, and the proportion of the low-level width in a complete cycle is 1 minus the proportion of the high level. For example, Figure 3 At t0, the 32-bit sampling value is 0x7ffff, and 19 bits are 1, so the number of high-level width cycles of the signal in the previous cycle sampled at this time point should be 19 / 32=0.59375; at t1 in the figure, the 32-bit sampling value is 0xf7000000, and 7 bits are 1, so the number of high-level width cycles of the signal in the previous cycle sampled at this time point should be 7 / 32=0.21875. Sum the proportion of all high-level widths at t0 and t1, that is, the number of width cycles, and the sum of the proportion of the high-level width in the cycle is 5.8125. Assuming that the frequency of the capture clock is 100mhz, the high-level width of the input signal obtained by calculation is 5.8125x10ns=58.125ns. Compared with the previous sampling scheme, the signal capture accuracy of this embodiment is improved by 32 times.
[0114] like Figure 4 As shown, another embodiment of the present invention also provides a digital signal sampling device, including:
[0115] A first determination module, used for determining the band and number of bands in which the first capture clock has a specified phase difference within a period;
[0116] A second determining module, used to determine a first number of delay units corresponding to the band in the delay circuit;
[0117] a first adjustment module, configured to use the first number of delay units as adjustment units, and to adjust the first capture clock by the delay circuit based on different numbers of adjustment units respectively, so as to generate a plurality of different second capture clocks, each of the second capture clocks being delayed by n of the bands relative to the first capture clock, where n is a positive integer and is less than the number of the bands;
[0118] A sampling module, used for sampling the signal wave to be sampled according to the first capture clock and the second capture clock to obtain multiple groups of sampling results that meet the timing, each group of the sampling results corresponds to a sampling period of the first capture clock, and includes sampling data of the first capture clock and the second capture clock in the sampling period;
[0119] The third determination module is used to calculate and determine the number of high-level width cycles and the number of low-level width cycles of the signal wave to be sampled according to the multiple groups of sampling results.
[0120] In some embodiments, the apparatus further comprises:
[0121] A capture module, configured to capture, according to the phase-locked circuit, a third number of the delay units corresponding to the first capture clock within a specified period range;
[0122] The determining a first number of delay units corresponding to the band in the delay circuit includes:
[0123] Determining the number of the bands included in the specified period range;
[0124] The first number of delay units corresponding to each of the bands is determined based on the third number of delay units and the number of the bands included in the specified period range.
[0125] In some embodiments, the apparatus further comprises:
[0126] A first obtaining module is used to obtain a preset sampling accuracy value of the signal wave to be sampled, wherein the preset sampling accuracy value is a multiple of the sampling accuracy value of the current first capture clock;
[0127] The first division module is used to divide the first capture clock in a period according to the multiple relationship to form a plurality of bands with specified phase differences, and the number of the bands is at most the same as the multiple value corresponding to the multiple relationship.
[0128] In some embodiments, the first number of delay units are used as adjustment units, and the delay circuit adjusts the first capture clock based on different numbers of adjustment units to generate a plurality of different second capture clocks, including:
[0129] The first number of delay units are used as adjustment units, and the delay circuit controls the first capture clock to pass through different numbers of adjustment units respectively, so that the first capture clock is delayed to different phases respectively, thereby forming a plurality of different second capture clocks;
[0130] The delayed phase and the specified phase difference are in a multiple relationship, and the number of adjustment units that the first capture clock passes through each time is one more than the number of adjustment units that the first capture clock passes through last time.
[0131] In some embodiments, sampling the signal wave to be sampled based on the first capture clock and the second capture clock includes:
[0132] sorting or marking the first capture clock and a plurality of second capture clocks according to delay durations;
[0133] The signal wave to be sampled is sampled based on the sorted or marked first capture clock and multiple second capture clocks.
[0134] In some embodiments, the apparatus further comprises:
[0135] A second obtaining module, used for obtaining a first sampling result of the first capture clock and a second sampling result of each of the second capture clocks;
[0136] The second division module is used to divide the plurality of second sampling results into sampling periods according to the sampling frequency of the first capture clock to obtain a plurality of groups of acquisition results corresponding to different sampling periods, and the sampling results in the same group correspond to the same sampling period.
[0137] In some embodiments, the calculating and determining the number of high level width cycles of the signal wave to be sampled based on the multiple groups of sampling results includes:
[0138] Counting the number of first values in each group of the sampling results in chronological order, the first values representing that the signal is at a high level at the corresponding sampling moment;
[0139] Calculating a ratio of the number of first values to the number of capture clocks in each group of the sampling results, where the number of capture clocks is the sum of the first capture clock and the number of the plurality of second capture clocks;
[0140] Based on the ratio in each group of the sampling results, the ratios of multiple consecutive groups of first sampling results that meet the high-level sampling characteristics are summed, and the sampling periods corresponding to the multiple consecutive groups of first sampling results cover the number of high-level width periods of the signal wave to be sampled.
[0141] In some embodiments, the step of calculating and determining the number of low-level width cycles of the signal wave to be sampled based on the plurality of sampling results comprises:
[0142] Counting the number of second values in each group of the sampling results in chronological order, the second value representing that the signal is at a low level at the corresponding sampling moment;
[0143] Calculating a ratio of the number of second values in each group of the sampling results to the number of capture clocks, where the number of capture clocks is the sum of the first capture clock and the number of the plurality of second capture clocks;
[0144] Based on the ratio in each group of the sampling results, the ratios of multiple consecutive groups of second sampling results that meet the low-level sampling characteristics are summed, and the sampling periods corresponding to the multiple consecutive groups of second sampling results cover the number of low-level width periods of the signal wave to be sampled.
[0145] Another embodiment of the present invention further provides an electronic device, including:
[0146] at least one processor; and,
[0147] a memory communicatively connected to the at least one processor; wherein,
[0148] The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to implement the digital signal sampling method as described in any one of the embodiments above.
[0149] Another embodiment of the present invention further provides a storage medium, which includes a stored program, wherein when the program is executed, a device including the storage medium is controlled to execute the digital signal sampling method as described in any one of the above embodiments.
[0150] The embodiment of the present invention further provides a computer program product, which is tangibly stored on a computer-readable medium and includes computer-readable instructions, and when the computer-executable instructions are executed, at least one processor executes a digital signal sampling method such as in the above-described embodiment. It should be understood that each solution in this embodiment has the corresponding technical effect in the above-described method embodiment, which will not be repeated here.
[0151] It should be noted that the computer storage medium of the present application may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access storage medium (RAM), a read-only storage medium (ROM), an erasable programmable read-only storage medium (EPROM or flash memory), an optical fiber, a portable compact disk read-only storage medium (CD-ROM), an optical storage medium, a magnetic storage medium, or any suitable combination of the above. In the present application, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, device or device. In the present application, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, in which a computer-readable program code is carried. This propagated data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. A computer-readable signal medium may also be any computer-readable medium other than a computer-readable storage medium, which may send, propagate or transmit a program configured to be used by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer-readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, antenna, optical cable, RF, etc., or any suitable combination of the above.
[0152] A person skilled in the art should understand that the discussion of any of the above embodiments is merely illustrative and is not intended to imply that the scope of protection of the present application is limited to these examples. In line with the concept of the present application, the technical features in the above embodiments or different embodiments may be combined, the steps may be implemented in any order, and there are many other variations of different aspects of one or more embodiments of the present application as described above, which are not provided in detail for the sake of simplicity.
[0153] One or more embodiments of the present application are intended to cover all such substitutions, modifications and variations that fall within the broad scope of the present application. Therefore, any omissions, modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of one or more embodiments of the present application should be included in the protection scope of the present application.
Claims
1. A digital signal sampling method, characterized in that: include: Determine the bands and number of bands in which the first capture clock has a specified phase difference within a period; Determine a first number of delay units corresponding to the band in the delay circuit; The first number of delay units are used as adjustment units, and the delay circuit adjusts the first capture clock based on different numbers of adjustment units respectively to generate a plurality of different second capture clocks, each of the second capture clocks being delayed by n bands relative to the first capture clock, where n is a positive integer and is less than the number of bands; Based on the first capture clock and the second capture clock, the signal wave to be sampled is sampled to obtain multiple groups of sampling results that meet the timing, each group of the sampling results corresponds to a sampling period of the first capture clock, and includes sampling data of the first capture clock or the second capture clock in the sampling period; The number of high-level width periods and the number of low-level width periods of the signal wave to be sampled are calculated and determined based on the multiple groups of sampling results.
2. The digital signal sampling method according to claim 1, characterized in that: The method further comprises: Capturing a third number of the delay units corresponding to the first capture clock within a specified period range based on a phase-locked circuit; The determining a first number of delay units corresponding to the band in the delay circuit includes: Determining the number of the bands included in the specified period range; The first number of delay units corresponding to each of the bands is determined based on the third number of delay units and the number of the bands included in the specified period range.
3. The digital signal sampling method according to claim 1, characterized in that: The method further comprises: Obtaining a preset sampling accuracy value of the signal wave to be sampled, wherein the preset sampling accuracy value is a multiple of the sampling accuracy value of the current first capture clock; The waveform of the first capture clock within a period is divided based on the multiple relationship to form a plurality of bands with specified phase differences, and the number of the bands is at most the same as the multiple value corresponding to the multiple relationship.
4. The digital signal sampling method according to claim 1, characterized in that: The method of using the first number of delay units as adjustment units and adjusting the first capture clock by the delay circuit based on different numbers of adjustment units to generate a plurality of different second capture clocks includes: The first number of delay units are used as adjustment units, and the delay circuit controls the first capture clock to pass through different numbers of adjustment units respectively, so that the first capture clock is delayed to different phases respectively, thereby forming a plurality of different second capture clocks; The delayed phase and the specified phase difference are in a multiple relationship, and the number of adjustment units that the first capture clock passes through each time is one more than the number of adjustment units that the first capture clock passes through last time.
5. The digital signal sampling method according to claim 1, characterized in that: The sampling of the signal wave to be sampled based on the first capture clock and the second capture clock includes: sorting or marking the first capture clock and a plurality of second capture clocks according to delay durations; The signal wave to be sampled is sampled based on the sorted or marked first capture clock and multiple second capture clocks.
6. The digital signal sampling method according to claim 1, characterized in that: The method further comprises: Obtaining a first sampling result of the first capture clock and a second sampling result of each of the second capture clocks; The plurality of second sampling results are divided into sampling periods based on the sampling frequency of the first capture clock to obtain a plurality of groups of acquisition results corresponding to different sampling periods, and the sampling periods corresponding to the sampling results in the same group are the same.
7. The digital signal sampling method according to claim 1, characterized in that: The calculating and determining the number of high level width cycles of the signal wave to be sampled based on the plurality of groups of sampling results comprises: Counting the number of first values in each group of the sampling results in chronological order, the first values representing that the signal is at a high level at the corresponding sampling moment; Calculating a ratio of the number of first values to the number of capture clocks in each group of the sampling results, where the number of capture clocks is the sum of the first capture clock and the number of the plurality of second capture clocks; Based on the ratio in each group of the sampling results, the ratios of multiple consecutive groups of first sampling results that meet the high-level sampling characteristics are summed, and the sampling periods corresponding to the multiple consecutive groups of first sampling results cover the number of high-level width periods of the signal wave to be sampled.
8. The digital signal sampling method according to claim 1, characterized in that: The step of calculating and determining the number of low level width cycles of the signal wave to be sampled based on the plurality of sampling results comprises: Counting the number of second values in each group of the sampling results in chronological order, the second value representing that the signal is at a low level at the corresponding sampling moment; Calculating a ratio of the number of second values in each group of the sampling results to the number of capture clocks, where the number of capture clocks is the sum of the first capture clock and the number of the plurality of second capture clocks; Based on the ratio in each group of the sampling results, the ratios of multiple consecutive groups of second sampling results that meet the low-level sampling characteristics are summed, and the sampling periods corresponding to the multiple consecutive groups of second sampling results cover the number of low-level width periods of the signal wave to be sampled.
9. A digital signal sampling device, characterized in that: include: A first determination module, used for determining the band and the number of bands in which the first capture clock has a specified phase difference within a period; A second determining module, used to determine a first number of delay units corresponding to the band in the delay circuit; a first adjustment module, configured to use the first number of delay units as adjustment units, and to adjust the first capture clock by the delay circuit based on different numbers of adjustment units respectively, so as to generate a plurality of different second capture clocks, each of the second capture clocks being delayed by n of the bands relative to the first capture clock, where n is a positive integer and is less than the number of the bands; A sampling module, used for sampling the signal wave to be sampled according to the first capture clock and the second capture clock to obtain multiple groups of sampling results that meet the timing, each group of the sampling results corresponds to a sampling period of the first capture clock, and includes sampling data of the first capture clock and the second capture clock in the sampling period; The third determination module is used to calculate and determine the number of high-level width cycles and the number of low-level width cycles of the signal wave to be sampled according to the multiple groups of sampling results.
10. An electronic device, characterized in that: include: at least one processor; as well as, a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to implement the digital signal sampling method according to any one of claims 1 to 8.
