The copied https://oshwhub.com/liujigang/shuidimenjinka made a panel to maximize the use of the pcb
panel placed in one order. The size is within 10*10, and the connection area is enlarged. It complies with the production specifications and
has been verified by the board.
Periodic signal waveform identification and parameter measurement device (J question)
# 1. Introduction
The periodic signal waveform identification and parameter measurement device designed this time uses the ARM Cortex-M4 processor as the main controller and a high-speed voltage comparison circuit built with a high-speed precision operational amplifier. , voltage amplifier circuit, precision rectifier circuit and voltage following circuit, etc., form a signal processing circuit; and based on the ARM Cortex-M4 processor through corresponding algorithms, the identification of signal waveform type and the measurement of frequency, peak-peak and other related parameters are realized. The system can identify and measure the frequency, peak-to-peak value, duty cycle and other related parameters of the signal waveform with a frequency of 100Hz to 10kHz and a peak-to-peak value in the range of 1V to 10V. It also adds upper and lower limit sound and light alarm functions, color display, multi-interface switching and other functions to improve the practicality of the system.
![QQ screenshot 20211216170947.png]

# 2. Project analysis
1. Use an operational amplifier to precisely rectify the input signal, compare the voltage to achieve multi-channel switching, and amplify or attenuate the input voltage to make the signal suitable for the ARM Cortex-M4 processor Sampling range. Since the voltage range of the sampling signal that the ARM Cortex-M4 processor can receive is limited, if the voltage value of the signal to be measured exceeds the range that the ARM Cortex-M4 processor can collect, if the measurement method of Scheme 1 is used, the higher voltage value cannot be collected. . After comprehensive consideration, choose option two.
After analyzing and comparing several common waveforms (sine wave, square wave, triangle wave). It is found that there is a big difference between their respective peak values and effective values, and the ratio between the two, that is, the crest coefficient, is always a constant value and does not change with the changes in the amplitude and frequency of the input signal. Generally, the measured waveform is symmetrical, so the waveform type can be determined by using the crest coefficient for identification based on the ratio of the peak value and the effective value of the measured waveform (crest coefficient). The waveform coefficients and crest coefficients of common waveform signals are shown in Table 2-1.
Table 2-1 Comparison of form coefficients and crest coefficients of common waveforms
| | | | |
| --- | --- | --- | --- |
| Waveform category | Form coefficient y | Crest coefficient a | Crest coefficient a /√√1 |
| sine wave | 1 | 2√2 | 1 |
| symmetric square wave | 0.9 | 1 | 1/2−−√1/2 |
| symmetric triangle wave | 0.993 | 3√3 | 3/2− −√3/2 |
It can be seen from Table 2-1 that the waveform coefficient y of sine wave, symmetrical square wave and symmetrical triangle wave is very close. It is difficult to distinguish the waveforms only by the waveform coefficient of the signal, and the difference in their crest coefficients is is larger, it is easier to distinguish from the value of the crest coefficient. The determination method is: use the crest coefficient to determine. If the value is equal to 1, the signal is a sine wave; if it is less than 1, it is a symmetrical square wave; if it is greater than 1, it is a symmetrical triangle wave. From the above analysis, it can be seen that using the crest coefficient for waveform identification is an effective method. After analyzing and comparing several common waveforms (sine wave, square wave, triangle wave). It is found that there is a big difference between their respective peak values and effective values, and the ratio between the two, that is, the crest coefficient, is always a constant value and does not change with the changes in the amplitude and frequency of the input signal. Generally, the measured waveform is symmetrical, so the waveform type can be determined by using the crest coefficient for identification based on the ratio of the peak value and the effective value of the measured waveform (crest coefficient). The waveform coefficients and crest coefficients of common waveform signals are shown in Table 2-1.
2. For the peak-to-peak value, we divide it into three channels: small signal amplification and large signal attenuation. Keep the signal within the range that the microcontroller can measure.
3. The frequency uses a comparator to measure the microcontroller interrupt.
# 3. System composition
! [QQ screenshot 20211216171257.png]

