This system uses the esp32 microcontroller as the control core, and consists of a car and a buzzer to form a movable sound source system. The audio signal emitted by the buzzer is received by the lm567 control microphone, and the lm358 operational amplifier is used to amplify the audio signal. When the signal is output, the analysis results are communicated with the microcontroller through the esp32 wireless transceiver module. The microcontroller controls the duty cycle of the PWM wave of the motor driver chip and is driven by the L298N drive circuit to accurately control the movement of the car motor, which achieves better sound guidance. system.
Keywords: audio signal processing; sound source localization; ESP32 microcontroller; wireless transmission;
1. Plan comparison and demonstration 1
1.2.1. Audio signal acquisition and processing module 1
1.2.2. Selection of microcontroller 1
1.2.3. Wireless communication module 2
1.2.4. Motor control and drive module 2
1.2.5. Audio power amplifier module 2
2. Comparative analysis of overall ideas 3
2.2. Phase difference method 3
3.1.1. Audio transmitter module 5
3.1.2. Audio receiving module 5
This system consists of two units: a movable sound source and three audio receivers with different orientations. Each unit is controlled by a low-power microcontroller ESP32, and the controller at the audio receiver is the main controller. The audio receiver can receive and process the audio signal emitted by the movable sound source platform, and guide the movable sound source to move along a designated route under the control of the main controller. The audio receiver is composed of an audio signal acquisition and processing circuit and a wireless transceiver module. The movable sound source uses a car as a platform and consists of an audio power amplifier, a light-emitting indicator circuit, a motor control and a drive circuit, etc.
The audio detection and shaping circuit uses a piece of LM567. The basic working condition of LM 567 is like a low-voltage power switch. When it receives an input tone within the selected narrow frequency band, its switch is turned on. And the universal LM567 can also be used as a deformable generator or a universal phase-locked loop circuit. When used as a tone control switch, the detected center frequency can be set to any value between 0.1 and 500KHZ, and the detection bandwidth can be set to any value within 14% of the center frequency. Furthermore, the output switching delay can be varied arbitrarily over a wide time range by selecting external resistors and capacitors.
1. Choose STM32F03C8T6, but choosing STM32 requires two wireless communication modules, and the total price is more expensive.
2. Choose ESP32 to develop based on arduion. This module comes with wireless transmission communication. And domestic prices are relatively cheap and cost-effective.
So we choose 2.
Using the Bluetooth communication that comes with ESP32.
Using L298N drive motor.
We choose DC motors because they are cheap and cost-effective.
LM386 is an audio integrated power amplifier with the advantages of low power consumption, adjustable internal chain gain, wide power supply voltage range, few external components and low total harmonic distortion. And the price is cheap, only a few cents a piece.
Through discussions within the group and the requirements of the topic, in the following article we generally introduce the structure of the smart car:
Assume receiver A is the coordinate origin, AC is the Y-axis, and AB is the X-axis to establish coordinates, as shown in the sound guidance diagram in Figure 5. Suppose L_SC=L 1 , L_SA=L 2 , L_SB=L 3 , the difference between L 1 and L 2 is a, the difference between L 3 and L 2 is b, establish the following system of equations according to the cosine theorem (length unit: m , time unit: s):
Among them, t 1 and t 2 respectively represent the time difference between the arrival of sound at A and C and the arrival at A and B, and their values can be positive or negative. Compared with point A, when the sound reaches point C first, t 1 <0, and when it reaches point B first, t 2 <0, otherwise t 1 >0 and t 2 >0. Combining equations (3), (4), (5), (6), and (7), we can get the following equation:
According to equation (8), the value of L 2 can be obtained by using the root formula . Then calculate the values of L 1 , L 3 , cos, and sin respectively according to formulas (3), (4), (5), and (6) . The final sound source coordinates are:
This solution can find the current location of the movable sound source, and can make the sound source reach any specified position. However, its calculation amount and data amount are large, and it is suitable for running on a controller with high processing speed and large RAM. , theoretically it can be solved with the computing power of ESP32, but considering the functions of the hardware and actual errors, this bill is not suitable.
The phase difference method can locate individual special positions, such as the center line between points A and B and the center of the entire rectangular area. This method is suitable for certain special occasions.
In order to make the movable sound source reach the OX line, the phase difference of the audio signal received by receiver A and receiver B after amplification, filtering and shaping is measured. According to the propagation speed of audio in the air, 340*t 2 =L 2 -L 3 can be obtained . When it reaches the center line OX, the phase difference is 0. This is a theoretical value, but it shows that there is an error and a range can be given. At this time, t 2 =0. In the same way, the sound source can be guided to the center of the rectangle. This system adopts this method.
Using the LM386 circuit with a gain of 200 times, it can effectively amplify the output power of the microcontroller and drive the speaker.
Using LM567 frequency selection circuit, the effect is good, the original parameters used are all valid parameters, the error does not exceed 5%
The lm2596 is used to reduce the voltage to 5V as the power supply for the microcontroller.
Power module
A 12V rechargeable lithium battery is used to power the motor to ensure stable power supply.
Taking the arrival of the center line OX as an example, the host first transmits a signal through Bluetooth transmission to tell the slave to start the timer. The host emits a sound wave. Since the three pins of the slave are set to the falling edge, the interrupt is turned on. When a certain receiving hardware is received, turn on the interrupt and read the timer time. When all three are received, turn off the timer and compare the time of A and B. If the time to reach A is greater than B, the slave sends a forward signal to the host. , if the A and B times are within the allowed range, a stop signal is sent to the host to stop the car, and then the above procedure is repeated continuously. However, due to the interference of echo and other sound sources, the time judgment is inaccurate. At this time, the response time must be reduced and the sound frequency must be increased. The mean filter algorithm is often used to obtain a relatively stable time.
Overall software flow chart
The frequency of the movable sound source audio signal is 6.4kHz, and the time period is set to 1s to sound once.
Assemble and debug all the hardware, and burn the written ESP32 into two ESP32 modules. Continuously correct and optimize Arduion-based programs according to the actual hardware conditions.
to Ox line |
to center point |
||||
Second-rate
number |
average Speed(cm/s) |
position Error(cm) |
Second-rate
number |
average Speed(cm/s) |
position Error(cm) |
1 |
6.9 |
0.5 |
1 |
6.5 |
0.3 |
2 |
6.4 |
0.2 |
2 |
7.7 |
0.3 |
3 |
4.9 |
0.3 |
3 |
4.9 |
1.2 |
4 |
7.4 |
0.6 |
4 |
7.1 |
0.7 |
5 |
8.4 |
0.4 |
5 |
8.9 |
0.5 |
average error |
0.4 |
average error |
0.6 |
Since the distance limit of the hardware can only be guaranteed to be effective within a specific demonstration, the car can only meet the requirements within this specific range. At the same time, due to environmental interference, it is not guaranteed to completely reach the center line every time, and there are errors. And due to the Bluetooth pairing response speed, the overall pace is not very fast. Improvements can be made in the software.
All reference designs on this site are sourced from major semiconductor manufacturers or collected online for learning and research. The copyright belongs to the semiconductor manufacturer or the original author. If you believe that the reference design of this site infringes upon your relevant rights and interests, please send us a rights notice. As a neutral platform service provider, we will take measures to delete the relevant content in accordance with relevant laws after receiving the relevant notice from the rights holder. Please send relevant notifications to email: bbs_service@eeworld.com.cn.
It is your responsibility to test the circuit yourself and determine its suitability for you. EEWorld will not be liable for direct, indirect, special, incidental, consequential or punitive damages arising from any cause or anything connected to any reference design used.
Supported by EEWorld Datasheet