“In order to prevent automobile accidents, when the automobile intelligent detection device detects that there is danger ahead, it must issue a warning message to the driver. The voice alarm clearly warns the driver of danger so that the driver can take timely and accurate measures. Therefore, this paper proposes a digital voice processing technology, which firstly collects and stores the alarm information of various conditions digitally. When encountering danger, it will judge the type of danger and automatically select and play the stored alarm information.
Authors: Ma Zhiyuan; Huang Jinfeng; Zhang Fan; Zhang Chengxue
In order to prevent automobile accidents, when the automobile intelligent detection device detects that there is danger ahead, it must issue a warning message to the driver. The voice alarm clearly warns the driver of danger so that the driver can take timely and accurate measures. Therefore, this paper proposes a digital voice processing technology, which firstly collects and stores the alarm information of various conditions digitally. When encountering danger, it will judge the type of danger and automatically select and play the stored alarm information. Due to the large amount of voice information, direct storage takes up huge storage space. For this reason, this paper uses FPGA to implement ADPCM (Adaptive Differential Pulse Code Modulation) codec design to compress and store voice information. This doubles the amount of stored information.
2 System structure and principle
The design of this system is based on single chip microcomputer and FPGA as the core. The single-chip microcomputer controls the working state of the system, starts recording and playback, and time and Display the recording and playback time. The FPGA compresses, stores, and decompresses the collected data. The single-chip microcomputer and the FPGA work in coordination, which improves the work efficiency and stability of the system. The system structure is shown in Figure 1.
First of all, the various alarm sounds you want to collect are converted into digital signals by the A/D converter through the forward channel (microphone, differential amplifier, filter, adder) and sent to the FPGA for ADPCM compression and encoding, and then stored. into the static memory SRAM. When encountering danger, the single-chip microcomputer judges the danger, controls the FPGA to take out the corresponding voice data from the SRAM and decodes it, and then sends it to the 8-bit D/A converter, converts it into an analog signal, and then passes through the backward channel (filtering). device, correction circuit, power amplifier, speaker) to reproduce the alarm sound.
3 Main hardware design of the system
The electret microphone is used to collect the voice signal, and the signal amplitude is converted to a millivolt-level electrical signal. When the system pre-stage processes it, the signal-to-noise ratio of the amplifier input end should be improved as much as possible to ensure that the amplifier circuit has an accurate and stable gain. . To this end, the detection amplifier circuit shown in Figure 2 is designed in this paper. The front stage of the circuit adopts a voltage follower, which uses the characteristic that the input resistance is infinite and the output tends to zero to provide high input resistance to realize impedance transformation and isolation; Circuit immunity.
The voltage follower is composed of a low-noise audio amplifier NE5532 with excellent performance. The working voltage is 12 V and the working bandwidth is 10 MHz, which is especially suitable for speech information processing. The difference amplifier is implemented with AD620. The inside of AD620 is actually a differential amplifier with small offset voltage and current and high common-mode rejection ratio. Therefore, it has excellent performance in processing weak signals, that is, in terms of amplifying and eliminating noise. Its gain G=1+ (49.4 kΩ/Rg) (Rg is a resistor connected between pins 1 and 8). Adjust the potentiometer R1 to make the amplified signal amplitude between -2.5 V and 2.5 V, which is convenient for A/D converter to sample and quantize.
3.2 Bandpass filter
After the voice signal is amplified and transmitted, it is easy to pick up noise, so before data acquisition, it is necessary to filter out out-of-band clutter through a band-pass filter. The frequency range of human speech is 300 Hz to 3.4 kHz, so the passband range of the filter should be 300 Hz to 3.4 kHz. Such a wide frequency band must be realized by cascading the low-pass part and the high-pass part.
High-pass filter design index: pass-band cut-off frequency fp=300Hz, pass-band allowable maximum attenuation αp≤3 dB; in order to eliminate power frequency interference, determine stop-band cut-off frequency fs=50 Hz, stop-band allowable minimum attenuation as>40 dB. It is composed of two-stage second-order Butterworth high-pass filters in cascade. The simulation results are shown in Figure 3.
The design index of the low-pass filter is: the pass-band cut-off frequency fp=3 400 Hz, the maximum allowable attenuation αp ≤ 3 dB in the pass-band; in order to suppress sampling aliasing distortion, the stop-band cut-off frequency fs=4 000 Hz is determined, and the stop-band allows Minimum attenuation as ≥ 40 dB. Because the elliptic filter can obtain a narrower transition bandwidth than other filters, it is suitable for this system design. The fifth-order elliptic low-pass filter circuit is obtained by using the filter aided design software Filter Wiz Pro, as shown in Figure 4, and the simulation results are shown in Figure 5.
By cascading high-pass and low-pass filters, a band-pass filter of 300 Hz to 3.4 kHz can be obtained. Experiments show that the filter has a good effect and reaches the design index. The design of the bandpass filter for the backward channel is the same.
4 Design of system software
4.1 FPGA part
Select EPlC6Q-240C8 of Cyclone series of Altera Company to realize ADPCM encoder and decoder. The device contains 120 000 typical gate resources, 5 980 logic units, 6 RAM modules, 92 160 Bit RAM or ROM, 2 digital PLLs, 185 programmable I/O ports, and the highest working clock can reach more than 300 MHz. And through the JTAG interface to achieve in-system configuration.
ADPCM is a waveform coding technique that utilizes high correlation between samples and quantization order to compress data adaptively. ADPCM combines the adaptive characteristics of APCM and the differential characteristics of DPCM.Its core idea is to adaptively change the size of the quantization step, that is, to use a small quantization step to encode a small difference, and a large quantization step to encode a large difference;
The sample value of estimating the predicted value of the next input sample, the difference between the actual sample value and the predicted value is always the smallest. The input signal of ADPCM codec is G.711 PCM code. If the sampling frequency is 8 kHz and each code is 8 bits, its data rate is 64 Kb/s, and the output code of ADPCM is “adaptive quantizer”. ” output, the output is a 4-bit differential signal, its sampling frequency is still 8 kHz, and the data rate is 32 Kb/s, thus obtaining a 2:1 data compression.
Encoding process: Calculate the difference d between the current sample value Sc of the 8-bit two’s complement code and the previous predicted sample value Sp, and the difference value is quantized and encoded to output a 4-bit ADPCM code I. In the algorithm, a structure variable is defined to store the predicted sample value Sp and the quantization step size q, and two tables are formulated: one table is the index adjustment table, and its input is the difference quantization code I, which is used to update the step size index; One table is the step size adjustment table, whose input is the step size index and the output is the step size q. When encoding, first use the step size index of the previous sampling point to check the step size adjustment table to obtain the step size q, and then determine the 4-bit ADPCM encoding value I according to the following formula:
Then use the encoded value I as the input of the index adjustment table, look up the table to output the index adjustment, and add it to the original step size index in the structure variable to generate a new step size index, which is used in the encoding of the next sample value. After the encoder outputs I, the same calculation process as the decoding needs to be repeated to obtain a new predicted sample value Sp.
Decoding process: First, the quantization step size is obtained by querying the step size adjustment table through the step size index, and the difference quantization code I is inversely quantized to obtain the speech difference value d, which is the inverse process of finding I; and then with the previous predicted value Sp. The current speech signal Sc is reconstructed together; finally, Sp=Sc is used to update the predicted value Sp, and I is used to update the quantization step size index.
After the design is completed, the ADPCM codec is simulated, and the simulation results are shown in Figure 6. AD_DataBus is the input signal before encoding, which is generated by Testbench. When the encoding enable signal P1_7 is “0”, encoding starts, and when P1_7 jumps to “1”, the encoding is masked. At this time, the decoding enable signal P1_4 is “0”, and decoding starts. When P1_4 jumps to “1”, the decoding is masked. It can be seen that the input signal AD_DataBus before encoding and the decoder output DA_DataBus basically meet the requirements. Since the ADPCM algorithm itself is lossy compression, it can be determined that the design of this part is correct and reliable.
4.2 Microcontroller part
The single-chip microcomputer is the control center of the whole system. Responsible for detecting danger and judging its type to choose to play the corresponding alarm information. Its workflow is shown in Figure 7. This paper presents the use of 3 buttons to represent the occurrence of 3 kinds of dangers for the detection of single-chip microcomputers.
Select the commonly used 51 series microcontroller AT89C52, and use C51 language programming to complete the program design, and the experimental effect is ideal.
The design of this system is that the single-chip microcomputer and the FPGA are used together to give full play to their respective advantages. The ideal effect is obtained, which has strong practicability, and also proves the high efficiency of using programmable logic device to realize the voice digital compression processing. Experiments show that the system can reproduce the recorded alarm voice well and has high fidelity. Drivers can freely change the alarm sound according to their preferences. In critical situations, the system will automatically issue a clear alarm prompt, which greatly improves the safety of driving.