兰博

2021-Question A-Signal distortion measurement device

 
Overview
## **Table of contents** **1. Foreword** **2. Team introduction** **3. Project analysis** **4. Theoretical analysis and calculation** **5. Analysis of each schematic circuit* * **6. Circuit pcb design analysis** **7. Physical display** **8. Work assembly** **9. Program design** **10. Summary** **11. Attachment** # # **1. Foreword**         2021 is an extremely bumpy year. I participated in the e-sports competition this year. I started preparing in July, then experienced postponement, and then started the competition in early November. I experienced many ups and downs, but it was relatively smooth. The results were quite good, and I won the second prize in the country. Our topic is Question A - Distortion Measurement Device, using MSPEXP432E401Y as the main control chip. The analog-to-digital conversion (ADC: Analog to digital converter) channel inside the chip collects data from the periodic signals generated by the function/arbitrary waveform generator, using The Fast Fourier Transform (FFT) algorithm performs frequency domain data processing on the sampled data to obtain the THD value of the measured signal. The actual measurement results show that the system operates stably and can measure the peak-to-peak range of 30mV-600mV and the fundamental frequency of 1kHz-100k The fifth harmonic can realize the normalized amplitude measurement of the fundamental wave and harmonics of the output signal and the THD measurement, which has good application prospects and practical value. ## **2. Team introduction**        Our team members include Yu Zhou Fei, Guo Zhongwang, and Liu Yanyang. We are a team from the School of Electronic Engineering of Tianjin Vocational and Technical Normal University. Among them, Yu Zhoufei’s main research direction is embedded software and FPGA, Guo Zhongwang’s main research direction is hardware circuits, and Liu Yanyang’s main research direction is cameras and image recognition. ## **3. Project Analysis** ###### 3.1 Project requirements 1. Basic requirements (1) The peak-to-peak voltage range of the input signal: 300mV~600mV. (2) Input signal base: 1kHz. (3) Input signal distortion range: 5% ~ 50%. (4) It is required that the absolute value of the input signal distortion measurement error THDx - THDo ≤ ±5%, THDx and THDo are the measured value and nominal value of the distortion respectively. (5) Display the distortion measurement value THDx. (6) The distortion measurement and display takes no more than 10 seconds. 2. Play part (1) The peak-to-peak voltage range of the input signal: 30mV ~ 600mV. (2) Input signal base range: 1kHz ~100kHz. (3) Measure and display the input signal distortion THDx value, requiring THDx-THD≤±3%. (4) Measure and display a periodic waveform of the input signal. (5) Display the normalized amplitude of the fundamental wave and harmonics of the input signal, and only display the 5th harmonic. (6) Display the THDx value of the input signal measured and displayed by the measuring device, a periodic waveform, the normalized amplitude of the fundamental wave and harmonics on the mobile phone. (7) Others.        According to the requirements of the question, let's analyze how to complete the various indicators of this question. The peak-to-peak voltage range of the input signal is: 30mV-600mV, and the fundamental frequency range: 1kHz-100kHz. And the system ADC needs to collect the fifth harmonic of the signal, which requires the front-end signal to have variable gain and a large bandwidth. Here, an analog switch is used to change the size of the feedback resistor in the non-phase proportional amplification circuit to change the voltage amplification factor, so that the output amplitude of the front-end input signal can be changed. The advantage is that it is affordable and can be welded manually, making it easy to implement quickly. The disadvantage is that the MCU needs to judge the output level before changing the size of the feedback resistor.        In terms of thd value calculation, when the input of a linear amplifier is a sinusoidal signal, its nonlinear distortion appears as harmonic components in the output signal. Total harmonic distortion is commonly used to measure the degree of nonlinear distortion of a linear amplifier. The calculation formula is as follows: ![Formula 1-1.png]        Through the above formula, it is not difficult to analyze that the total harmonic distortion (THD) can be calculated as long as the fundamental wave (U o1 ) and the effective value of each harmonic component are obtained. There are Two ways to obtain the required value are FFT fast Fourier transform and FIR digital filter. In this design, we use FFT fast Fourier transform. This algorithm greatly reduces the number of multiplications required to calculate the discrete Fourier transform. In particular, the more the number of sample points N is transformed, the more calculations the FFT algorithm requires. The more obvious it is. In terms of the processor, the ADC acquisition and processor serve as the control core of the entire system. They are responsible for detecting the operating parameters of the system and making control instructions based on presets and judgments to make the system run in the best state. The MSPEXP432E401Y microcontroller is used as the main control chip + its own 12-bit sequential comparison ADC to complete the underlying core solution calculations such as acquisition and signal processing. This microcontroller uses ARM's 32-bit high-performance "Cortex-M4" core, with the highest operating frequency. 120MHz, 1024KB flash memory with 4 memory banks integrated on the chip. It has the advantages of rich peripheral interfaces and ultra-low power consumption. ## **4. Theoretical analysis and calculation** ###### 4.1 THD theoretical calculation        Calculating the THD value of a waveform is divided into three steps, namely waveform data sampling, FFT fast Fourier transform, and THD value calculation. Among them, waveform data sampling converts continuous time domain waveforms into discrete time domain waveforms. Then the discrete time domain waveform is converted into the frequency domain amplitude-frequency waveform through FFT fast Fourier transform. Finally, the THD value is calculated by counting the amplitudes of the fundamental frequency component and the fourth harmonic component. (1) Waveform data sampling According to the Nyquist sampling theorem, it can be seen that the minimum value of the sampling frequency Fs must be twice the maximum frequency. In practical applications, Fs generally takes 2.56 to 4 times the highest frequency. In this design, it is required to collect the fourth harmonic component and the first fundamental frequency component. The value of the fundamental frequency component is 1KHz. It can be seen that the highest frequency is 5KHz and the minimum sampling frequency is 10KHz. In this design, in order to improve the accuracy of the 4th harmonic component and the fundamental frequency component, and taking into account the bit width of the microcontroller, the sampling frequency was selected to be 20.48KHz. (2) FFT Fast Fourier Transform According to the FFT (Fast Fourier Transform) formula (2-1), it can be seen that when N=2048, the corresponding X(k) also has 2048 data. The difference in frequency between two points in the frequency domain is df=Fs/N. In this design, Fs=20.48KHz, N=2048, so df=10Hz. According to the properties of FFT, it can be seen that a finite digital signal is converted from the time domain to the frequency domain. The transformation is symmetrical by default, so the data obtained after FFT (Fast Fourier Transform) is actually only half, and there are only 1024 effective X(k). Collect the 9th harmonic component and fundamental frequency component to meet the requirements of the question to collect the 4th harmonic component and fundamental frequency component. ![Formula 2-1.png] (3) THD value calculation THD definition: If the linear amplifier input voltage, its output AC voltage containing nonlinear distortion is: Then the calculation formula of THD value is as shown in (2-2)! [Formula 2-2.png]        Based on the data after FFT (Fast Fourier Transform), find the maximum amplitude value of the fundamental frequency component and the 4th harmonic component. According to the df calculated by FFT (Fast Fourier Transform), it can be seen that the peak value of the fundamental frequency component appears near the 100th data, and the peak value of the 4th harmonic component appears near the 200th, 300th, 400th, and 500th data respectively. Find the maximum value of +-10 data near these values. Put the maximum value of the collected amplitude into formula (2-3) to calculate the value of THD. ![Formula 2-3.png] ###### 4.2 Signal conditioning circuit theoretical calculation        The front-end signal processing circuit is selected as a non-phase proportional amplification circuit, as shown in Figure 2-1. The voltage transfer function of this circuit is shown in formula (2-4). From the formula, it is not difficult to see that the output voltage Vo can be changed by changing the size of the feedback resistor R1. ![Formula 2-4.png]        It can be seen from formula (2-5) that automatic AGC control can be achieved by using an analog switch to select the size of the feedback resistor. The required magnification is shown in Table 2-1. ![Formula 2-5.png] ![Figure 2-1.png] Figure 2-1 Non-phase proportional amplification circuit Table 2-1 Voltage amplification factor | | | | | --- | --- | --- | | Input voltage range (mV) | Output voltage range (V) | Magnification | | 30-40 | 1.68-2.24 | 56 | | 40-80 | 1.12-2.24 | 28 | | 160-320 | 1.28-2.56 | 8 | | 320-600 | 0.90-1.80 | 3        | The Fast Fourier Transform is then calculated, so the ADC error is the main source of image THD error. Whether the collected data can restore the initial waveform well will directly affect the calculation results of the MCU.        ADCs are used in a wide variety of applications. Ideally, every volt applied to the input of the signal chain is digitally represented by the ADC as a volt at the output. But that is not the case. System accuracy cannot be higher than the least significant bit (LSB) size of the converter. Analog-to-digital converter linearity is only relative to the converter itself, which depends on architectural and process variations. ADC Error Analysis Other error sources that affect converter performance include: CMRR, clock jitter, inherent board noise, coupling, etc. All of these errors ultimately determine how effectively the ADC represents the signal; typically the ADC represents itself more efficiently in the frequency domain. (2) Voltage amplification error (op amp bandwidth) analysis found through the actual measurement circuit that the measured peak-to-peak value of the output voltage is different from the calculated amplification factor at different frequencies and different output voltage ranges. By consulting the op amp The chip manual of TLV2372 shows that the gain bandwidth product (GBW) is 3MHz, which is far from meeting the system design requirements. The solution is to choose a chip with a higher gain bandwidth product or reduce the amplification factor of the circuit or reduce the amplification factor to increase the bandwidth performance of the signal conditioning circuit. Simply speaking, the bandwidth of an op amp is used to measure the frequency range of the signal that an amplifier can process. The higher the bandwidth, the higher the frequency of the signal that can be processed, and the better the high-frequency characteristics. Otherwise, the signal will be easily distorted, but this is for For small signals, the slew rate SR (or slew rate) is generally used to measure large signals. ## 5. Circuit analysis of each schematic diagram ## 1. Circuit design (1) Programmable gain control circuit        This circuit is the pre-processing circuit for the signal entering the microcontroller. After the signal enters, it first enters the first-level variable gain operational amplifier. After that, a level-raising circuit is used to raise the input level to above 0V. In the gain control part of the operational amplifier, the microcontroller controls the analog switch and selects the corresponding resistor to achieve the gain control of the operational amplifier. ![Figure 3-1.png] ## **6. Circuit pcb design analysis**        In terms of the single-chip microcomputer system, use the existing single-chip microcomputer core board, and lead the single-chip microcomputer pins through pin headers and hole boards to lead out the wires. Then route the wires at the bottom of the perforated board to connect the modules. The link between the microcontroller and peripherals includes 2 sets of serial ports, namely serial port 1 and serial port 2, of which serial port 1 is connected to the serial port screen and serial port 2 is connected to Bluetooth. Then PE3 is connected to the front-end ADC signal processing link through the SMA port. It is then linked to the 3 control ports of the analog switch through 3 pins. This part of the link is relatively simple and does not draw the relevant PCB. ![Physical circuit diagram-pcb.jpg]        In terms of signal links, all input and output lines use SMA interfaces to prevent external high-frequency interference. At the same time, the top and bottom floors are all paved to strengthen the signal loop and prevent signal interference. At the power supply of the chip, add a decoupling capacitor to remove high-frequency interference from the power supply. The top and bottom PCB diagrams of the circuit are shown below. ![PCB_TOP.png] ![PCB_LOW.png] ## **7. Physical display** The complete display of the physical picture is as shown below. ![Physical display.jpg] ## **8. Work assembly**        This work has no mechanical structure, so this part is omitted ## **9. Programming**        In terms of program design, bare metal programming is used to improve real-time. At the same time, the state machine method is used in data processing, step by step. At the beginning of the program, the first thing to do is to initialize the peripherals, configure the corresponding DMAADCTIM and other peripherals, and read the adc data once. After the reading is completed, the read data will be analyzed and the current voltage, and automatically adjusts the gain of the amplifier based on the identified voltage. After the gain adjustment is completed, the fundamental frequency is calculated by performing fft calculation on the data collected by the ADC. After the base frequency is obtained, the input signal is collected once by setting a sampling rate of 20 times. After the collection is completed, the collected data is subjected to fft operation and the THD value is calculated. Then the THD data, waveform data, and spectrum data are , normalized amplitude and other data are stored in the video memory. Finally, the data is displayed on the display screen and the mobile phone by calling the display program. The overall program flow chart is shown in Figure 3-4. ![Figure 3-4.png] 2. Main program display ``` int main(void) { int i; /* Configure the system clock for 120 MHz */ systemClock = MAP_SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ | SYSCTL_OSC_MAIN | SYSCTL_USE_PLL | SYSCTL_CFG_VCO_480), 128000000); SysCtlPer ipheralEnable(SYSCTL_PERIPH_GPION); while(!SysCtlPeripheralReady(SYSCTL_PERIPH_GPION)); GPIOPinTypeGPIOOutput(GPIO_PORTN_BASE, GPIO_PIN_1); GPIOPinWrite(GPIO_PORTN_BASE,GPIO_PIN_1,GPIO_PIN_1); ConfigureUART2_Bluetooth(systemClock); ConfigureUART0_LCD(systemClock); /* Enable the clock to GPIO Port N and wait for it to be ready */ /* Configure PN0 as Output for controlling the LED */ fre_singal_init(); HAL_ADC_INIT(fre_in_tim); vol_auto_init(); while(1) { //Calculate amplitude vol_auto(); //Calculate frequency fre_pinlutiaojie(); THD_calculation_1K(); view_ADC_Spectrum(); view_wave(); view_Bluetooth(); view_ADC_THD(); if((fft_base_fre < 20000)||(fft_base_fre == 20000)); else SysCtlReset(); } } ``` ## * *10. Summary**          This electronic competition is a dual competition of mental and physical strength. During the competition, from receiving the question to building the structure, to debugging the program, and finally completing the competition. Many difficulties were encountered during the process, such as unreasonable structure and difficulty in adjusting circuit parameters. In addition, there was also lack of physical strength. I only slept four or five hours in the last few days. This was undoubtedly a huge challenge for us. We are honored that we completed it, successfully fulfilled the question requirements, and completed the competition. ## **11. Attachment** See the article download area
参考设计图片
×
 
 
Search Datasheet?

Supported by EEWorld Datasheet

Forum More
Update:2024-11-22 12:37:33

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号