Method for measuring instantaneous period of square wave pulse

By using a frequency-dividing counter and a high-frequency clock counter in the square wave pulse signal measurement system, combined with an inverter and gated mode, high-precision instantaneous period measurement of variable-period square wave pulse signals is achieved, solving the problem of large measurement errors in the prior art and improving the reliability and safety of the equipment.

CN120064772APending Publication Date: 2025-05-30SHANGHAI UNIV OF ENG SCI
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510302434.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-03-14
Publication Date
2025-05-30

AI Technical Summary

Technical Problem

In the prior art, when measuring square wave pulse signals of variable periods, it is difficult to achieve high-precision instantaneous period measurement, especially when there are large fluctuations in the pulse period, the measurement error is large, which affects the reliability and safety of the equipment.

Method used

Through a system composed of a frequency division counter, two high-frequency clock counters and inverter, the high-low-level segments of the pulse are counted using the gated mode and the high-frequency clock, and the measurement accuracy is monitored in real time and the frequency division number is adjusted to achieve high-precision instantaneous period measurement of variable-period square wave pulse signals.

Benefits of technology

It improves the accuracy of instantaneous period measurement of square wave pulse signals, reduces the demand for microcontroller CPU performance, and ensures the reliability and safety of equipment operation.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120064772A_ABST
    Figure CN120064772A_ABST
Patent Text Reader

Abstract

The invention relates to a square wave pulse period measurement method in the technical field of electronic measurement. The method comprises the following steps: obtaining a frequency division pulse P2 and an inverted pulse P3 by using a frequency division counter and a phase inverter; obtaining a count value Q1 by using a first counter; the system enters an interrupt service program at the low level stage Tb of the frequency division pulse P2; the instantaneous period of the pulse P1 to be measured is calculated, and a current instantaneous period measurement relative error is obtained through calculation; obtaining a count value Q2 by using a second counter; the system enters an interrupt service program at the low level stage Tc of the inverted pulse P3; the instantaneous period of the pulse P1 to be measured is calculated, and a current instantaneous period measurement relative error is obtained through calculation; the appropriate pulse frequency division number is calculated according to a measurement error limit value set by the system, and the frequency division number N set in the frequency division counter is updated. Through real-time monitoring of pulse period measurement precision, measurement parameters are adjusted in real time, and the accuracy of pulse signal instantaneous period measurement can be greatly improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to a method for measuring the period of a square wave pulse in the field of electronic measurement technology, and in particular to a method for measuring the instantaneous period of a square wave pulse whose pulse period changes instantaneously with time. Background Art

[0002] Square wave pulses are common signal forms in electronic devices. Square wave pulse signals are widely used in everything from small household appliances to large-scale applications such as automobiles, ships, satellite communications, and aerospace. During the operation of related electronic devices, accurately measuring and controlling the period and frequency of pulse signals is often the key to ensuring the reliable operation of the devices.

[0003] Currently, the measurement of the period of a square wave pulse usually adopts the method of counting pulses within a fixed time length or measuring the time for a fixed number of counting pulses. When measuring a pulse signal with a fixed period using these two methods, as long as an appropriate time length or an appropriate number of counting pulses is selected, the measurement result can reach a certain accuracy. However, when using these two methods to measure the pulse period, if there are large fluctuations in the period of the pulse to be measured, a large measurement error will occur, and this error has a high degree of uncertainty, which greatly reduces the accuracy of the measurement result. In severe cases, it may cause the device to malfunction and lead to safety accidents.

[0004] With the rapid development of electronic technology and information technology, square wave pulse signals with variable periods appear in various electronic devices in large quantities, and the range of period changes is relatively wide. For such a type of high-transient variable-period square wave pulse signal, it is necessary to quickly and accurately measure the instantaneous period and ensure that the measurement accuracy is consistent under different period conditions, so as to ensure the reliability and safety of device operation. Summary of the Invention

[0005] In view of the deficiencies of the prior art, the present invention proposes a method for measuring the instantaneous period of a square wave pulse. During the measurement process, by monitoring the real-time measurement accuracy of the pulse period and adjusting the measurement parameters in real time, the accuracy of measuring the instantaneous period of the pulse signal is greatly improved, and the requirements for the performance of the microcontroller MCU can be reduced.

