First of all, I would like to thank everyone from all walks of life for guiding my project. Please correct me if there are any omissions in the article! I have participated in many electronic design competitions. This time I made the 2021 J question periodic signal waveform identification and parameter measurement device, an advanced graphic oscilloscope, frequency 1HZ to 200Khz, supports the measurement of 10 parameters, and the waveform is displayed in real time. In this project Here, I will analyze the circuit structure in detail with you. I hope you can learn from my project.
Name: Lei Chaolin, English name: Mark Lei, pen name: Fu Lai
Born in 2000 in Hengyang, Hunan.
Electronic and electrical major, focusing on integrated circuit testing technology and high-frequency signal processing fields
Award-winning experience (chronological order)
Published the paper "Exploration on STM32 and PID Algorithm" in April 2020
First Prize in the Electronic Design Competition of the Ministry of Science, Technology and Innovation in July 2020 (Host)
Outstanding students of Lichuang Internet of Things summer practical training camp in August 2020
First Prize in the Academy’s Embedded Design Competition in September 2020 (Host)
Provincial first prize in Hunan Province Electronic Design Competition (TI Cup) in October 2020 (host)
Provincial First Prize in the 2021 Hunan Vocational College Skills Competition (Integrated Circuit Application and Development) (Host)
First Prize of Lichuang Tuya Smart Joint Training Camp in March 2021 (Host)
Second prize in the Hunan Provincial Industrial and Information Technology Skills Competition in October 2021, and the honorary title of National High-end Technical Expert (host)
First Prize in the Hunan Division of the National College Student Electronic Design Competition in November 2021 (Host)
To be continued…
The picture above shows the work report to Li Zhijian (first from left), Director of the Hunan Provincial Department of Science and Technology
First we get the question and analyze it

The title reminds us that we need to do a
Design a waveform identification and parameter measurement device for periodic signals that can identify a given signal
The type of waveform and measuring the parameters of the signal, isn’t this an oscilloscope?
There is a lot of information about oscilloscopes online, but it is still difficult to make a powerful one.
The above is the functional part
From the perspective of the performance part, the frequency range of the basic part is increased, and 3 additional measurement parameters are required. This requires the processing speed of our microcontroller to be faster, so I chose the STM32F4 series microcontroller for data analysis. There are also very high requirements for the preamplifier circuit, which not only requires the input of differential mode and common mode signals, but also requires a high adoption rate, that is, the slew rate. The op amp I chose here is TL084, which is a high-speed op amp that integrates four operational amplifiers with a slew rate of 15v/us.
The slew rate of TL084 is 15V/us, which fully meets the requirements.
If we choose a general-purpose op amp here, because the slew rate is too low and a 50khz sine wave is input, the output waveform will get a trapezoidal wave, and the waveform will be completely distorted.
Designing a good pre-processing part will make our equipment better and perform better. So we focus on designing the pre-processing part.
I will introduce the main components here, and I will introduce the schematic diagram and PCB later.
At the same time, the most difficult part of this question is the extremely low frequency measurement method of 1Hz, which must be completed within 3 seconds. At the normal sampling rate, it takes 5 cycles. However, we detect the frequency through the zero-crossing detector and then reduce the sampling rate. , sampling can be completed within 1s.
1. Main power circuit

Power supply part. We use two linear voltage regulator chips, 7805 and 7905. Why use a linear voltage regulator chip? Because our circuit is a high-frequency circuit and is easily affected by the power supply, we use linear voltage stabilization to reduce ripple. The input uses an anti-reverse connection diode to avoid incorrect polarity of the power input, thereby burning out the motherboard. At the same time, an ams1117 is used to power the post-level level conversion circuit. In the power output part, a large number of filter capacitors are used to improve the stability of the power supply.
2. Gear detection and pre-processing

