This system will use a single-chip microcomputer integrated with the μC/OS-Ⅱ operating system, and use the fast Fourier transform and window function method to analyze the various parameters of the audio signal.
1 System Overall Plan
The signal first passes through an 8th-order active Butterworth filter for anti-aliasing processing, and then passes through amplification, attenuation, and level shifting buffer networks before being sent to the microcontroller for processing.
The system has two MSP430F1611 microcontrollers, one is responsible for sampling the analog signal and performing 4096-point FFT calculation on the collected signal, and the other is responsible for controlling the display device and completing the analysis of the signal power spectrum, periodicity, and distortion.
The overall block diagram of the system is shown in Figure 1.
2 System Hardware Design
2.1 Design of anti-aliasing filter
According to the Nyquist theorem, when the AD converter samples the input signal at a frequency of fs, the signal with a frequency of f>fs/2 will be mirrored to 2fs-f about the frequency of fs/2. If the aliasing phenomenon caused by the out-of-band spurious signal is not properly filtered, these frequency components will affect the performance indicators of the in-band data acquisition. This system selects a shift sampling frequency of about 40 kHz, while the input signal is up to 10 kHz, and the oversampling rate is low, so it puts forward relatively high requirements on the filter. Considering the flat in-band amplitude-frequency characteristics of the Butterworth filter, the continuous-time active filter MAX274 is used to design an 8th-order Butterworth filter (as shown in Figure 2), so that the signal outside 20 kHz is effectively attenuated. After testing, the effect is relatively good.
2.2 Design of front-end amplifier
Since the amplitude of the input audio signal may be large, we assume that the signal given by the outside world can reach 10 V peak-to-peak, and the AD acquisition signal range of the MSP430F1611 microcontroller is 0-2.51 V, so the signal needs to be compressed. After comprehensive consideration, this system is divided into 4 gears, and each gear is guaranteed to have overlapping parts. Below 100 mV, it is amplified by 27.6 dB (24 times) through the low offset op amp op07, and is directly passed in the range of 90 mV to 2.5V, and attenuated by 6.02 dB (2 times) through the resistor voltage divider in the range of 2 to 5 V. Similarly, it is attenuated by 12.04 dB (4 times) in the range of 4 to 10 V, and then the gear is manually selected through the input device to control the on and off of each relay, select the most suitable gear, and then the signal is buffered and input into the microcontroller for sampling and FFT calculation after passing through the level shifting circuit. This module pays attention to the isolation of the front and rear stages when cascading, and adds a buffer stage to reduce the error of the measured signal amplitude, as shown in Figure 3.
2.3 Determination of audio signal periodicity and period measurement
By setting the power threshold value, this system can effectively determine whether the input signal is periodic and calculate the period value of the periodic signal. For a general periodic signal f(t), expand f(t) into a Fourier series to obtain:
Taking Fourier transform on both sides of equation (1) we get:
It can be seen that the general periodic signal is a discrete spectrum composed of a series of impulse functions, and the impulse occurs at the harmonic frequency of the signal (0, ±w1, ±2w2...), while the spectrum of the non-periodic signal is continuous, so the signal spectrum distribution is relatively dispersed, and there can be no large steps in the spectrum. In this way, a power threshold value can be set. If there is a spectrum greater than this threshold value, it is a periodic signal, otherwise it is not. When the signal is judged to be a periodic signal, the signal is sent to the comparator, and the generated pulse signal is sent to the microcontroller for counting to determine its period. After many experiments, a better threshold value is selected, so that a large part of the signal (such as triangle wave, sawtooth wave, sine wave) can be judged whether it is periodic, so as to accurately calculate the period of the signal. [page]
2.4 Measurement of Audio Signal Distortion
For a sinusoidal signal, the power value of the fundamental spectrum is always the largest. This method can be used to determine the spectrum of the fundamental wave and thus obtain the power of the fundamental wave. The distortion of a sinusoidal signal is defined as the square root of the ratio of the energy of all harmonic components in the signal to the energy of the fundamental wave. If the fundamental power of the sinusoidal signal is P1 and the total power of the signal is P, then the distortion of the sinusoidal signal is
The distortion of the sinusoidal signal can be calculated by analyzing the power of each spectrum.
3 System Software Design
3.1 Embedded System Design
This design embeds the μC/OS-Ⅱ operating system in the MSP430F1611 microcontroller, which can easily realize the scheduling and coordination of multiple tasks, greatly saving software development time and reducing the probability of errors. The software flow chart of the system is as follows: Figure 4 is the software flow chart of FFT, Figure 5 is the flow chart of the slave MSP430F1611 responsible for signal acquisition and FFT calculation, and Figure 6 is the flow chart of the host MSP430F1611 responsible for peripheral signal analysis.
3.2 Specific design of FFT algorithm
3.2.1 Analysis of FFT Points and Sampling Frequency
This system uses the base 2 Fourier transform for calculation. Considering that the RAM storage space of the 16-bit MSP430F1611 microcontroller is 10 k, the amplitude of the spectrum after FFT calculation is symmetrical about the center. In order to save hardware resources, the 2048 points after FFT calculation are discarded, so half of the resources can be saved. Since 2 048x16 bitx2=8.192 k, the maximum N=4 096 points are taken for FFT. This system sets the frequency resolution to 20 Hz. If the sampling frequency fs=40kHz, then the frequency resolution of this FFT is △f=fs/N=10 Hz. But in actual situations, since FFT can only analyze a limited number of points, the continuous time signal must be truncated, which is equivalent to adding a window to the time domain signal, so that the signal spectrum spreads to both sides to produce a spectrum leakage effect; coupled with the limited frequency resolution of FFT, the signal spectrum cannot completely coincide with the spectrum line of FFT, thus producing a fence effect. These two effects make the analyzed spectrum lines diffuse and distribute; for two signals that are only 20 Hz apart, the frequency resolution of FFT can be improved by reducing the sampling frequency or increasing the number of FFT points, or by adding windows to analyze the spectrum more accurately. This system divides the frequency of the collected signal into two segments. When the signal frequency is high, the sampling frequency of fs=40 kHz can be used for sampling. When the frequency of the collected signal is low, the sampling frequency is changed to fs=20kHz through the input device, so that the sampling frequency of FFT can even be increased to △f=fs/N=5 Hz. This method can improve the frequency resolution of the overall system, and the number of points for analyzing FFT is limited by hardware resources. Finally, the analysis accuracy can also be improved by adding windows.
3.2.2 Selection of window function
Different window functions will have different effects on signals. Window functions with relatively small sidelobe amplitudes are beneficial to reducing spectrum leakage and more accurately measuring the signal spectrum amplitude. However, the main lobe width of this window function is relatively large, which will cause the analyzed spectrum lines to spread more to both sides, resulting in a decrease in the accuracy of measuring single-frequency and multi-frequency signal frequencies, such as the Blackman window and the Flattop window. Window functions with weaker sidelobe amplitude attenuation have narrower main lobe widths, which is beneficial for measuring frequency accuracy, such as rectangular windows. There are also window functions that take both into account, such as banning windows and bumming windows. Therefore, the measurement accuracy of frequency and amplitude is contradictory. This system uses matlab simulation to preliminarily estimate the window function that should be selected. The signal analyzed is a single-frequency function.
The MATLAB simulation results after adding various window functions to this signal are as follows: Figure 7 is the frequency spectrum after adding the Blackman window, and Figure 8 is the frequency spectrum after adding the Hanning window.
According to the above figure, it can be seen that the spectrum of 1 000 Hz and 1 005 Hz is divided into several spectral lines with relatively high amplitudes. This is caused by the leakage effect and the fence effect. When the banning window is added, the signal frequency is just an integer multiple of the FFT frequency resolution fs/N=10 Hz, and the signal spectrum line is divided into 7 spectral lines with relatively high amplitudes. When the blackman window is added, the spectrum line is divided into nearly 20 spectral lines with relatively high amplitudes. However, in actual situations, when the hanning window is added, the central spectrum line is divided into 3 or 4 spectral lines with relatively large amplitudes, which is better than the simulation result. However, the spectrum line with the blaekman window is distributed wider than the simulation result, but the calculated amplitude value will be slightly higher than the accuracy of the banning window. In order to improve the frequency resolution of the audio analyzer, adjacent spectrum lines should be kept from overlapping each other as much as possible, so that the power of each frequency signal can be calculated and the frequency resolution can be improved. After comprehensive consideration, this system chooses to add a hanning window.
[page]
4 Test methods and test results
4.1 Test environment and test equipment
The audio signal analyzer was tested at room temperature of 30℃. The test instruments were as follows: 2 Nanjing Shengpu 40M function generators, 1 Tektronix 60M digital oscilloscope, transistor millivoltmeter DA-16, and distortion tester ZC4128.
4.2 Measurement of signal power spectrum
Two function generators were used to generate two signals for superposition and testing. The input voltages of A and B were VppA = 2.000 V (0.04 W), the frequency was 1 kHz, and VppB = 3.000 V (0.09 W), the frequency was 1 kHz. Table 1 shows the test results, and it can be seen that the measurement error of the single signal power spectrum is within 0.2%, and the total power measurement error is also around 0.2%.
4.3 Measurement of signal frequency resolution and periodicity
The function generator is used to input general periodic signals, 50 Hz sine waves, 1 000 Hz square waves, triangle waves, sawtooth periodic waves and non-periodic noise signals. Table 2 shows the test results. It can be seen that the periodicity judgment of general signals is very accurate, and the frequency test error is within 1%.
4.4 Measurement of signal distortion
Use a function generator to generate triangle waves of 1 000 Hz, 100 Hz, and 20 Hz and square waves of 1 000 Hz, 100 Hz, and 20 Hz, and divide each signal into two paths, one for the distortion tester and the other for the audio signal analyzer. The test accuracy is determined by comparing the results. Table 3 shows the test results. It can be seen that due to the high harmonic components around 1 k, the anti-aliasing filter filters out the energy of the high-order harmonics, which will cause a large deviation in the distortion. When the frequency of the signal is reduced, the distortion will be measured more accurately.
5 Conclusion
This system uses the Fast Fourier Transform (FFT) algorithm, integrated peripheral sampling circuits, two MSP430F1611 microcontrollers to process the signal, and uses matlab tools for pre-estimation and judgment, effectively reducing the blindness of software design. And by adding a buffer circuit, the mutual influence of the front and rear circuits is reduced, so that the accuracy of the audio signal analyzer is effectively improved.
Previous article:PID parameter definition based on MSP430 microcontroller
Next article:Anti-interference performance of single chip microcomputer
- Popular Resources
- Popular amplifiers
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- Is the life of a hardware engineer really boring? Let's talk about it
- Is it a way out for hardware engineers to switch to embedded software?
- Let's talk about the specific applications of alumina ceramic substrates
- Relationship between CD4051's switching voltage and power supply voltage VCC
- DIY power supply: if you don't change the color of the digital tube, the operation will be uncomfortable
- Question about zero crossing comparator
- stm32 CANOpen
- [Ultra-low power STM32U5 IoT exploration kit]
- The advantages of GaN in the RF field
- 【AT-START-F425 Review】+ A/D Data Acquisition and Display