[0006] The present invention is realized through the following technical solutions, and the present invention includes the following steps: Step S1: The to-be-measured pulse P1 with a variable period T1 is frequency-divided by a frequency divider counter according to a set frequency division number N to obtain a frequency-divided pulse P2, and the frequency-divided pulse P2 is inverted by an inverter to obtain an inverted pulse P3; Step S2: Use the first counter to work in the gated mode to count the system clock Fsys at any high-level stage Ta of the frequency-divided pulse P2, and stop counting at the end of the high-level stage to obtain a count value Q1; Step S3: At the falling edge of the frequency-divided pulse P2 when the first counter ends counting, trigger the first system interrupt, and the system enters the interrupt service routine at the low-level stage Tb of the frequency-divided pulse P2; Step S4: In the first system interrupt service routine, calculate the instantaneous period of the to-be-measured pulse P1, and calculate the current relative error of the instantaneous period measurement Terr1. After the calculation is completed, clear the first counter to 0; Step S5: Use the second counter to work in the gated mode to count the system clock Fsys at any high-level stage Tb of the inverted pulse P3, and stop counting at the end of the high-level stage to obtain a count value Q2; Step S6: At the falling edge of the inverted pulse P3 when the second counter ends counting, trigger the second system interrupt, and the system enters the interrupt service routine at the low-level stage Tc of the inverted pulse P3; Step S7: In the second system interrupt service routine, calculate the instantaneous period of the to-be-measured pulse P1, and calculate the current relative error of the instantaneous period measurement Terr2. After the calculation is completed, clear the second counter to 0; Step S8: According to the measurement error limit Terr set by the system, calculate a suitable pulse frequency division number Nnew from the current frequency division number N and Terr1 or Terr2, and update the set frequency division number N in the frequency divider counter.

[0007] Further, in the above step S1, the periods of the frequency-divided pulse P2 and the inverted pulse P3 are both N*T1, and the phases of P2 and P3 are opposite.

[0008] Furthermore, in the above steps S2 and S5, the frequency-divided pulse P2 is connected to the gated port Gate of the first counter, the inverted pulse P3 is connected to the gated port Gate of the second counter, and the system clock pulse Fsys is connected to the counting ports Clk of the first counter and the second counter.

[0009] Furthermore, in the above steps S3 and S6, the first system interrupt program triggered by the frequency-divided pulse P2 is executed at the low-level stage of P2, and the second system interrupt program triggered by the inverted pulse P3 is executed at the low-level stage of P3.

[0010] Further, in step S4, the instantaneous period of the pulse P1 to be measured is the period T2 of the frequency-divided pulse P2, which can be calculated according to the count value Q1 of the first counter and the system clock period Tsys, T2 = 2 × Q1 × Tsys; in step S7, the instantaneous period of the pulse P1 to be measured is the period T3 of the inverted pulse P3, which can be calculated according to the count value Q2 of the second counter and the system clock period Tsys, T3 = 2 × Q2 × Tsys.

[0011] Further, in the above steps, for the instantaneous period T1 of the pulse P1 to be measured at different times, using the frequency division number N, it can be calculated respectively from the period T2 of the frequency-divided pulse P2 and the period T3 of the inverted pulse P3, T1a = T2 / N = 2 × Q1 × Tsys / N, T1b = T3 / N = 2 × Q2 × Tsys / N; the absolute error DetaT of the instantaneous period T1 of the pulse P1 to be measured is 2 × Tsys / N, and the relative errors of the period of the pulse P1 to be measured measured by the frequency-divided pulse P2 and the inverted pulse P3 are respectively Terr1 = DetaT / T1a = 2 × Tsys / (N × T1a), Terr2 = DetaT / T1b = 2 × Tsys / (N × T1b).

[0012] Further, in the above steps S4 and S7, the first counter is cleared after the execution of the first system interrupt service program ends, and starts a new count in the next high-level stage of the frequency-divided pulse P2; the second counter is cleared after the execution of the second system interrupt service program ends, and starts a new count in the next high-level stage of the inverted pulse P3.

[0013] Further, in the above steps S4 and S7, the first counter and the second counter perform counting operations alternately according to the phase anti-correlation relationship between the frequency-divided pulse P2 and the inverted pulse P3, to continuously calculate the instantaneous period T1 of the pulse P1 to be measured. According to the frequency division number N, the calculation update period of the instantaneous period T1 is N * T1.

