Abstract
High-precision waveform identification and measurement are effective for waveform detection and evaluation in signal processing. The accuracy of waveform identification, precision of measurement, and speed of response are important indicators of waveform measurement instruments. To detect the waveform accurately, a hold and attenuation circuit divided into two is designed, and the STM32F4 microcontroller is used to accurately capture and perform spectrum analysis using a high-precision analog-to-digital converter based on fast Fourier transform technology to identify key parameters, such as waveform type, frequency, peak-to-peak value, and duty cycle. To improve the recognition accuracy and response speed, technical solutions, such as high-frequency sampling and over-zero detection, are used to improve the system efficiency. Algorithm simulation, circuit simulation, and physical testing show that the high-precision waveform synchronization recognition circuit and algorithm can accurately recognize various essential waveforms in the voltage and frequency ranges of 50 mV ≤ VPP ≤ 10 V and 1 Hz ≤ f ≤ 50 kHz, respectively, and simultaneously measure important parameters, such as frequency, peak-to-peak value, and duty cycle with an accuracy within ±1%. Intelligent linkage, no intermediate parameter setting, and a response speed of approximately 0.3 s make it suitable for such applications as fast and high-precision waveform intelligent detection and display. The method is highly integrated, simple to operate, cost-effective, and practical.
Introduction
Waveform recognition technology is important for the wide application of digital instrumentation [1, 2]. With the increasing demand for accuracy and response speed of waveform recognition, high-precision waveform recognition, fast display, and accurate measurement of key parameters are essential in intelligent troubleshooting, clinical electrocardiography detection, and radar waveform recognition [3–5]. At present, waveform recognition and measurement typically use waveform coefficient recognition, calculation of the root mean square (RMS) value, and other methods that can adapt to the most common measurement scenarios [6, 7]. However, cases with low frequency and high voltage amplitude suffer from inaccurate waveform recognition and large peak-to-peak (Vpp) errors [8]. Moreover, owing to the low-frequency measurement method used in the low-frequency case, the sampling rate is slow, resulting in a long response time, which seriously affects further applications of the relevant technology [9].
Periodic waveform measurements are usually divided into two categories: sinusoidal and non-sinusoidal signals. Sinusoidal signals are comparatively easy to identify mainly because the ideal sinusoidal RMS and fundamental RMS are equal, the high harmonics are zero, and the proportionality between the RMS and the peak-to-peak value is fixed [10]. The identification method for non-sinusoidal waves is relatively complex. One method is to calculate the RMS value of the periodic signal and use the relationship between the RMS value and the peak value for identification; however, the accuracy of this method is relatively insufficient. Another method is to use the Fourier series to analyze the base wave characteristics of the signal using the relationship between the base wave RMS and the total RMS, which is more accurate; however, the realization of the difficulty is more complex [11, 12]. As an important method for waveform parameter measurement, the lock-in frequency measurement method can determine frequencies with a slow drift over a small frequency range with high precision and efficiency [13].
Traditional waveform recognition and measurement instruments commonly have insufficient amplitude span and small frequency gaps. In ordinary experiments and measurement environments, the approach can still be used normally, but for amplitude and frequency spanning with large scales (50 mV ≤ Vpp ≤ 10 V, 1 Hz ≤ f ≤ 50 kHz), the shortcomings are obvious. Waveform analysis at low input voltages and high input frequencies is prone to such issues as inaccurate signal analysis, insufficient precision (>1%), and slow response speed (>3 s). Furthermore, the cumbersome instrument connection and analysis process requires a certain degree of professionalism from the user, and its practicality is greatly reduced for staff with a relative lack of professional foundation [14]. Therefore, the development of a cross-scale, high-precision, fast-response waveform recognition and measurement device that can achieve a variety of waveform recognition and real-time measurement tasks of important parameters is significant for observing and analyzing signals in practical applications.
Considering the practicality, development cost, measurement range, measurement accuracy, response speed, and other application requirements, a signal following the preamplifier circuit was developed to amplify or reduce the signal, which ensures that the input signal can be adapted to the normal operating range of the microcontroller. The identified signal can be designed into two routes for waveform identification and parameter measurement. One route, a high-performance analog-to-digital converter (ADC), was adopted to quantize the signal to be measured. The waveform and parameters were then identified and measured using a fast Fourier transform (FFT) [15, 16]. The frequency and voltage peak-to-peak values were calculated. Another route was to use a high-performance ADC and direct memory access (DMA) to complete the data transmission. The AD conversion was triggered by a timer, and the waveform duty cycle and other parameters were measured.
The system is operated and controlled by an STM32 microcontroller, and waveform recognition and an online display are used. The current waveform type, duty cycle, peak-to-peak value, frequency, and other important parameters are output in real time. Thus, circuit designers can determine the current state of the signal accurately. In the circuit test, these circuit design methods and spectrum analysis algorithms could identify the waveform and measure the important parameters quickly and accurately, with an accuracy in ± 1% and a response speed of 0.3 s, which meet the requirements of most high-precision and fast waveform measurement applications.
System and methods
Accurate waveform-type identification and high-precision parameter measurements are important for signal processing. In particularly, such applications as medical devices in the life sciences and radar satellites in the military require support from information-processing technologies [17]. Test and measurement instruments are also important judgment bases for information technology to meet precision requirements. At present, international test and measurement instruments mainly come from several international instrument companies. There are many functions, including high resolution and wide bandwidth. Other spectrum-analyzing equipment on the market is generally expensive. However, for commonly used signal recognition and analysis instruments, on the one hand, there is no requirement for high precision; on the other hand, cost is an important consideration. With the continuous development of information technology, signal analysis hardware and software are relatively mature, and the use of existing equipment can be considered to build high-precision, easy-to-operate, cost-controllable signal measurement equipment through synergistic hardware and software calculations and debugging to complete the rapid identification of the signal and the accurate measurement of important parameters [18].
Theoretically, any continuously measured time-domain signal can be represented as an infinite superposition of sine wave signals of different frequencies. Using the Fourier transform, the RMS values of the fundamental and multiple harmonic components of a non-sinusoidal waveform are calculated, assuming that the signal to be sampled is a periodic function of time, whose expression is
| (1) |
| (2) |
Its discrete expression is
| (3) |
where N is the number of sampling points per cycle, Xk is the kth sampling result, and X0 and XN are the 0th and Nth sampling results, respectively. Therefore, the base wave RMS is
| (4) |
Here, the initial phase angle is
| (5) |
The total harmonic RMS value is the RMS of the RMS values of the individual harmonic components:
| (6) |
Waveform recognition is used to determine the signal waveform in the frequency domain. A sine wave has only a fundamental component, whereas a rectangular and a triangular wave have harmonic components, such as the third, fifth, and seventh harmonics, in addition to the fundamental components, and the third-harmonic components are 1/3 and 1/9, respectively. The third-harmonic components are 1/3 and 1/9 of the fundamental, and the ratio of the harmonic RMS values can also be used as a reference for waveform recognition.
The waveform recognition and measurement system in this study can be divided into two parts. The preamplifier circuit is responsible for voltage following, including amplification and attenuation circuits to ensure that the microcontroller can work properly within the acceptable voltage range. It is also necessary to ensure that seamless switching is maintained in low-to-medium-voltage and high-to-medium-voltage situations. The second part is the microcontroller signal-processing module. The two signals sent from the preamplifier circuit are analyzed spectrally one way to identify the waveform and measure the peak-to-peak value of the voltage. The other way is transmitted by the ADC DMA to measure the duty cycle and frequency of the waveform through the timing circuit. A block diagram of the system is shown in Fig 1.
Fig 1. Block diagram of the system structure.
For periodic waveforms, including positive and negative half-weekly signal cycle changes, the direct reading signal of the microcontroller should be greater than zero. Therefore, it is necessary to use a bias circuit to convert the negative half-week signal into a positive half-week waveform to ensure that the microcontroller can read the signal accurately. The parallelism of the calculation is improved to ensure the speed of the parameter measurement. The signal is first read dynamically, and then a voltage-following strategy is adopted to attenuate the signal for high-voltage-value input (>5 V) and amplify the signal for low-voltage-value input (<2 V). Finally, the signal is quantized by the ADC, one way using Fourier transform for spectrum analysis to identify the waveform and measure the frequency, and the other way through the difference between the over-zero voltage value and the maximum voltage value to measure the peak-to-peak value and calculate the duty cycle.
To measure a typical large-span voltage range, a value of 50 mV to 10 V must be measured. Because the input voltage range of common ADCs is 0–2.5 V, the signal to be measured must be attenuated or amplified to ensure the proper operation of the ADC. Usually, the signal modulation circuit and the linearity of the ADC work better in the middle region than at the ends. Here, 2 V is used as the upper measurement limit, and the lower measurement limit is set to 200 mV. This method ensures that the signal in the low-voltage region can be amplified and seamlessly connected to the middle-voltage region. Moreover, for the high-voltage case of 5–10 V, signal attenuation is required to ensure a seamless connection with the medium-voltage region. The medium voltage is set to 2 V. The schematic diagram of the preamplifier circuit section is shown in Fig 2.
Fig 2. Schematic diagram of the front circuit section.
The essential technologies for high-precision waveform synchronization recognition and measurement systems include waveform recognition and parameter measurement. Based on the preamplifier circuit, part of the signal sampling is performed by the high-performance ADC of the microcontroller to quantize the signal to be measured. A sufficiently high sampling rate is an important factor in ensuring the accuracy of waveform recognition and measurement. On this basis, a Fourier transform is used for spectrum analysis to identify the waveform type. The other part transfers data through the ADC DMA, starts the TIM3 clock departure AD conversion, and collects important parameters, such as the peak-to-peak value, frequency, and duty cycle of the current waveform.
The program design process has two steps. One is waveform identification and frequency, and peak-to-peak measurements. First, high-frequency ADC sampling is used to determine whether the signal is complete, sample the complete signal, access the signal rising edge/falling edge time, calculate the frequency of the waveform changes, and stop the capture channel signal sampling clock. After the frequency has been calculated, the complete signal flag is reset, and the timer is turned on to check whether the DMA reception is complete; in this case, the DMA directly accesses the data and filters out the maximum and minimum values. The peak-to-peak value is calculated from the difference. Subsequently the Fourier transform is used to obtain the values of the first- and second-harmonic components, calculate the ratio of the second-harmonic component to the first-harmonic component, calculate the slope, and identify the waveform. Finally, the DMA flag is reset to ensure data capture for the other timer channel. This is shown in Fig 3(A).
Fig 3. Flowchart of program execution.
(a) waveform identification and frequency and peak-to-peak value measurement and (b) duty cycle measurement.
In the next step, to measure the duty cycle, the time between two timing edges is calculated. When timer TIM5 starts to capture data, the system determines whether it is the first rising edge of the signal, is the first time of data initialization, and then determines the falling edge. The high-voltage time is calculated while the signal integrity is detected. The low-voltage time and the ratio between the two are calculated to derive the signal duty cycle, and finally the data are cleared. Here, a microcontroller with fast calculation ability is needed, such as the STM32F4, which can reach approximately 170 MHz to meet the current demand for fast calculation, as shown in Fig 3(B).
As shown in Fig 3(A), after starting high-speed ADC sampling, it is first necessary to detect whether the signal is complete and in a complete cycle signal before the frequency can be calculated accurately. After the DMA captures the data, the maximum and minimum values are screened, and the peak-to-peak value is calculated from their differences. In addition, the FFT is used to derive the value of each harmonic component. Through the ratio of the first- and second-harmonic components, the type of waveform is calculated, judged, and simultaneously given to the display part of the microcontroller. The spectrum is analyzed. The results are shown in Fig 4.
Fig 4. Spectrum analysis of FFT.
Results and discussion
To test the measurement accuracy, range, and response speed of this high-precision waveform synchronization recognition and measurement system, a random waveform is fed by a signal generator, and the system recognizes the waveform and calculates the frequency, peak-to-peak value, and duty cycle, with the expected response time timed within 0.3 s. Two sets of waveforms with peak-to-peak values and frequencies of 1 V ≤ VPP ≤ 5 V, 100 Hz ≤ f ≤ 10 kHz, and 50 mV ≤ VPP ≤ 10 V, 1 Hz ≤ f ≤ 50 kHz are given by the signal generator and passed through the waveform measurement system for identification and parameter measurement. The test results in the range of 1 V ≤ VPP ≤ 5 V, 100 Hz ≤ f ≤ 10 kHz are shown in Fig 5(A). Test results of waveforms in the range of 50 mV ≤ VPP ≤ 10 V, 1 Hz ≤ f ≤ 50 kHz are shown in Fig 5(B). The waveform identification and parameter measurement response times for both are approximately 0.2 s. The response times of the waveform identification and parameter measurement for both are approximately 0.2 s.
Fig 5. Waveform test results.
(a) test results in the range of 1 V ≤ VPP ≤ 5 V, 100 Hz ≤ f ≤ 10 kHz and (b) test results in the range of 50 mV ≤ VPP ≤ 10 V, 1 Hz ≤ f ≤ 50 kHz.
Based on the waveform test results shown in Fig 5(A), the original signal has a frequency of 1 kHz and a peak-to-peak value of 2 V with a 50% duty cycle sine wave. After passing through the high-precision waveform synchronization recognition and measurement device, the displayed results show a sine wave with a frequency of 1001 Hz, a peak-to-peak value of 1941.1 mV, and a duty cycle of 50.5%. The accuracy of the waveform recognition is evident, with a frequency error of only 0.1%, peak-to-peak measurement error of 2.9%, and duty cycle error of 1%. Fig 5(B) shows that the original signal is a sine wave with a frequency of 1 kHz and a peak-to-peak value of 10 V. After passing through a high-precision waveform synchronization recognition and measurement device, the displayed result is a sine wave with a frequency of 1001.0 Hz, peak-to-peak value of 10041.8 mV, and duty cycle of 50.1%. Waveform recognition is accurate, with a frequency error of only 0.1%, peak-to-peak measurement error of 2.1%, and duty cycle error of 0.2%. The measurements listed above fall within the acceptable ±3% error range for high-precision electronic products. Nevertheless, for irregular or nonperiodic input signals, the current methods may reduce the measurement accuracy and response speed because of the limited signal judgment method and insufficiently high chip sampling frequency. The replacement of higher-performance chips with smarter recognition methods can be improved.
Conclusions
The high-precision waveform synchronization recognition and measurement system is a waveform recognition and parameter measurement device for periodic signals designed and fabricated using the STM32F407ZGT6 microcontroller as the core, combined with signal scaling circuits, high-frequency ADC sampling, FFT algorithms, DMA transfers, and other signal-processing technologies. The basic waveform generated by the function signal generator is input directly into the voltage-scaling preamplifier circuit, and signals exceeding the voltage operating range of the microcontroller are attenuated and then entered to the microcontroller. The microcontroller acquires and calculates the data of the input waveform and recognizes the waveform and the measurement and display of the relevant parameters. The circuit simulation and actual verification demonstrate that the absolute value of the relative error between the waveform recognition results and all measured parameters in the peak-to-peak value VPP and frequency f is not greater than 3%, and the absolute value of the absolute error is not greater than 2% when the duty cycle D of the rectangular wave signal is in the range of 20%-80%. The response time of the waveform recognition and parameter measurement system is less than 0.3 s. The intelligent linkage and rapid response are suitable for such applications as fast and high-precision waveform recognition and critical parameters measurements. However, for irregular or non-periodic input signals, the measurement accuracy and response speed will be degraded due to the limited chip performance and judgment method, and the next step will be to replace the high-performance chip and intelligent measurement method to improve the system performance.
Supporting information
(RAR)
Data Availability
All relevant data are within the manuscript and the supporting information- compressed/ZIP File archive.
Funding Statement
the industry-University-Research Project of Wuhan Municipal Education Bureau (CXY202014); Education Research Program Project of Hubei Provincial Department (B2020405).
References
- 1.Yuan J, Wu T, Hu Y, Jiao Z. Faulty feeder detection based on image recognition of voltage-current waveforms in non-effectively grounded distribution networks. International Journal of Electrical Power & Energy Systems. 2022, 143: 108434. doi: 10.1016/j.asoc.2022.109663 [DOI] [Google Scholar]
- 2.Wang Q, Du P, Liu X, Yang J, Wang G. Adversarial Unsupervised Domain Adaptation for Cross Scenario Waveform Recognition. Signal Processing. 2020, 171: 107526. doi: 10.1016/j.sigpro.2020.107526 [DOI] [Google Scholar]
- 3.Jiajia J, Jindong C, Xianquan W,et al. Non-PLLhigh-precision synchronous sampling method among lots of acoustics acquisition channels for underwater multilinear array seismic exploration system[J].Journal of Measurement Science and Instrumentation,2022,13(01):41–50. doi: 10.3969/j.issn.1674-8042.2022.01.005 [DOI] [Google Scholar]
- 4.Zhou N, Luo L, Sheng G, Jiang X. High Accuracy Insulation Fault Diagnosis Method of Power Equipment Based on Power Maximum Likelihood Estimation. IEEE Transactions on Power Delivery. 2019, 34(4): 1291–1299. doi: 10.1109/TPWRD.2018.2882230 [DOI] [Google Scholar]
- 5.Xie C, Zhang L, Zhong Z. Quasi-LFM radar waveform recognition based on fractional Fourier transform and time-frequency analysis. Journal of Systems Engineering and Electronics. 2021, 32(5): 1130–1142. doi: 10.23919/JSEE.2021.000097 [DOI] [Google Scholar]
- 6.Liu H, Fu Z, Kong D, Wang H, Xiao Y. METHOD OF HIGH TIMING RESOLUTION PULSE SYNTHESIS BASED ON VIRTUAL SAMPLING. Metrology and Measurement Systems: Metrologia i Systemy Pomiarowe. 2022, 29 (2): 373–389. doi: 10.24425/mms.2022.140034 [DOI] [Google Scholar]
- 7.Saoudi A, Pepin CM, Dion F, Bentourkia M, Lecomte R, Andreaco M, et al. Investigation of depth-of-interaction by pulse shape discrimination in multicrystal detectors read out by avalanche photodiodes. Nuclear Science IEEE Transactions on. 1999, 46(3): 462–467. doi: 10.1109/23.775563 [DOI] [Google Scholar]
- 8.B Kim, KS Ryu, DJ Kim, et al. A Study on the Voltage Control Method of Primary Feeder by the Energy Storage System and Step Voltage Regulator. In: IFAC Workshop on Control of Smart Grid and Renewable Energy Systems, 2020. 10.1016/j.ifacol.2019.08.248 [DOI]
- 9.Chunxi Z, Xianmu LI, Shuang GAO. Fast acquisition methods based on sparse Fourier transform. Journal of Beijing University of Aeronautics and Astronautics. 2018, 44(4): 670–676. doi: 10.13700/j.bh.1001-5965.2017.0280 [DOI] [Google Scholar]
- 10.Zhang X, Dong J, Huang S, et al. A Novel Fusion Method for Generating Surface Soil Moisture Data With High Accuracy, High Spatial Resolution, and High Spatio‐Temporal Continuity. Water Resources Research. 2022, 58(5): 1–26. doi: 10.1029/2021WR030827 [DOI] [Google Scholar]
- 11.Chen CC, Tsui FR. Comparing different wavelet transforms on removing electrocardiogram baseline wanders and special trends. BioMed Central. 2020, 20(11):343. doi: 10.1186/s12911-020-01349-x [DOI] [PMC free article] [PubMed] [Google Scholar]
- 12.Chunyang W, Xuelian L. An Overview of Applied Research for Fractional Fourier Transform in Signal Processing. Journal of Changchun University of Science and Technology(Natural Science Edition). 2015, 38(05): 1–8. doi: 10.1186/S12911-020-01349-X [DOI] [Google Scholar]
- 13.Lu J. Lock-in frequency measurement with high precision and efficiency. Review of Scientific Instruments. 2020, 91(7): 075106. doi: 10.1063/5.0002377 [DOI] [PubMed] [Google Scholar]
- 14.K Liu, Tian S, Guo G, Xiao Y. Precisely synchronous and cascadable multi-channel arbitrary waveform generator. Review of Scientific Instruments. 2017, 88(3): 035110. doi: 10.1063/1.4978067 [DOI] [PubMed] [Google Scholar]
- 15.Lopez-Risueno G, Grajal J, Sanz-Osorio A. Digital channelized receiver based on time-frequency analysis for signal interception. IEEE Transactions on Aerospace and Electronic Systems. 2005, 41(3): 879–898. doi: 10.1109/TAES.2005.1541437 [DOI] [Google Scholar]
- 16.Zienko SI, Zhbanova VL. Fourier Analysis of the Spectral Characteristics of a Matrix Photodetector in the Frequency and Time Domain. Journal of Communications Technology and Electronics. 2022, 67(3): 335–339. doi: 10.1134/S1064226922030226 [DOI] [Google Scholar]
- 17.Janecek M, Wu H, Tai YC. A simulation study for the design of a prototype insert for whole-body PET scanners. IEEE Transactions on Nuclear ence. 2006, 53(3): 1143–1149. doi: 10.1109/TNS.2006.871899 [DOI] [Google Scholar]
- 18.Zahirniak DR, Sharpin DL, Fields TW. A hardware-efficient, multirate, digital channelized receiver architecture. IEEE Transactions on Aerospace and Electronic Systems. 1998, 34(1): 137–152. doi: 10.1109/7.640270 [DOI] [Google Scholar]





