At present, most audio signal processors are not only large in size but also expensive, and are difficult to be popularized in some special aspects. Embedded system analyzers are small and reliable, so the development of audio analysis instruments based on special function microcontrollers is the basis of speech recognition and has great practical significance. The principle of signal analysis is to convert the signal from the time domain to the frequency domain, so that the unclear characteristics of the original signal become obvious, which is convenient for analysis and processing. For audio signals, their main characteristic parameters are amplitude spectrum and power spectrum. The working process of the audio signal analyzer is: limiting amplification of audio signals, analog-to-digital conversion, fast Fourier transform (FFT, conversion from time domain to frequency domain), eigenvalue extraction; from the amplitude spectrum of the audio signal, the power spectrum of the audio signal is obtained.
1 Hardware Design
"Smart Home" is also called smart house. The home network intelligent control system uses advanced computer technology, communication technology and embedded technology to connect various devices in the home into a system through the home network. The composition of the entire smart home system is shown in Figure 1. In this system, the monitoring and control of certain household electrical appliances requires the analysis of audio signals.
This design uses Microchip's DSPIC30F6014A microcontroller as the core processor. This chip is a combination of MCU technology and DSP technology. It not only includes the control function of 16-bit MCU, but also integrates the high-speed computing technology of DSP. It is actually a digital microprocessor that can easily realize various functions of audio signal analysis. The block diagram of the audio system is shown in Figure 2, including several parts such as power module, prefabricated circuit, A/D conversion module, DSP module, LCD display module, etc. The specific design and implementation functions of each module and interface are as follows:
(1) Power supply module: It adopts a DC three-terminal regulated power supply design. After voltage reduction, rectification, filtering and voltage stabilization, 220 V AC power is converted into the ±5 V and ±12 V power supply voltages required by the system.
(2) Prefabricated circuit: To ensure that the input bandwidth is within the audio range, the front-end DC bias circuit uses an OP07 amplifier. The first-stage adder adds the input signal to a 2.5 V voltage value, and the second-stage inverter transfers the signal to a 0-5 V range that can be processed by the A/D converter. Because the 50 Ω resistor at the input end is grounded, the system input impedance is approximately 50 Ω.
(3) A/D conversion module: Because there is only one audio signal input, only AN6 is used among the 16 analog input pins of the 12-bit configurable A/D module. During initialization, this pin is configured as an analog input pin. At the same time, because the processed audio signal voltage is 0 to 5 V, the reference voltage of the A/D module is set to 0 V and 5 V. The conversion output rate is as high as 200 KSPS.
(4) DSP module: This digital microprocessor is a modified Harvard structure design that can perform real-time analysis with high resolution. The DSP module is called through Microchip's MPLAB C30 C compiler, which provides 49 DSP processing functions to complete all digital signal processing.
(5) LCD display module: used to intuitively display spectrum waveform.
(6) ICD2 debug interface: Microchip's ICD2 in-circuit debugger is selected, and an ICD2 debug interface is reserved for this purpose.
(7) RC oscillator: This microcontroller can operate in four modes: external clock input, external RC input, internal fast RC oscillator, internal low power (RC) oscillator, and post divider used in low power consumption. This design uses the internal fast RC oscillator, which can provide a 7.37 MHz clock. Since the audio signal needs to be processed in real time, the post divider is not used.
2 Software Design
The main loop of the audio system is shown in Figure 3.
(1) After sampling and A/D conversion are completed, the A/D enable flag is cleared to obtain a discrete digital signal.
(2) Call the period determination function to analyze the periodicity of the signal.
(3) Call the FFT transformation function to perform fast Fourier transform on the discrete signal to achieve the transformation from time domain to frequency domain.
(4) Display the frequency spectrum of the input signal.
(5) Calculate the power spectrum of the signal and calculate the maximum power.
(6) Display the power spectrum and maximum power of the signal.
2.1 A/D Sampling
Theoretical analysis: Due to the 12-bit A/D module, the quantization unit is 1/212. Since the frequency resolution △f = 100 Hz and the number of FFT sub-sample points N = 512, the sampling frequency fs = 51 200 Hz (fs ≤ N△f) and the sampling period Ts = 1/51 200 s (sampling period minus sampling time + conversion time). Since the oscillation frequency is 7.37 MHz, the instruction period TCY = (1/7.37) × 4 = 0.5 μs.
Actual control: The conversion time is 14 TAD (for correct A/D conversion, TAD = 333.33 ns). Therefore, if the A/D automatic sampling time is configured to be 6 TAD and the A/D conversion clock is 16TCY, the total A/D conversion time is 0.092 ms and the sampling frequency is 10.87 kHz.
The A/D module works in the system clock source and automatic conversion mode, and enters an interrupt after each conversion. A structure with a sampling point number should be defined in the program to store the data collected by the A/D. Each structure includes a real part and an imaginary part. In the interrupt service subroutine, the digital quantity collected by the A/D module is stored in the real part of the structure, and a total of sampling point conversions are performed. The flow of the interrupt service subroutine is shown in Figure 4.
2.2 Period determination
The frequency components of audio signals are not only numerous, but also non-periodic. The measurement period can be in the time domain or in the frequency domain. However, since the frequency domain measurement of periodicity requires that certain frequency points have regular zero points or near zero points, it is impossible to correctly analyze the periodicity of more complex signals with more frequency components and more uniform and low power distribution. Therefore, for the periodicity determination of the signal, the period determination function should be called directly before the FFT transformation of the signal. The flow chart of the periodicity determination subroutine is shown in Figure 5.
2.3 FFT Transformation
Since the amount of computation of direct Fourier transform is proportional to the square of the number of sub-sample points N, when N is large, the amount of computation is too large and is not suitable for implementation in embedded systems with limited resources. Therefore, the most commonly used radix 2 FFT algorithm is the one whose main idea is to decompose the N-point direct Fourier transform into multiple shorter direct Fourier transforms, and then use the periodicity and symmetry of the rotation factors to save system resources to a great extent.
The MPLAB C30 C compiler provides almost all digital signal processing software tools. Through the DSPIC30F series microprocessor, digital signal processing can be easily implemented by simply calling the library functions provided by Microchip. For the radix-2 FFT transform, its software flow chart is shown in Figure 6.
2.4 Feature value extraction
The quantities that play a decisive role in frequency domain analysis include sampling frequency and number of sampling points. Through FFT transformation, the discretized amplitude spectrum X(k) is obtained. The discretized amplitude value is first squared and then divided by the number of sub-sample points N to obtain the power value corresponding to the frequency point (power = X(k)*X(k)/N).
3 Conclusion
The main performance indicators of the system are: input impedance 50 Ω; input signal voltage range (peak-to-peak value) 100 mV~5 V; the frequency component range of the input signal is 200 Hz~10 kHz; the frequency resolution is 100 Hz (it can correctly measure the power value of the frequency component with a frequency difference of not less than 100 Hz in the measured signal); the total power of the input signal and the power of each frequency component, the sum of the power of each detected frequency component is not less than 95% of the total power value; the absolute value of the relative error of the power measurement of each frequency component is less than 10%, and the absolute value of the relative error of the total power measurement is less than 5%; the analysis data is refreshed at a period of 5 s, and the frequency components of the signal should be stored in sequence according to the power size and can be played back and displayed. At the same time, the total power of the signal and the frequency and power values of at least the first two frequency components are displayed in real time, and a pause button is set to keep the displayed data. Audio signal analysis based on DSP microcontroller technology has the characteristics of stable performance, simple circuit, fast speed, low cost and small size. It is suitable for embedded systems that require audio signal analysis and can be further promoted and applied in more fields, such as environmental monitoring, speech recognition, and control of intelligent systems.
Previous article:Design of LED drive control circuit based on PIC microcontroller
Next article:Design of triple speed sampling method for serial asynchronous communication based on PIC software
- Popular Resources
- Popular amplifiers
Recommended Content
Latest Microcontroller Articles
He Limin Column
Microcontroller and Embedded Systems Bible
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
MoreSelected Circuit Diagrams
MorePopular Articles
- 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
MoreDaily News
- 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
Guess you like
- 50 ohm impedance line problem
- 【Portable programmable instrument】Begin preparation for debugging
- TIOBE Programming Language Rankings April 2022
- Selection of Serial Port to WiFi Module and Serial Port to Network Port Module for Industrial Control Gateway of Internet of Things
- TI Cortex MCU Industrial Safety Applications
- [Raspberry Pi Pico Review] WS2812B Snowflake Light Practice -- and IoT Communication RGB Control
- How to convert a sine wave into a square wave
- If you want to work in electronics, you need to remember these English words!
- Decoupling Technology
- Bluetooth 4.0 BLE Development Complete Manual: Practical IoT Development Technology