[0014] Further, in the above step S8, according to the measurement error limit Terr set by the system and the current frequency division number N, after the first system interrupt service program calculates the relative error Terr1 of the current instantaneous period of the pulse P1 to be measured, it calculates the new frequency division number Nnew, and Nnew should satisfy the relationship Nnew ≥ Nx = Terr1 × N / Terr; after the second system interrupt service program calculates the relative error Terr2 of the current instantaneous period of the pulse P1 to be measured, it calculates the new frequency division number Nnew, and Nnew should satisfy the relationship Nnew ≥ Nx = Terr2 × N / Terr; when the calculated Nx is an integer, Nnew = Nx, and when Nx is a decimal, Nnew takes the smallest integer larger than Nx.

[0015] Therefore, the present invention is applicable to a square-wave pulse instantaneous period measurement system composed of a frequency divider counter, two high-frequency clock counters, an inverter, etc. In the present invention, the frequency divider counter receives a square-wave pulse input signal, generates a new divided-frequency pulse according to a preset division ratio, and then converts it into an inverted pulse through an inverter. The gating mode of the first counter is triggered at any high-level stage of the divided-frequency pulse to perform the counting operation of the system clock, and the counting stops at the end of this high-level stage (i.e., the falling edge), and the first count value at this time is recorded. When the first counter finishes counting, the falling edge of the divided-frequency pulse triggers the first system interrupt, and the system enters the interrupt service routine in the low-level stage of the divided-frequency pulse. In the interrupt service routine, the instantaneous period of the pulse to be measured is calculated, and the current relative error Terr1 of the instantaneous period measurement is obtained. After the calculation is completed, the first counter is cleared. The second counter performs the system clock counting on any high-level stage of the inverted pulse in the gating mode, and the counting stops at the end of this high-level stage to obtain the second count value. After the second counter finishes counting, the falling edge of the inverted pulse triggers the second system interrupt, and the system enters the interrupt service routine in the low-level stage of the inverted pulse. In the service routine of the second system interrupt, the instantaneous period of the pulse to be measured is calculated again, and the current relative error Terr2 of the instantaneous period measurement is obtained. After the calculation is completed, the second counter is cleared. Finally, according to the measurement error limit Terr set by the system, combined with the current division ratio and Terr1 or Terr2, a new suitable division ratio Nnew is calculated and the division ratio N in the frequency divider counter is updated. Repeat the above steps to complete the instantaneous period measurement of the square-wave pulse to be measured.

[0016] Compared with the prior art, the present invention has the following beneficial effects: The present invention uses small single-chip microcomputer components such as frequency dividers, counters, and inverters. The method of calculating the pulse period occupies little CPU resources of the single-chip microcomputer, reducing the calculation pressure on the CPU of the single-chip microcomputer. The division ratio of the frequency divider counter is adjustable, and the advantage is that it can be adaptively adjusted for pulses of different frequencies. The pulse to be measured is measured by the first counter in the high-level segment, and then measured by the second counter in the low-level segment immediately. Combining the count values and relative errors in each counting stage, the instantaneous period of the frequency to be measured is calculated, and the division ratio is updated in real time to reduce errors and achieve high-precision measurement. Description of the Drawings

[0017] Figure 1 is a schematic diagram of the principle of a method for measuring the instantaneous period of a square-wave pulse in an embodiment of the present invention;

[0018] Figure 2 is a flowchart of a method for measuring the instantaneous period of a square-wave pulse in an embodiment of the present invention;

[0019] Among them, 11 is a frequency division counter, 12 is a first counter, 13 is an inverter, and 14 is a second counter. Detailed implementation manners

[0020] The present invention will be further described in detail below with reference to the accompanying drawings and embodiments. It can be understood that the specific embodiments described herein are only used to explain the present invention, rather than limiting the present invention. In addition, it should be noted that for the sake of description, only a part related to the present invention rather than all the structures are shown in the accompanying drawings.

[0021] The schematic diagram of the principle of the square wave pulse instantaneous period measurement method applicable to the embodiment of the present invention is as Figure 1 shown, and it includes a frequency division counter 11, two high-frequency clock counters, and an inverter 13. The inverter 13 is located between the two counters. After the pulse to be measured enters the measurement system, it is frequency-divided by the frequency division counter 11 to generate a frequency-divided pulse that enters the first counter 12; the first counter 12 uses the high-frequency clock to count the high-level segment, stops counting when the falling edge is triggered, and converts it into an instantaneous period; the frequency-divided pulse forms an inverted pulse through the inverter 13 and enters the second counter 14; the second counter 14 uses the high-frequency clock to count the high-level segment of the inverted pulse, stops counting when the falling edge is triggered, and calculates the instantaneous period of this segment; the two counters work independently, measure the current pulse period during the period when the counting ends, and calculate the relative error; the single-chip microcomputer calculates a new frequency division number according to the measurement error limit set by the system, combined with the current frequency division number and the relative error; the frequency division counter re-frequencies the pulse to be measured according to the new frequency division number to generate a new frequency-divided pulse; and so on to perform high-precision measurement of the instantaneous period of the pulse to be measured.

