1 Introduction
2.Personal introduction
3.Project analysis
5. Schematic circuit analysis
6. PCB design analysis
7. Physical display
8.Assembly of works
9.Programming
10. Summary
11. Accessories
Lichuang launched a call for e-sports competitions. If there was a bonus, we quickly signed up. The game was originally supposed to be held in early August, but the day before the game was planned, it was suddenly postponed. It’s a pity that two of the team can secure graduate degrees and one can only find a job. As the competition approaches in November, everyone still wants to play the last competition to make up for their regrets. The three of us are majoring in communications from the School of Information, so the direction we chose is signals. After the questions come out, there is only one question to choose from, which is question A. The THD measurement in the question is the same as that in the 20th provincial competition. With some experience, the difficulty is that we did not prepare TI devices, and the sampling frequency has been increased. In the last two days, I came up with the idea of using sequential equivalent sampling, which improved the problem index from 100kHz to 1MHz, which was very complete. A small drawback in the evaluation is that when measuring a 50KHz signal, the error is about 2%, which is significantly larger than the 1% for 1K and 100KHz. Leading to the final regret of the second country.
All three are, Grade 18 undergraduate students from Wuhan Institute of Technology
Majoring in electronic information engineering and communication engineering, mainly in hardware, embedded software, digital logic, and instrumentation.
Competition experience
2020 Hubei Provincial Electric Competition First Prize
2020FPGA Competition National Second Prize
2021 E-sports National Second Prize
Design and manufacture a signal distortion measurement device for periodic signals from function/arbitrary waveform generators.
To put it simply, it is to use TI devices to make a THD measurement device, which must meet certain input amplitude, frequency and THD value, the error is less than 3%, and can display the waveform and send it to the mobile phone for display.
We used an AGC circuit to stabilize the input amplitude. For the input frequency and THD value range, we could only use high sampling rate and accurate calculation to make up for it. In the end, we used sequential equivalent sampling to greatly increase the sampling rate, and The accuracy has increased a lot.
1) Selection of controllable gain amplification module solution
In this question, a wide voltage range of 30 to 600mV needs to be sampled. If fixed-gain amplification is performed directly, the amplified 30mV signal will have a smaller amplitude and the sampling error will increase, so segmented amplification is required.
Solution 1: Use the voltage-controlled amplifier VCA821 to form a voltage-controlled amplifier circuit. The bandwidth of VCA821 can reach 210MHz, and the DAC is controlled by the microcontroller to output voltage to adjust the circuit gain. This solution requires software control, has good flexibility, and the amplification factor is known. However, the disadvantage is that it needs to collect the amplitude and provide software feedback, which is difficult.
Solution 2: Use the voltage-controlled amplifier VCA821 to form an automatic gain control circuit (AGC). The dynamic adjustment range of VCA821 is -10dB~20dB. The AGC circuit adjusts the gain through hardware feedback, reducing software control and is simple to implement. The disadvantage is that the actual gain of the circuit is unknown.
To sum up, the system does not need to obtain the actual signal amplitude, so option 2 is chosen.
2) Data collection plan selection
Option 1: Real-time sampling. A periodic waveform is expressed by arranging the sampling points of each period in time sequence. The fundamental frequency of the input signal in this question can reach up to 100kHz. Measuring the 5th harmonic requires a sampling rate of more than 1MHz. The maximum sampling frequency of MSP432P401R is 1.024MHz, which is difficult to implement and difficult to meet the requirements of the question.
Option 2: Sequential equivalent sampling. Sequential equivalent sampling is to sample once in one cycle or multiple cycles, and reflect the original signal situation through the envelope formed after sampling. This solution can obtain extremely high bandwidth at an extremely low sampling frequency and is simple to implement, but it requires a known signal period.
To sum up, choose a combination of Plan 1 and Plan 2 to first perform periodic measurements, and then use sequential equivalent sampling to collect waveforms.
3) Selection of signal period measurement scheme
Since equivalent sampling requires knowledge of the time period, measurements are required.
Option 1: Use hysteresis comparator and use FPGA to measure frequency. This solution can measure very high frequencies with small frequency steps. However, when there are multi-peak signals, large errors will occur, which are difficult to solve in a short time.
Option 2: Use FFT to calculate the period. Using FFT operation, the frequency corresponding to the first maximum point in the spectrum is the fundamental wave period of the signal. This method is simple to use and the frequency measurement is accurate, but the spectrum frequency resolution may not be enough and the measurement frequency may be offset.
In summary, frequency resolution accuracy is used in exchange for accurate frequency measurement, so option two is chosen.
1) Analysis of sequential sampling principle
Sequential equivalent sampling is to sample once in one cycle or multiple cycles, and the envelope formed by the sampled discrete digital signal reflects the waveform of the original signal. The period of this envelope is much lower compared to the original signal. It can obtain extremely high bandwidth at extremely low sampling frequency and is mainly used in digital sampling oscilloscopes.
The schematic diagram of sequential sampling is shown in Figure 2. The sampling signal delay is
(1)
T is the period of the signal under test, and the equivalent number of sampling points in one period is n points, that is
(2)
From equation (1) and equation (2), the ratio between the actual sampling rate and the equivalent sampling rate is calculated as
(3)
That is, the equivalent sampling rate is n+1 times the actual sampling rate. This method can obtain extremely high bandwidth (up to 50GHz) at an extremely low sampling rate (100~200kHz).
Figure 2 Schematic diagram of sequential sampling
2) Principle analysis of harmonic components based on FFT
The calculation of each harmonic component is performed using the fast Fourier transform FFT algorithm. FFT is an improvement of DFT. It can use the DFT rotation factor and symmetry to reduce the amount of calculation and speed up the calculation. Perform FFT transformation on the collected 256-point signal sequence in the time domain, and the output sequence is obtained:
, (4)
When the amplifier input is a sinusoidal signal, the amplifier's nonlinear distortion manifests itself as harmonic components in the output signal, that is, harmonic distortion. "Total harmonic distortion THD" is usually used to quantitatively analyze the amplifier's nonlinear distortion degree. If the input AC voltage of the amplifier is , and the amplifier output AC voltage with harmonic distortion occurs, THD is defined as
(5)
In the system, there are three main sources of errors:
1) In the ADC acquisition front-end of the system, operational amplifiers are used for some signal amplification and transformation. There are characteristics such as the flatness of the amplifier's passband, noise and harmonic distortion that will cause errors.
2) In ADC sampling, it is required to satisfy the Nyquist sampling theorem, that is, the sampling frequency is greater than twice the highest frequency of the analog signal to reduce or eliminate the aliasing effect.
3) There are also errors when using the FFT algorithm in a microcontroller. Sampling and calculating the signal requires an infinite sequence to calculate an infinite spectrum. In practice, only part of the waveform sequence can be collected for calculation, which will cause spectrum leakage effects and errors; in discrete FFT transformation, due to the discreteness of the time domain, the frequency domain is also discrete, which will cause the fence effect. In discrete FFT transformation, Frequency points other than this point cannot be measured.
In response to the above errors, the solutions are as follows:
1) Construct an amplification circuit by using high-precision, low-noise operational amplifier chips; connecting capacitors across the power input end to filter out high-frequency clutter pulses brought by the power grid will reduce the interference of clutter electronic circuits.
2) Try to satisfy the sampling theorem and use high-resolution ADC appropriately.
3) Corresponding to frequency leakage, the corresponding window function can be added, such as the Blackman window function; corresponding to the fence effect, the frequency resolution can be appropriately improved and zero padding and other operations can be performed. At the same time, try to ensure that the required frequency component is an integer multiple of the frequency resolution.
Figure 3 VCA821 automatic gain control circuit diagram
The automatic gain control circuit consists of VCA821 and two operational amplifiers. The circuit schematic is shown in Figure 3. VCA821 is a voltage-controlled amplifier that dynamically adjusts the gain in the range of -10~20dB by controlling the input voltage at the V G terminal to meet the 26dB voltage range of the input signal 30~600mV required by the question. OPA695 provides a gain of 40dB, and the diode detects and feeds back the output signal. OPA820 forms an integrating circuit to compare the detected signal with the reference voltage. The output is fed back to the V G terminal, and the amplification factor of VCA821 is adjusted to make the output signal amplitude online. remain constant within the sexual range.
Figure 4 Sampling front-end conditioning circuit circuit diagram
The sampling conditioning circuit is shown in Figure 4. In order to meet the ADC sampling voltage range of 0~3.3V, the AC quantity needs to be superimposed with a DC quantity of 1.5V. It is composed of a front-stage isolation and a rear-stage non-inverting adder. Among them, the REF3330 reference voltage source generates an accurate 3V voltage, which is divided by R16 and R20 to obtain 1.5V. The function of R19 and R21 is to attenuate the signal to avoid saturation of the subsequent op amp and distortion.
6. PCB design analysis
This is the PCB for the circuit we designed to lift. It is similar to ordinary op amp design rules. The OPA227 operational amplifier is used, which can be purchased on Lichuang Mall. There is a reference voltage source, which uses TI's REF3330 and has a regulated voltage of 3V. It can also be purchased on Lichuang Mall. Our PCB design follows that the signal flow direction must be short, and all signal interfaces use SMA connectors, which are more reliable than Dupont wire connections.
The AGC circuit and design methods are all in TI's VCA821 chip manual, which can also be purchased at Lichuang Mall.
8.Assembly of works
Devices used:
Linear DC regulated voltage, switching power supply, any model can be used. Description: Linear regulated power supply stable output ±5V, ±12V, switching power supply stable output +5V
Serial screen, purchased from Tao Jingchi
AGC circuit, independently produced
Conditioning circuit, independently produced
MSP432P401R board, apply on TI official website
WIFI module , independently produced
Mobile phone host computer , independently produced
Connect the signal to the AGC circuit, and after passing through the conditioning circuit, sample the ADC interface. The serial port screen is connected with Dupont cable, and the wifi module is connected with the microcontroller.
The main program flow chart is shown in Figure 5. According to the requirements of the topic, the MSP432 microcontroller is used to process the signal sampled by the internal ADC, and the fundamental and harmonic normalized amplitudes, THD values and a periodic waveform are measured and displayed. The system is initialized first. Select whether to perform a measurement by pressing the button. After starting the measurement, set the initial sampling frequency to 256kHz and perform real-time sampling to measure the fundamental frequency period. When the fundamental frequency is less than 10kHz, the real-time sampling data is directly used to calculate the THD value; when the fundamental frequency is greater than 10kHz, the sequential equivalent sampling method is used to collect and calculate the THD value. The distortion, a periodic waveform and the normalized amplitude of the fundamental wave and harmonics are displayed on the local screen. In addition, the mobile phone is connected through the ESP8266 module and the data is sent to the mobile phone for display.
Figure 5 Main program flow chart
The source code of the software can be found in the appendix.
This system realizes all the functions required by the question, including basic functional requirements and partial functional requirements. It meets all the indicators of the question, and is better than the question requirements in terms of input signal peak-to-peak range and fundamental frequency range.
This system has obtained a reasonable design plan through theoretical calculations. It uses MSP432P401R as the core and uses sequential equivalent sampling and FFT algorithms to implement a signal distortion measurement device that can display the distortion of the input signal and a periodic waveform on the local screen. , and connect the mobile phone via WIFI to display the same result on the mobile phone. Through actual testing, the relative error index of distortion measurement does not exceed 3% when the fundamental frequency is between 1kHz and 100kHz; the relative error index when the fundamental frequency is between 100kHz and 1MHz does not exceed 5%.
All reference designs on this site are sourced from major semiconductor manufacturers or collected online for learning and research. The copyright belongs to the semiconductor manufacturer or the original author. If you believe that the reference design of this site infringes upon your relevant rights and interests, please send us a rights notice. As a neutral platform service provider, we will take measures to delete the relevant content in accordance with relevant laws after receiving the relevant notice from the rights holder. Please send relevant notifications to email: bbs_service@eeworld.com.cn.
It is your responsibility to test the circuit yourself and determine its suitability for you. EEWorld will not be liable for direct, indirect, special, incidental, consequential or punitive damages arising from any cause or anything connected to any reference design used.
Supported by EEWorld Datasheet