通通

2021 Question A-Signal distortion measurement device

 
Overview
### 2021 Electronic Competition National Competition Question A: Signal Distortion Measurement Device## **Contents** **1. Foreword** **2. Team Introduction** **3. Project Introduction** **4 .Title and functional indicators** **5. Theoretical analysis and calculation** **6. List of modules used in this question and description of the overall solution** **7. Circuit analysis of each schematic diagram** **8. Circuit pcb design ** **9. Programming** **10. Physical picture display** **11. Summary** **12. Demonstration video** - - - ### Foreword       The team has always been happy to participate in Lichuang's activities, because I and my teammates got to know a lot of interesting small circuits through Lichuang, and then reproduced some small circuit DIYs. Now we are using the open source topics recommended by Lichuang to train freshmen and second-year students. The tools we also use are Lichuang EDA (which is really user-friendly). Some of the circuit boards we usually prepare for electronic competitions are also developed here at Lichuang, which really helps us students a lot. Then for Lichuang’s call for entries for the national competition this time, I came to participate as soon as I received the news. I hope I can give something back and it will be a memory for the team.       At first, I almost gave up participating because I had to take the postgraduate entrance examination, but thinking that I would only have this opportunity to participate in the national competition in my life, I finally decided to participate without any regrets. Although there are many questions from classmates: "You are about to take the postgraduate entrance examination and you are going to participate in the competition. Are you not going to take the postgraduate entrance examination?", "You haven't done it for so long. If you go, you may not win a prize. You might as well take the postgraduate entrance examination honestly"... But recalling every bit of my time in the laboratory, countless late nights, and the joy of fighting side by side with my teammates, I chose to participate in the competition. No matter what the result was, it was an explanation for myself and my teammates.       This is my first time working on an open source project at LiChuang. I have little experience. If I have any shortcomings, I hope you can give me some advice and learn from each other. - - - ### Team Introduction      The three people in the team are all members of the E-Sports Laboratory of the School of Electronic Information Engineering, mainly in the direction of instrumentation. During the undergraduate period, apart from taking classes, most of the rest of the energy was invested in the laboratory. Now The three of them are all seniors, some are in graduate school and some are working. The main reason for participating in this e-sports competition is out of sentiment, leaving a legacy to the younger brothers and sisters, and also fulfilling my dream of winning the national e-sports award.
Award-winning experience in competitions related to the team's majors: 2021 "TI Cup" National College Student Electronic Design Competition National Second Prize 2020 "TI Cup" Hubei Province College Student Electronic Design Competition Provincial First Prize 12th Lanqiao Cup Embedded andEDA Design In addition to developing the national second prize
, the team also often summarizes and shares its experience in the use of Lichuang EDA, e-sports training and other professional related content in its own CSDN. The team's personal CSDN link: Teammate's: Pipi Zhi, who majored in engineering: [https: //blog.csdn.net/qq_45138815](https://blog.csdn.net/qq_45138815) Mine: Forgotten: [https://blog.csdn.net/h568630659?spm=1010.2135.3001.5343](https ://blog.csdn.net/h568630659?spm=1010.2135.3001.5343) Demo video of station B for this question: [https://www.bilibili.com/video/BV1Fi4y1d7Ro/](https://www.bilibili.com/ video/BV1Fi4y1d7Ro/) - - - ### Project Introduction      This system uses TI's MSP432 series MCU as the control core, and measures the total amplitude of arbitrary waves generated by the signal source through hardware conditioning circuits, MCU ADC sampling, digital signal processing and other means. Approximate harmonic distortion (THD). The input signal passes through the automatic gain control amplifier, and then adjusts the amplitude to the ADC sampling range through the DC bias adder, and then samples it into a digital signal. The THD of the signal is calculated through fast Fourier transform (FFT) analysis, and the frequency domain and time domain waveforms are obtained. , and the measured results are displayed on the local color touch screen and transmitted to the mobile APP in real time via WiFi. The test results show that the circuit design of this device is clear, the human-computer interaction interface is friendly, and the functional performance is complete. The measurement range of frequency, amplitude, and accuracy exceeds the requirements of the question. It can complete the measurement of various indicators within 1 second, and a new frequency indicator is added. With the innovative voice broadcast function, the maximum error in THD measurement does not exceed 1%, successfully completing all the requirements of the question and extending it. - - - ### Questions and functional indicators![image.png] ![image.png]    | | | | --- | --- | | Question requirements | Completion status | | (1) Input signal peak-to-peak value 30mV ~600mV | Completed, expanded to 170μV~6V | | (2) Input signal fundamental frequency range 1kHz~100kHz | Completed, expanded to 600Hz~100kHz | | (3) Input signal distortion range 5%~50% | Completed, expanded to 0%~100% | | (4) Distortion measurement and display takes no more than 10s | Completed, extended to no more than 1s | | (5) Measure the approximate total harmonic distortion value THD of the output signal | Completed, the maximum error does not exceed 1 % | | (6) Measure and display a periodic waveform of the input signal | Completed | | (7) Display the normalized amplitude of the fundamental wave and harmonics | Completed | | (8) Display the measurement results on the mobile phone | Completed | | (9 ) Others | (1) Frequency measurement display

(2) Voice prompt function

(3) Discrete spectrum visualization

(4) Friendly interaction and clear display

(5) Continuous and single measurement mode | ### Module list for this question | | | | | --- | --- | --- | | Module | Model | Remarks | | Main control module MCU | MSP432E401Y | | | Automatic gain control amplification module AGC | AGC module (AD603) | Taobao link: [https:/ /m.tb.cn/h.fiGzQkD?sm=9124c2](https://m.tb.cn/h.fiGzQkD?sm=9124c2) | | WiFi module | ESP8266 (punctual atom)| Taobao link: [https://m.tb.cn/h.f7zSYlr?sm=472fbb](https://m.tb.cn/h.f7zSYlr?sm=472fbb) | | Display (large color screen) | 7-inch 800*480 8P interface serial screen | Taobao link: [https://m.tb.cn/h.fRyreFA?sm=ad58ad](https://m.tb.cn/h.fRyreFA?sm= ad58ad) | ### Overall plan description:      An external arbitrary wave signal generator is used as the signal source. The input signal is connected to the automatic gain control amplifier for amplification to adapt to the wide input amplitude range, and then the bias is superimposed to adjust the output signal to the ADC sampling amplitude range. The microcontroller performs FFT operation on the sampling results to obtain the approximate total harmonic distortion and waveform information in the time domain and frequency domain. The measured results are displayed on the color touch screen and transmitted to the mobile phone APP in real time via WiFi. The overall system scheme block diagram as the picture shows. ![image.png] - - - ### Theoretical analysis and calculation** 1. Amplification circuit design **      In this system, since the range of the measurement and control signal is relatively wide, in order to ensure the necessary measurement accuracy, a preamplifier needs to be added to the input analog signal to make the output voltage suitable for the voltage range of the analog-to-digital converter. In view of the peak-to-peak range of the input signal of the question, which is 30mV~600mV, the amplifier designed in this system must not only ensure that the signal with the lowest input amplitude can be accurately collected by the AD, but also ensure that the signal with the highest input amplitude will not exceed the input amplitude of the microcontroller ADC after amplification. Limit 0~3.3V. At the same time, considering that the maximum fundamental frequency of the input signal is 100kHz, its fifth harmonic frequency is 500kHz, so an op amp with a bandwidth of not less than 5MHz should be selected. Here, the programmable amplifier AD603 is used for implementation. AD603 adopts a unique The advanced interpolation technology can ensure that the gain change is linear, the gain stability is strong, and it is less affected by external temperature and power supply fluctuations. The arbitrary wave generated by the signal source passes through the automatic gain amplification circuit. Its function is to automatically reduce the gain of the amplifier when the input signal is strong, and to automatically increase the gain when the signal is weak, thereby ensuring that the output is within the AGC range. The voltage is relatively uniform. This enables the post-processing circuit to have good processing characteristics for the input signal. **2. DC bias adder circuit design** The bias part uses a classic adder circuit, in which the proportional resistors are all 10kΩ. The specific bias size uses a fixed-value resistor and a potentiometer to divide the voltage. Considering that the MCU ADC requires the acquisition signal amplitude to be 0~3.3V, the amplified sine wave peak-to-peak value can be amplified to a maximum of 3Vpp, then: ![image.png ] Therefore, take the 1K potentiometer and the 3.3K fixed value resistor to divide the voltage. ** 3.FFT measurement design **                              Fast Fourier transform FFT can transform a time domain signal into the frequency domain, and can also extract the spectrum of a signal. First, a signal is collected in the time domain according to the sampling frequency F, N points are collected, and then N By performing FFT operation on each point, the spectrum characteristics of this signal can be obtained. After FFT, the result is a complex number of N points. Each point corresponds to a frequency point whose modulus value is the sum of the squares of the real part and the imaginary part. The modulus value of each frequency point (except the DC component of the first point) is the peak value of the original signal. N/2 times of A, the DC component of the first point is N times of A. The signal frequency corresponding to the nth point is: ![image.png] - - - ### Schematic circuit analysis** 1. Automatic gain control amplification circuit **      The AGC circuit is essentially a feedback control circuit that converts the average output voltage into an appropriate DC level through the detection circuit and feeds it back to the gain control end of the voltage-controlled gain amplifier. Its structure is as shown below. ![image.png] The voltage-controlled gain amplifier determines the maximum gain and gain conversion range of the AGC. The frequency characteristics of the circuit, noise indicators and other major indicators also depend on this amplifier. Since the feedback loop feeds back the quasi-DC signal, it has basically no impact on the frequency characteristics of the entire amplifier. The automatic gain control amplifier circuit in this system is a variable gain amplifier composed of two AD603s. The voltage gain of each AD603 can change from 0dB to +42dB. The cascade amplifier composed of two amplifiers increases the control range of the AGC. AD603 relies on the control voltage to control the amplification factor; the comparator AD8561 compares the second-stage AD603 output signal (non-inverting terminal of the comparator) and the setting voltage (inverting terminal of the comparator), and uses diodes and RC to detect the comparator output signal. ;The detection value range is 0~3.3V, and the circuit is set to a fixed voltage value of 1.4V. This ensures that the adjusted voltage is within the control voltage range of AD603, so that AD603 can amplify normally and has the ability to automatically adjust, as shown in the figure . ![image.png] ** 2. DC bias adding circuit **                                                                    In this system, due to the internal offset voltage of AD603 in the preamplifier circuit, the amplified signal has a large DC offset before entering the adder, so a high-pass filter with a cutoff frequency of 1.59Hz is added to block DC. Here we take a first-order passive high-pass filter with capacitance C=0.1μF and R=1MΩ. At the same time, in order to prevent the influence of the resistance of the voltage dividing circuit on the proportional resistance of the adder and the influence of the proportional resistance on the cutoff frequency of the high-pass filter, a first-level follower is added after the voltage dividing circuit and the high-pass filter for isolation and then input into the adder. , the actual circuit is shown in the figure. ![image.png] ### PCB circuit analysis** 1. Automatic gain control amplification circuit ** This uses the AGC automatic gain control amplification module prepared during the competition preparation, so I will not post the PCB diagram, but put it on Taobao Link: [https://m.tb.cn/h.fiGzQkD?sm=9124c2](https://m.tb.cn/h.fiGzQkD?sm=9124c2) AGC module AD603 automatic gain control manual and programmable adjustment The output amplitude bandwidth is 10M ! [image.png] ** 2. DC bias and Qualcomm DC blocking circuit ** Because it was made during the competition, it is very troublesome to make double panels in the laboratory, so I chose a single panel, and then put two There are two power supply interfaces, mainly because it is difficult to route through only one. Then the size is close to 5X5cm, not too big, not too small, the same size as other circuit modules, and it looks more beautiful. ![image.png] ** 3. Adding circuit ** ** This is also a basic adding circuit. Pay attention to the power supply decoupling, and the circuit board specification is also made to 5*5cm as much as possible, consistent with the size of the front and rear circuit modules. ** ** ![image.png] ** - - - ### Programming This device takes the MSP432E401Y microcontroller as the core and uses the serial port screen for human-computer interaction. After one-click startup, it amplifies the data through the 12-bit ADC on the microcontroller. The input signal is sampled multiple times, the data at the optimal sampling rate is selected for FFT operation, and the frequency domain waveform of the signal is obtained. Information such as the peak-peak value and phase of the fundamental wave and each harmonic is extracted in the frequency domain and IFFT operation is performed. Thus, the restored one-cycle time domain waveform is obtained, and the final test results are displayed on the serial screen and transmitted to the mobile APP in real time via WiFi, as shown in the figure. ![image.png] First, let’s introduce the host computer. Our host computer software is written in QT, because QT is cross-platform. The same set of code can be run on Windows, Linux, or Android phones. And there is no need to modify anything, the compiler will automatically generate it for you, and the interface design can be implemented very quickly, very friendly, which is very convenient. Since it can run on a mobile phone, wouldn’t it be a WiFi_APP if I change the serial port to WiFi? Just do it. There is already relevant information on QT developing Bluetooth on the Internet. In the same way, WiFi or Bluetooth are similar, so I integrated all the information and integrated a WiFi_APP. You don't need any knowledge of Java to make this app. You only need to know the basic C++ foundation of QT. As long as you have a WIFI module (ESP8266) and an Android phone on hand, you can implement the functions of WIFI_APP. **Software and Hardware Platform** **Hardware Platform:** ESP8266, (available on Taobao), its interface is the same as the serial port, using four pins: TX, RX, GND, and VCC. Connect it to the lower computer or use CH340, TTL to USB module to connect to the PC. The working mode of WIFI can be adjusted through AT commands. There are AP mode, STA mode, AP+STA mixed mode... To put it simply: AP: You can use ESP8266 as a hotspot, allowing other devices to connect to it; STA: You can connect to the ESP8266 in the current environment WIFI hotspot. The most important thing is to enable transparent transmission mode. Transparent transmission means that you don’t need to care about how the WiFi protocol is implemented. All that needs to be done is that A sends data through the serial port and B receives data through the serial port. During the whole process, the A serial port and the B serial port are directly connected with wires. From the perspective of developers, it is completely transparent. We use STA mode (need to connect to a hotspot), and then turn on transparent transmission. ATK-ESP8266 (Punctual Atom) module, the wiring method is as follows: ![image.png] Only 4 of these six pins are needed: RXD, TXD, GND, VCC, respectively, and the TXD, RXD, GND, VCC of the microcontroller Just connect them. ![EW9.jpg] **Android phone:** I am using an Android phone here, an OPPO phone, Android version 10 **Software platform:** The Qt version of this project is 5.12.4, and the system is Windows 10 x64 Note: You need to build Qt for Android environment video link: [Qt installation and Android environment construction](https://www.bilibili.com/video/BV1F4411F72b?p=1&share_medium=iphone&share_plat=ios&share_session_id=DCB8C0E3-3D5F-41DB-8807 -A9600D838E55&share_source=COPY&share_tag=s_i×tamp=1639031677&unique_k=L94cK9Q) **Basic introduction of the software: ** Because it is the first time to do a WiFi host computer, I made a very simple prototype to implement WIFI status detection, local IP scanning and server linking , display of fundamental harmonics, display of time domain and frequency domain waveforms, and can complete data sending and receiving like a serial port assistant. As shown in the picture, this is the simplest software interface I made at the beginning. This software is based on widget control. Of course, you can choose other ones, and you can also define your own classes. We are based on TCP communication, QT's network protocol, and use two classes, QTcpServer and QTcpSocket. TCP is divided into server and client, which is similar to a network debugging assistant. We use the mobile phone as the server and the wifi module (esp8266) as the client. As long as they are connected to the same network, they can communicate with each other and transmit data. Of course, we also need to formulate a simple data transmission protocol: because of the protocol, you know what type of data is sent, how many are sent at a time, and where to display them. Below is part of the code, and the source code is at the end. You can download it and check it out slowly.      
          
           
                                                         Similarly, we also provide you with a video link to learn QT for your convenience: [[Beijing Xunwei] Embedded Learning QT Learning Chapter - Bilibili] [https://b23.tv/gP8rDCd](https:/ /b23.tv/gP8rDCd) ![42LMG`UQB28_PU663E3XOKO.jpg] ``` #include "qglobal.h" #include "cmd_queue.h" #include "process_fun.h" #include "widget.h" uint8_t cmd_buffer[A_CMD_MAX_SIZE ]; void A_ProcessMessage(A_PCTRL_MSG msg, uint16_t size,Ui::Widget *dis) { uint8_t cmd_type = msg->cmd_type; //Command type uint16_t screen_id = A_PTR2U16(&msg->screen_id); //Screen ID uint16_t control_id = A_PTR2U16 (&msg->control_id); //Control ID uint32_t value = A_PTR2U32(msg->param); //Value uint16_t len ​​= A_PTR2U16(msg->param); switch(cmd_type) { case A_kCtrlButton: //Button control A_NotifyButton( screen_id,control_id); break; case A_kCtrlText: //Text control A_NotifyText(screen_id,control_id,msg->param,dis); break; case A_kCtrlGraph: A_NotifyGraph(screen_id,control_id,len,&msg->param[2]); //Drawing control default: break; } } void A_NotifyText(uint16_t screen_id, uint16_t control_id, uint8_t *str,Ui::Widget *dis) { if(screen_id == 0) { if(control_id == 3) { Widget:: updatedata3(str,1,dis); } ``` - - - ### Physical picture display

** Physical picture of the work: **

![image.png]
** Human-computer interaction interface: **

![image.png ]
**Mobile APP:**
![image.png] ### Summary:      Regarding this question, our team still has a little regret, because we did not have enough understanding of TI's MCU before. Faced with this question, we now learn from TI's boards. Development, including model selection, also suffered a loss. At that time, I had three types of MCUs: 430, 432, and C2000. I simply read the introduction on the official website and chose the MSP432. Although it could complete all the indicators specified in the question, it was relatively There is still a big gap compared to other groups that chose C2000. I heard that other schools can measure 1M frequency with C2000, but the ADC sampling rate of MSP432E401Y can only reach 1M. For the fundamental wave of 100kHz, the fifth harmonic has reached 500kHz. , it is very reluctant to use 1M rate to collect. Moreover, there is no DA inside MSP432E401Y, so it cannot perform continuous program control. Either control relays, analog switches, etc. are used to achieve discrete amplification control; or it can only be connected to an external DA module.
Finally, I would also like to thank the laboratory teachers and seniors who usually provide us with training and answer questions. I would like to thank the brothers and juniors who compete in the e-sports competition together. I would also like to thank my teammates who took the time during the intense review period for the postgraduate entrance examination. The last electronic competition during my undergraduate period is over, but the electronic competition is not the end. I would like to share this with you. ### Demo video
参考设计图片
×
 
 
Search Datasheet?

Supported by EEWorld Datasheet

Forum More
Update:2025-05-15 20:20:44

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
community

Robot
development
community

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号