[0022] The flowchart of the method for implementing a square wave pulse instantaneous period measurement method according to the present invention is as Figure 2 shown, and this method is executed by the Figure 1 measurement system shown, and specifically includes the following steps:

[0023] Step S1: The pulse P1 to be measured with a variable period T1 is frequency-divided by the frequency division counter 11 according to the set frequency division number N to obtain a frequency-divided pulse P2, and the frequency-divided pulse P2 is inverted by the inverter 12 to obtain an inverted pulse P3.

[0024] Among them, since the inverted pulse P3 is obtained by inverting the frequency-divided pulse P2, the frequency-divided pulse P2 and the inverted pulse P3 have the same period, both of which are N*T1, and their phases are opposite. The high-level segment of P2 corresponds to the low-level segment of P3.

[0025] Step S2: Use the first counter 12 operating in gated mode to count the system clock Fsys during any high-level phase Ta of the divided-frequency pulse P2, and stop counting at the end of the high-level phase to obtain the count value Q1.

[0026] Among them, accurate counting of external events can be achieved through the gated mode. The divided-frequency pulse P2 is connected to the gated port Gate of the first counter 12 as the gated input signal of the first counter 12. The counter is enabled and starts counting when in a specific state (high level); the gated mode of the counter stops counting when the state of the input signal changes. Thus, the first counter 12 stops counting at the end of the high-level phase to obtain the count value Q1; the system clock provides a unified time reference for the entire system. A high-frequency system clock pulse Fsys is connected to the counting port Clk of the first counter 12 to implement the timing and counting functions.

[0027] Step S3: At the falling edge of the divided-frequency pulse when the first counter 12 finishes counting, trigger the first system interrupt, and the system enters the interrupt service program during the low-level phase Tb of the divided-frequency pulse.

[0028] Among them, the gated mode of the first counter 12 stops counting at the falling edge of the high level. Thus, the system triggers an interrupt at the falling edge of the divided-frequency pulse P2 and enters the first system interrupt program. That is, the first system interrupt program triggered by the divided-frequency pulse P2 is executed during the low-level Tb phase of the divided-frequency pulse P2.

[0029] Step S4: In the first system interrupt service program, calculate the instantaneous period of the pulse P1 to be measured, and calculate the current relative error Terr1 of the instantaneous period measurement. After the calculation, clear the first counter to 0.

[0030] Among them, the instantaneous period of the current pulse P1 to be measured is the period T2 of the divided-frequency pulse P2, which can be calculated according to the count value Q1 of the first counter 12 and the system clock period Tsys, T2 = 2 × Q1 × Tsys; the first counter 12 is cleared to 0 after the execution of the first system interrupt service program and starts a new count at the next high-level phase of the divided-frequency pulse P2.

[0031] Step S5: Use the second counter 14 operating in gated mode to count the system clock Fsys during any high-level phase Tb of the inverted pulse P3, and stop counting at the end of the high-level phase to obtain the count value Q2.

[0032] Among them, the inverted pulse P3 is connected to the gated port Gate of the second counter 14, and the system clock pulse Fsys is connected to the counting port Clk of the second counter 14. This system clock pulse is the same clock pulse as the first counter 12, ensuring the accuracy of the counting process.

[0033] Step S6: At the falling edge of the inverted pulse when the second counter 14 finishes counting, trigger the second system interrupt, and the system enters the interrupt service routine during the low-level stage Tc of the inverted pulse.

[0034] Among them, the gating mode of the second counter 14 stops counting at the falling edge of the high level of the inverted pulse P3, and the system enters the second system interrupt program, that is, the second system interrupt program triggered by the inverted pulse P3 is executed during the low-level Tc stage of the inverted pulse P3.

[0035] Step S7: In the second system interrupt service routine, calculate the instantaneous period of the pulse under test P1, and calculate the current relative error Terr2 of the instantaneous period measurement. After the calculation is completed, clear the second counter to 0.