# 4. Hardware part
Hardware description:
Figure 1 is a functional version that implements signal processing. The 6-way relay on the right actually processes three-way signals, as shown in Figure 3-1 for signals. Amplify, maintain, and attenuate.
But why use 6-way?
Because our experiment found that if three-way relays are directly used without isolation, when the signal is switched to one way, the other two operational amplifiers will "floating", which will cause signal interference, so three-way relays were added, and the microcontroller can control any one signal supply to "floating" "The phenomenon can be eliminated.
The left side of the schematic diagram is to amplify, keep unchanged, and reduce the signal, because the signal processed by the microcontroller is either 5V or 3V. It should be controlled within this range.
After signal processing, when writing the program, it is just a matter of multiples to restore the voltage value of the original signal.
After experiments, we found that to process signals from 1HZ to 50KHZ, the LM358 can meet the requirements. Of course, we also used other expensive op amps at the time, but the LM358 is relatively cheaper and is completely sufficient to handle this problem.
This shows that for a constant signal, there is no need to add a pressure follower. Our experiments have found that adding a pressure follower is not good for processing low-frequency signals, and the waveform will change greatly. This can be processed directly by the microcontroller.
The right side is the interface for microcontroller processing:
Frequency: Because it comes from the comparator, either high level or low level, the microcontroller can handle it easily.
Amplitude: Mainly ADC sampling. It is best to have a high-speed ADC module for processing so that the collected waveform points are denser and the waveform difference is larger and the recognition rate is more accurate. This time we were not prepared and directly used the ADC function that comes with stm32f407ze.
Improvement suggestions:
1. What is used here is to use relays for switching. In fact, analog switches can be used. Here are several analog switch models recommended: four-way two-way analog switch CD4066, single eight-way analog switch CD4051, dual four-way analog switch CD4052, like this The PCB size will be much smaller.
2. It is recommended to use a high-speed Adc module to process the signal amplitude, because the number of 50khz acquisition points collected by stm32f407ze is uneven, although multiple acquisitions can be accumulated. But collection takes time. The performance questions require to be completed within three seconds, so in order to reduce the complexity of the code, it is best to change the hardware and change the hardware.
The function implementation board is as shown in Figure 1
! [yjt.png]

The following is the microcontroller development board and 5V power supply block used: The stm32f407VE board used was purchased online. The schematic diagram is attached and the link is attached, so I will not draw it.
Development board purchase link: [https://m.tb.cn/h.f8qSFPF?sm=25c03f](https://m.tb.cn/h.f8qSFPF?sm=25c03f)
5V power module: [https: //m.tb.cn/h.fjLDGHV?sm=53b407](https://m.tb.cn/h.fjLDGHV?sm=53b407)
Screen module used by the program: [https://m.tb.cn /h.fjpRMgi?sm=5c4546](https://m.tb.cn/h.fjpRMgi?sm=5c4546)
Because the development board comes with 5V to 3.3V conversion and some storage circuits, a lot of hardware is saved during the competition. Just do the wiring directly.
How to wire?
The dual-channel adjustable power supply is connected to the +- power supply (as shown in Figure 2-1). Because the op amp requires +=12V, adjust the two power supplies to 12V according to the following connection method: the left is +12V, the middle is GND, and the right is -12V.
12V is connected to the + of the power module, and GND is connected to GND.
This is an adjustable power module and directly press + -Just adjust the output to 5V for the microcontroller development board.
As for the screen, this time I used a 1.8-inch TFT screen. Because the performance part needs to display parameters at the same time, the screen needs to be larger.
The overall wiring diagram is shown in Figure 2-2.
Figure 2-3 is the schematic diagram of the development board.
Figure 2-1
![Solution.png]

Figure 2-2
![jxt.png]

Figure 2-3
![zxxt.png]

# 4. Software design block diagram
![rf.png]

is written using the standard library and used for ADC DMA is used to increase sampling speed and external interrupt is used for frequency measurement. Attached below. The following 4-1 is for module peripheral initialization
! [ztt.png]

# 5. Measurement error
! [QQ screenshot 20211216172707.png]

# 6. Test result analysis
This work uses STM32F407 as the main control chip, with a high-speed precision operational amplifier, Precision rectifier circuit, high-speed voltage comparator, voltage amplifier, voltage follower and other components are built to form the entire system hardware circuit. Through testing and inspection, the system can detect and judge various waveforms of 50mV≤VPP≤10V, 1Hz≤f≤100kHz, with fast detection speed and high accuracy, completing all the functions of the question. At the same time, this work also adds upper and lower limit sound and light alarm functions, color display, multi-interface switching and other functions.
# 7. Signal measurement and identification of PCB board
! [QQ screenshot 20211216233929.png]

reverse side
! [QQ screenshot 20211216233940.png]
2021J question code.zip
Periodic signal waveform identification and parameter measurement device (J question).pdf
Design report.docx
My video.mp4
BOM download
PCB_Waveform parameter measurement relay version_2022-09-22.pdf
PCB_Waveform parameter measurement relay version_2022-09-22.json
Waveform parameter measurement relay version_2022-09-22.pcbdoc
Gerber_waveform parameter measurement relay version.zip
Schematic_Waveform Identification_2022-09-22.pdf
SCH_Waveform Identification_2022-09-22.json
Sheet_1_2022-09-22.schdoc
62041
electronic