This circuit is the main circuit of the front stage, and it realizes multiple functions through an operational amplifier. The first thing that comes in is the AC and DC coupling, then the voltage follower and then three operational amplifiers. One is responsible for amplifying the signal 10 times, one is responsible for reducing the signal by two times, and the other is responsible for reducing the signal by 5 times. U6 is CD4051. Responsible for selecting the signal to the post-stage circuit. The default state is to amplify 10 times. The post-stage circuit detects the amplification by 10 times. If it exceeds the threshold, switch to the second gear, pass-through. If the pass-through signal is still very large, then switch to Zoom in twice, and finally switch to zoom in 5 times. The above switching is based on the amplitude of the signal and is detected by the subsequent circuit. We should note here that the selection of resistors must be high-precision resistors, otherwise it will affect the amplification factor.
The peak-to-peak voltage range that needs to be collected in this design is 0.05V to 10V , and the absolute value of the relative error is not greater than 1% . Since the input voltage of the ADC is 0-2.5V , the measurement signal should be limited to this range. Considering that the linearity of the signal conditioning circuit and ADC will be better in the middle area and worse at both ends, 2V can be selected as its upper limit measurement boundary. At this time, the lower limit measurement boundary can be selected 200mV , which can make the voltage in the low voltage area After amplification, it can switch seamlessly with the medium voltage area. At the same time, the maximum voltage of the high-voltage channel is 10V , which is reduced to 2V after being reduced by 5 times , which can be seamlessly switched with the medium voltage area.
3. Amplitude detection circuit

The above is an amplitude detection circuit, which is a comparator. Through comparison, the amplitude of the input signal is known. If the input signal is greater than the threshold, a low-level signal is output to the microcontroller. If the input signal is less than the threshold, a high-level signal is output. signal to the microcontroller. Thereby detecting whether the amplitude of the input signal is within the sampling range of the microcontroller.
3. Post-processing circuit

First of all, the post-processing part is divided into a voltage boost part, a zero-crossing detection part, and a protection part. U 1.4 is responsible for voltage reversal, converting the input positive voltage into negative voltage, and then inputting it into the adder circuit. The two negative signals are added to obtain a positive signal zero-crossing detection circuit. When the input signal reaches a positive voltage, a signal is output to the microcontroller to obtain the frequency of the signal. To be precise, it is a level-raising circuit, otherwise the microcontroller cannot collect negative signals.
What we should note here is that the microcontroller can only collect 2.495v, so we have to add diodes for protection. You used 4 diodes. The voltage drop of one diode is 0.6 volts, and the voltage drop of 4 diodes is 2.4 volts. In order to protect the microcontroller from being damaged, why is inverse proportional amplification used here? Because inverse proportional amplification can eliminate common mode interference, it is best to use inverse proportional amplification in general circuits.
4. Single chip microcomputer selection

Lichuang Mall No. C28730
The microcontroller I chose is STM32F407ZET6. The computing speed can reach 168MHz, which can fully meet the requirements of the question. The sampling rate of the 12-bit ADC is also very high.
When using this chip, you must pay attention to the frequency of the external crystal oscillator of the chip. The crystal oscillator of the Internet port of the microcontroller is not far from the external crystal oscillator of the chip. I regarded the chip crystal oscillator frequency as the network port crystal oscillator frequency of 25M. As a result, garbled characters appeared no matter how I debugged it. Send 03 The serial port debugging tool shows FCE0E0, which makes me very depressed. After two weeks of adjustment, it still doesn’t work.
5.Screen selection

The screen I chose is a 3.2-inch TFT screen with a touch screen and a high refresh rate. Lichuang Mall No.: C189213

The picture above shows the 3D model
The most important thing for a good circuit is PCB design, especially for this kind of high-frequency circuit. If the design is not good, the performance will be greatly reduced. The power supply and main circuit here are separated. Use single point grounding. Greatly eliminate the impact of power supply on the circuit. This enables the circuit to achieve optimal performance.
Enter the tuner. I use a tuner like an oscilloscope. Can be connected directly to the signal generator. Can eliminate external interference.
What we should also note here is that the op amp must be powered by a positive and negative power supply, otherwise the negative voltage signal cannot be collected.
1Software design
1.1 Main program software design ideas

Waveform type identification algorithm flow chart



The relevant code has been uploaded as an attachment
The following is the test data


