Data acquisition technology involves a wide range of fields, a wide dynamic range of collected signals, a large amount of data to be processed, and high requirements for the real-time performance of the system. Processing signals in the form of digital signals has the advantages of fast processing speed, flexibility, accuracy, strong anti-interference ability, small size and high reliability, which meets the requirements for fast, accurate and real-time processing and control of signals. This design takes advantage of these advantages of digital circuits, improves the traditional analog recording circuit, and improves the performance at a lower cost.
1. Proposal demonstration
This design processes the audio signal in the form of a digital signal. There are three options:
1) Directly use the voice chip for voice recording and playback. Winbond's ISD series voice chip uses the patented Chip-Corded technology. The sound can be directly stored without A/D conversion and compression. There is no A/D conversion error. Up to 250 levels of sound signals can be stored in one recording bit (BIT), which is equivalent to 8 times the recording capacity of the usual A/D technology. The chip integrates a crystal oscillator, microphone preamplifier, automatic gain control, anti-aliasing filter, smoothing filter, sound power amplifier, etc., and only a few peripheral devices are needed to form a complete sound recording and playback system.
2) Use DSP to process the sampled signal. DSP is a microprocessor with a special structure designed specifically for the rapid implementation of various signal processing algorithms. Its processing speed far exceeds that of a general CPU.
3) Use AT89S52 as the system main control chip, use ADC0809 to collect and A/D convert the audio signal, store the converted digitized audio signal in the extended data storage, use software to digitally filter the signal, and finally output PWM signal through the microcontroller to complete the playback.
The above three solutions are compared from the perspective of economic and technical factors: Directly using the voice chip can reduce a lot of peripheral circuits, and the circuit design is convenient, but the voice chip is not flexible enough. DSP has powerful digital signal processing functions and is flexible to use, but the chip is expensive and not suitable for general applications. The devices in solution 3) are all common chips, easy to obtain, and not expensive. Therefore, solution 3) is the best design solution.
2 Hardware Design
Figure 1 is a diagram of the system hardware structure. The audio signal is converted into a processable electrical signal through the pickup. The preamplifier circuit is used to amplify the output of the pickup and match the A/D conversion circuit. The A/D conversion circuit realizes the encoding of the analog signal. The microprocessor is the core of the system. It is used to process and store digital audio signals, coordinate the work of various parts of the system, and output PWM waves to drive the output circuit.
2.1 Microcontroller
The single-chip microcomputer is the control center of the system. It mainly realizes the following functions: controlling the LCD to display the relevant information of the voice signal, controlling key recognition and function selection; controlling the collection of audio data and storing it in the Flash ROM, reading the data in the Flash ROM during playback, and using software methods to generate PWM pulse signals to realize voice storage and playback.
2.2 Sound signal pickup and amplification circuit
The sound signal pickup circuit is a device that converts sound signals into electrical signals. This design uses a microphone, which is a sound-sensitive resistor whose resistance changes with the changes of external sound signals. When it is connected in series in the circuit, the change in resistance forms a change in voltage, which is passed through the capacitor to pass AC and isolate DC, and then an electrical signal representing the characteristics of the sound signal is obtained.
However, since the amplitude of the output voltage of the sound signal pickup circuit is very small, 20-25 mV, if the signal is directly connected to the A/D conversion circuit, since the minimum resolution voltage of the A/D converter is also in the order of millivolts, a large error will occur. In order to ensure the accuracy of the system, an amplifier circuit must be connected in series before connecting to the A/D conversion circuit. Considering that the output signal of the sound signal pickup circuit is very small, the distortion and noise of the amplifier circuit have the greatest impact on the accuracy of the system, so it is designed as a parallel negative feedback amplifier circuit with strong resistance to common-mode interference. Since the bandwidth of the audio signal is large, the wide-band, low-output impedance dual op amp NE5532 is selected.
2.3 A/D conversion circuit
The A/D conversion circuit consists of A/D converter ADC0809 and system processor AT89S52, and is mainly used to sample the amplified sound signal.
As can be seen from Figure 2, the ALE signal of ADC0809 is connected to the START signal, so that the channel address can be written (latched) at the leading edge of the signal, and the conversion can be started immediately at its trailing edge. To start the A/D conversion, only one instruction P2.7=0 is required. Before that, P2.7 should be cleared and the address corresponding to the lowest 3 bits of the selected channel should be sent to the data pointer DPTR. The conversion end signal EOC of ADC0809 is inverted and connected to INT1 of AT89S52, and the A/D conversion result is read in interrupt mode, and the next A/D conversion is started. The A/D conversion can also be started regularly and the last conversion result can be read.
2.4 Sound Coding Storage Circuit
During sampling, each sampling point will generate a 1-byte digital code signal. Since the sampling frequency is 8 kHz, if the recording is 15 minutes, the required storage space is 7.031 25 MB. Therefore, the system uses an 8 MB Flash memory K9F6408U0A. Since the address line and data line of this memory can be reused [3], this can save I/O interfaces. The biggest advantage of K9F6408U0A is that its commands, data and addresses can communicate with the main controller through 8 I/O interface lines, which greatly simplifies the system connection and enhances the stability of the system. In addition to the 8 I/O interface lines, K9F6408U0A also includes the following control lines: 1) CLE: Command latch enable terminal, high level is valid. At the rising edge of the WE signal, the command signal can be locked into the command register through the I/O port; 2) ALE: Address latch enable terminal, high level is valid. At the rising edge of the WE signal, the address signal can be locked into the address register through the I/O port; 3) CE: chip select line, low level is valid. During page programming or block erase operation or when the device is in a busy state, the CE high level will be ignored, 4) WE: write enable port, command, address and data are locked at the rising edge of the WE signal; 5) RE: read enable port, at the falling edge of this port, data is sent to the I/O port line and the internal column address register is increased by 1; 6) WP: write protection port, low level is valid, when it is low, programming and erasing operations are prohibited; 7) R/B: operation status indication signal. When it is low, it means that programming, erasing or reading operation is in progress, and it becomes high after the operation is completed. Using the above control lines, it is convenient to realize the control of K9F6408U0A by the system main controller. The AT89S52 microcontroller and K9F6408U0A storage interface circuit is shown in Figure 3.
2.5 PWM Output Circuit
This design uses a single-chip microcomputer to output a PWM signal to drive the audio amplifier circuit. The PWM output circuit is shown in Figure 4. PWM is an effective technology that uses the digital output of a microprocessor to control analog circuits. It modulates the width of a series of pulses to obtain the required waveform, and because no D/A converter is used, the system cost is greatly reduced. The advantage of PWM is that the signals from the processor to the controlled system are in digital form, and no D/A conversion is required. Keeping the signal in digital form can minimize the impact of noise. In addition, the PWM signal is easily controlled by the MCU software. Even if the circuit has a slight system error, it is easy to correct it through software.
In Figure 4, the P1.7 pin of the microcontroller is used to output a PWM signal of a certain width. After being shaped by the transistor, it acts on the inertia link. The resulting output signal PWMOUT will act on the audio power circuit and be restored to sound.
2.6 Audio Power Amplifier Circuit
In order to make the system have a large enough output to drive the speaker to make sound and facilitate volume adjustment, an audio signal power amplifier LM386 is used after the PWM output circuit to build a power amplifier circuit, as shown in Figure 5.
The LM386 audio power amplifier is mainly used in low-voltage consumer products. To minimize the number of peripheral components, the voltage gain is built-in to 20. However, by connecting an external resistor and capacitor between its pins 1 and 8, the voltage gain can be adjusted to any value, up to 200. The input is referenced to ground, and the output is automatically biased to half the power supply voltage. At a power supply voltage of 6 V, its static power consumption is only 24 mW, making the LM386 particularly suitable for battery-powered occasions. PWMOUT is the output of the PWM output circuit, and the speaker is 8 Ω, 0.5 W. After debugging, it was found that filtering the power supply +5 V with 10 μF and 0.1 μF capacitors will reduce a lot of noise and have a better effect.
3 System Software Design
The system has functions such as recording, playing, pausing, and clearing storage contents. Various functions are selected by buttons. The system first scans the status of each button. If a button is pressed, it will go to the corresponding processing program. The system program flow is shown in Figure 6.
3.1 System Initialization Procedure
The system initialization program mainly sets the microcontroller interrupt, timer, LCD initialization, keyboard, PWM, K9F6408U0A storage interface, ADC0809 address, and various variables used in the program.
3.2 Key Scanning Program
Since recording and pause are set by two buttons connected to the external interrupt pin, once the button is pressed, the recording or playback program will be entered, so the button scanning program is used to scan whether the playback button and the clear button are pressed.
3.3 Recording Procedure
When the key connected to external interrupt 0 is pressed, the recording program will begin.
The recording process is essentially the process of starting ADC0809 to sample the analog audio signal and storing the A/D conversion results in the peripheral data storage. Therefore, it mainly includes two parts: reading ADC0809 and writing to the peripheral data storage.
When extracting sound data, we should pay attention to the relationship between sampling frequency, sampling bit number, storage capacity and storage time. Usually, a sampling frequency of 8 kHz and a sampling bit number of 8 bits can obtain clear speech and good music sound, and occupy less storage space.
The code snippet to start ADC0809 with a sampling frequency of 8 kHz, read the last sampling result, and write it to the external Flash memory is as follows:
3.4 Playback Procedure
If P1.0 is pressed, the playback program is executed. The playback process is essentially the process of reading the data in the peripheral data memory, converting it into a PWM wave of a certain width, and outputting it. The sub-function for reading K9F6408U0A is as follows:
Steps to generate PWM waveform: 1) Set the timer to generate a timer interrupt. If the sampling rate is 11.025 kHz, set the timer interrupt frequency to 11.025 kHz; 2) Initialize the PWM module to generate a 11.025 kHz PWM waveform; 3) Wait for the timer interrupt, get the sampled data in the interrupt handler, and set the PWM duty cycle register to determine whether the sound is finished. If it is finished, turn off the timer interrupt and stop the PWM output.
3.5 Suspending the program
During the recording process, if you need to temporarily stop recording, you can press the pause button to enter the pause state. Press the pause button again to return to the previous state.
A variable is set in the program to indicate whether it should be paused or resumed.
3.6 Memory content clearing procedure
When the memory is full and recording is needed, the clear button can be pressed to clear a certain amount of content for the user to use again.
Erase: Erase in blocks. The code snippet is as follows.
4 Debugging Notes
When debugging the system, pay attention to the following aspects:
1) Since the sampling rate of 8 kHz is used in both PCM (Pulse Code Modulation) and DPCM encoding modes, each compression interrupt service program must be completed within 125 μs. Therefore, the code of the compression recording processing program must be optimized as much as possible to reduce the program execution time to avoid conflicts between sampling and data processing or information display, and to avoid the loss of sampling points when interrupting sampling.
2) When selecting the clock of ADC0809, the classic choice is about 640 kHz. Initially, the ALE end of the microcontroller was divided by 4 as the clock signal of ADC0809, but it was found that the output display of the LCD was affected. The problem was solved by changing the ALE end to 2 (using 1 M trigger) as the clock signal of ADC0809.
3) Use the MAX813L reset chip to replace the RC reset circuit to make the circuit reset reliably, and combine it with software monitoring to realize the watchdog function.
4) When the sampling frequency is 8 kHz and the word length is 8 bits, the stored speech duration exceeds 15 minutes and the playback voice quality is good.
5 Conclusion
The K9F6408U0A 8 MB NAND Flash memory and the PWM function of the microcontroller can be used to add voice functions to the application of the microcontroller. The storage method for the sound sampling data is to use direct and original sampling data. In specific practical applications, the STC12C5A08AD with an embedded A/D converter can be selected, which can save the external ADC0809 and make the circuit simpler. The innovation lies in not using a dedicated voice chip to achieve the storage and playback of the voice of the microcontroller application system.
@end 文章内容
Previous article:Design of smoke alarm based on AT89C52 and MQ-2 smoke sensor
Next article:Mobile Wireless Data Transmission System Designed Based on 51 Single Chip Microcomputer
- Popular Resources
- Popular amplifiers
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- 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
- Brief Discussion on the Development of Automation Instruments
- One controller is 3.3v, use TLP521-4 optocoupler to convert to 24v
- What are the advantages of digital circuits compared to analog circuits?
- GD32E230C development board button problem
- New Horizons to Pluto: Qorvo Helps Send Images from Pluto to Earth
- [GD32L233C-START Evaluation] Generation, compilation and download of RT_T project
- ST60 Short-range Contactless 60GHz Millimeter Wave Connector Different Obstacle Test
- Solve the problem of BQ76930 20 series circuit driving circuit
- Detailed discussion on embedded C programming experience
- You must know these contents - Nichicon's "Capacitor Doctor" series of short films are online