[0036] Among them, the instantaneous period of the current pulse under test P1 is the period T3 of the inverted pulse P3, which can be calculated according to the count value Q2 of the second counter and the system clock period Tsys, T3 = 2 × Q2 × Tsys; the second counter is cleared to 0 after the execution of the second system interrupt service routine, and starts a new count at the next high-level stage of the inverted pulse P3.

[0037] The instantaneous periods T1 at different moments of the pulse under test P1, using the division frequency number N, can be calculated respectively from the period T2 of the divided-frequency pulse P2 and the period T3 of the inverted pulse P3, T1a = T2 / N = 2 × Q1 × Tsys / N, T1b = T3 / N = 2 × Q2 × Tsys / N; the absolute error DetaT of the instantaneous period T1 of the pulse under test P1 is 2 × Tsys / N, and the relative errors of the period of the pulse under test P1 measured by the divided-frequency pulse P2 and the inverted pulse P3 are respectively Terr1 = DetaT / T1a = 2 × Tsys / (N × T1a), Terr2 = DetaT / T1b = 2 × Tsys / (N × T1b).

[0038] The first counter 12 and the second counter 14 alternately perform counting operations according to the phase anti-correlation relationship between the divided-frequency pulse P2 and the inverted pulse P3, to continuously calculate the instantaneous period T1 of the pulse under test P1. According to the division frequency number N, the calculation update period of the instantaneous period T1 is N * T1.

[0039] Step S8: According to the measurement error limit Terr set by the system, calculate the appropriate pulse division frequency number Nnew from the current division frequency number N and Terr1 or Terr2, and update the division frequency number N set in the division frequency counter.

[0040] Among them, according to the measurement error limit Terr set by the system and the current frequency division number N, after the first system interrupt service program calculates the relative error Terr1 of the current instantaneous period of the pulse P1 to be measured, it calculates the new frequency division number Nnew. Nnew should satisfy the relational expression Nnew≥Nx = Terr1×N / Terr; after the second system interrupt service program calculates the relative error Terr2 of the current instantaneous period of the pulse P1 to be measured, it calculates the new frequency division number Nnew. Nnew should satisfy the relational expression Nnew≥Nx = Terr2×N / Terr; when the calculated Nx is an integer, Nnew = Nx, and when Nx is a decimal, Nnew takes the smallest integer larger than Nx.

[0041] A method for measuring the instantaneous period of a square-wave pulse provided in this embodiment measures the high and low level segments of the pulse through the gated modes of two counters and a high-frequency clock respectively, and converts the count value into a period through a formula to realize the measurement of the instantaneous period of the pulse to be measured. Since the two counters calculate the high and low level segments of the pulse to be measured respectively, work independently and do not interfere with each other, the continuous measurement of the instantaneous period of the pulse to be measured is realized, and the requirement for the performance of the single-chip microcomputer CPU is reduced.

[0042] Note that the above is only the preferred embodiment of the present invention and the technical principles applied. Those skilled in the art will understand that the present invention is not limited to the specific embodiments described above, and various obvious re-adjustments, changes and substitutions can be made by those skilled in the art without departing from the protection scope of the present invention. Therefore, although the present invention has been described in more detail through the above embodiments, the present invention is not limited to the above embodiments. Without departing from the concept of the present invention, more other equivalent embodiments can be included, and the scope of the present invention is determined by the scope of the appended claims.

Claims

1. A method for measuring the instantaneous period of a square wave pulse, characterized in that: The following steps are involved: Step S1, the pulse P1 to be tested with a variable period T1 is divided by a frequency division counter according to a set frequency division number N to obtain a divided pulse P2, and the divided pulse P2 is inverted by an inverter to obtain an inverted pulse P3; Step S2, using the first counter working in the gated mode to count the system clock Fsys in any high level phase Ta of the frequency-divided pulse P2, and stopping counting at the end of the high level phase to obtain a count value Q1; Step S3, at the falling edge of the frequency-divided pulse P2 when the first counter finishes counting, the first system interrupt is triggered, and the system enters the interrupt service routine during the low level stage Tb of the frequency-divided pulse P2; Step S4, in the first system interrupt service program, the instantaneous period of the pulse P1 to be measured is calculated, and the current instantaneous period measurement relative error Terr1 is calculated, and the first counter is cleared to 0 after the calculation is completed; Step S5, using the second counter working in the gated mode to count the system clock Fsys during any high level phase Tb of the inverted pulse P3, and stopping counting at the end of the high level phase to obtain a count value Q2; Step S6, at the falling edge of the inverted pulse P3 when the second counter ends counting, triggering the second system interrupt, the system enters the interrupt service routine during the low level phase Tc of the inverted pulse P3; Step S7, in the second system interrupt service program, the instantaneous period of the pulse P1 to be measured is calculated, and the current instantaneous period measurement relative error Terr2 is calculated, and the second counter is cleared to 0 after the calculation is completed; Step S8: According to the measurement error limit Terr set by the system, the appropriate pulse frequency division number Nnew is calculated from the current frequency division number N and Terr1 or Terr2, and the frequency division number N set in the frequency division counter is updated.

2. A square wave pulse instantaneous period measurement method according to claim 1, characterized in that In step S1, the periods of the frequency-divided pulse P2 and the inverted pulse P3 are both N*T1, and the phases of P2 and P3 are opposite.

3. A square wave pulse instantaneous period measurement method according to claim 1, characterized in that In steps S2 and S5, the frequency-divided pulse P2 is connected to the gate port Gate of the first counter, the inverted pulse P3 is connected to the gate port Gate of the second counter, and the system clock pulse Fsys is connected to the counting ports Clk of the first counter and the second counter.

4. A square wave pulse instantaneous period measurement method according to claim 1, characterized in that In step S3, the first system interrupt program triggered by the frequency-divided pulse P2 is executed in the low level phase of P2; in step S6, the second system interrupt program triggered by the inverted pulse P3 is executed in the low level phase of P3.

5. A square wave pulse instantaneous period measurement method according to claim 1, characterized in that In step S4, the instantaneous period of the pulse P1 to be measured is the period T2 of the divided pulse P2, which can be calculated according to the count value Q1 of the first counter and the system clock period Tsys, T2=2×Q1×Tsys; in step S7, the instantaneous period of the pulse P1 to be measured is the period T3 of the inverted pulse P3, which can be calculated according to the count value Q2 of the second counter and the system clock period Tsys, T3=2×Q2×Tsys.

6. A square wave pulse instantaneous period measurement method according to claim 5, characterized in that The instantaneous period T1 of the pulse P1 to be measured at different moments can be calculated by the period T2 of the divided pulse P2 and the period T3 of the inverted pulse P3 using the frequency division number N, T1a=T2 / N=2×Q1×Tsys / N, T1b=T3 / N=2×Q2×Tsys / N; the absolute error DetaT=2×Tsys / N of the instantaneous period T1 of the pulse P1 to be measured, and the relative errors of the period of the pulse P1 to be measured measured by the divided pulse P2 and the inverted pulse P3 are Terr1=DetaT / T1a=2×Tsys / (N×T1a), Terr2=DetaT / T1b=2×Tsys / (N×T1b).

7. A square wave pulse instantaneous period measurement method according to claim 1, characterized in that In steps S4 and S7, the first counter is cleared to 0 after the execution of the first system interrupt service program is completed, and a new counting starts at the next high level phase of the frequency-dividing pulse P2; the second counter is cleared to 0 after the execution of the second system interrupt service program is completed, and a new counting starts at the next high level phase of the inverting pulse P3.

8. A square wave pulse instantaneous period measurement method according to claim 1, characterized in that In steps S4 and S7, the first counter and the second counter perform counting operations alternately according to the phase inversion relationship between the divided pulse P2 and the inverted pulse P3, so as to continuously calculate the instantaneous period T1 of the pulse P1 to be measured. According to the divided number N, the calculation update period of the instantaneous period T1 is N*T1.

9. A square wave pulse instantaneous period measurement method according to claim 1, characterized in that The step S8 includes the following steps: after the first system interrupt service program calculates the relative error Terr1 of the current instantaneous period of the pulse P1 to be measured according to the system set measurement error limit value Terr and the current division number N, the new division number Nnew is calculated, and Nnew should satisfy the relationship Nnew≥Nx=Terr1×N / Terr; after the second system interrupt service program calculates the relative error Terr2 of the current instantaneous period of the pulse P1 to be measured, the new division number Nnew is calculated, and Nnew should satisfy the relationship Nnew≥Nx=Terr2×N / Terr; when the calculated Nx is an integer, Nnew=Nx, and when Nx is a decimal, Nnew takes the smallest integer larger than Nx.