Download final_paper

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

Spectral density wikipedia , lookup

Electrical substation wikipedia , lookup

Headphones wikipedia , lookup

Variable-frequency drive wikipedia , lookup

Power inverter wikipedia , lookup

History of electric power transmission wikipedia , lookup

Audio power wikipedia , lookup

Heterodyne wikipedia , lookup

Ground loop (electricity) wikipedia , lookup

Sound reinforcement system wikipedia , lookup

Dynamic range compression wikipedia , lookup

Rectifier wikipedia , lookup

Surge protector wikipedia , lookup

Solar micro-inverter wikipedia , lookup

Schmitt trigger wikipedia , lookup

Power MOSFET wikipedia , lookup

Phone connector (audio) wikipedia , lookup

Oscilloscope history wikipedia , lookup

Stray voltage wikipedia , lookup

Immunity-aware programming wikipedia , lookup

Metadyne wikipedia , lookup

Analog-to-digital converter wikipedia , lookup

Islanding wikipedia , lookup

Alternating current wikipedia , lookup

Voltage regulator wikipedia , lookup

Power electronics wikipedia , lookup

Pulse-width modulation wikipedia , lookup

Buck converter wikipedia , lookup

Voltage optimisation wikipedia , lookup

Resistive opto-isolator wikipedia , lookup

Public address system wikipedia , lookup

Switched-mode power supply wikipedia , lookup

Mains electricity wikipedia , lookup

Opto-isolator wikipedia , lookup

Transcript
DANGER DETECTING HEADPHONES
By
Tae Hun Ahn
Daniel Bang
Yoon Mo Yang
Final Report for ECE 445, Senior Design, Fall 2016
TA: Zipeng Wang
07 December 2016
Project No. 47
Abstract
This report describes the details of the design in the Danger Detecting Headphones, which detects the
car horn sound from the outside environment and mutes the speaker for three seconds. The end
product was also able to filter out noises from the car horn signal. Hardware and software design
implementation will be discussed along with the verification of the modules, followed by the cost
analysis and future works.
ii
Contents
1. Introduction .............................................................................................................................................. 1
1.1 Statement of Purpose ......................................................................................................................... 1
1.2 Objectives............................................................................................................................................ 1
1.2.1 Benefits and Features .................................................................................................................. 1
1.2.2 Goals and Functions ..................................................................................................................... 1
2 Design......................................................................................................................................................... 2
2.1 Block Diagrams and Flowchart ............................................................................................................ 2
2.1.1 Hardware Block Diagram ............................................................................................................. 2
2.1.2 Software Flowchart ...................................................................................................................... 2
2.2 Block Description ................................................................................................................................ 3
2.2.1 Power Module.............................................................................................................................. 3
2.2.2 Microphone Module .................................................................................................................... 4
2.2.3 Volume Control Module .............................................................................................................. 5
2.2.4 Microcontroller Module............................................................................................................... 7
3. Design Verification .................................................................................................................................... 8
3.1 Power Module..................................................................................................................................... 8
3.2 Microphone Module ........................................................................................................................... 8
3.3 Microcontroller Module (ATMega328p-pu) ....................................................................................... 8
3.4 Volume Control Module ................................................................................................................... 10
4. Costs ........................................................................................................................................................ 11
4.1 Parts .................................................................................................................................................. 11
4.2 Labor ................................................................................................................................................. 12
4.3 Grand Total ....................................................................................................................................... 12
5. Conclusion ............................................................................................................................................... 13
5.1 Accomplishments .............................................................................................................................. 13
5.2 Uncertainties ..................................................................................................................................... 13
5.3 Ethical considerations ....................................................................................................................... 13
5.4 Future work ....................................................................................................................................... 14
References .................................................................................................................................................. 15
iii
1. Introduction
1.1 Statement of Purpose
Nowadays, there are many consumer electronics companies focusing mainly on the audio equipment.
Many of these companies produce noise canceling audio systems which enhance general sound quality
of music in all kinds of situation. Such products become main production lines of several renowned
audio companies, and this reflects a high demand of consumers in the audio market. We, however,
found a very hazardous feature of this noise canceling system. And this precarious feature appears in
not only the noise canceling headphones but also most of regular headphones in use throughout the
daily life. The problem is that the noise canceling headphones and regular headphones with high volume
lead users to isolate themselves from surroundings by blocking all sounds but music. For the pedestrians
who use headphones regularly on the street, this blocked sound could lead them directly to death.
To prevent hazardous situations for the pedestrians, we decided to develop headphones that detect car
horns and automatically mute music. This mute system will help pedestrians to perceive surround
situation immediately. We successfully developed headphones that work properly as we expected. Even
though overall functionality was satisfactory, there were some uncertainties like reliability in maximum
detectable distance.
1.2 Objectives
1.2.1 Benefits and Features
 Portable
 Detect car horns
 Mute the music player once the car horn is detected
 Filter out noises other than the car horns
1.2.2 Goals and Functions
 Collect sound data from microphone
 Convert the analog signal to the digital waveform
 Fast Fourier transform the digital wave
 Provide safety for the users via the mute logic
1
2 Design
2.1 Block Diagrams and Flowchart
2.1.1 Hardware Block Diagram
Figure 2.1 depicts the hardware block diagram of the entire circuit. First, the power module regulates
voltage from the battery and supplies 5V to all the other modules. The microphone module receives
sound signal from the outside environment and amplifies it through an op-amp circuit. The amplified
signal is still an analog signal and needs to be converted to a digital waveform in order for us to run the
detection algorithm in software. The microcontroller module does the job through an A/D converter
inside the chip. It also applies Fast Fourier Transform combined with the Digital band-pass filter, so that
it filters out the unnecessary noises other than car horn signal. If the filtered signal’s frequency matches
with that of the car horn, microcontroller will send a “mute” logic signal to the analog MUX inside the
volume control module. The volume control module, which controls the volume in normal state, will
mute the speaker for three seconds once it receives the “mute” logic signal.
Figure 2.1 Hardware Block Diagram
2.1.2 Software Flowchart
Figure 2.2 shows a software flowchart. The input of this flow chart is an analog signal generated by the
microphone. This analog signal will be converted into the digital signal through ADC by the ATMega328P
chip. After the conversion, we will run the fast Fourier transform test. Since the converted digital signal
2
contains a lot of noises, we pass the FFT results to the band pass filter to get rid of some noises that are
below the threshold.
Figure 2.2 Software Flowchart
With the results from the filter, we perform sampling to get the frequency. If the frequency matches the
expected car horn frequency, then the music will be muted. If not, the entire process that we described
above will be performed infinite times until it detects the proper frequency.
2.2 Block Description
2.2.1 Power Module
The power module of Danger Detecting Headphones has a simple structure but its role is significantly
important. To obtain an accurate detection feature, it was required to make the power voltage signal as
clean as possible. If the power signal has some noise, it will affect the output of the microphone module
and it will disturb the entire circuit to detect the car horn sound precisely. Therefore, it was fatal when
we did not filter out the noise from the power signal. Figure 2.3 shows the PCB that contains the power
3
module and the microphone module. And the part inside the orange square represents the power
module.
For the power source, we used a 9 V alkaline battery and for the voltage regulator, we used a LM7805.
The role of the LM7805 is basically to convert 9 V from the battery to 5 V. The reason for this choice is
that every IC chip being used in the entire circuit needs 5 V as its supply voltage. As you can see from
Figure 2.4, two capacitors were used in the module: The first capacitor whose capacitance is 100 𝜇𝐹, is
hooked up after the battery and before the input of the LM7805 regulator. This capacitor is there to
filter out any noise coming from the voltage source by shorting the AC signal of the battery to ground
and let only DC portion go into the regulator.[1] The second capacitor, hooked up after the regulator
also filters out any noise or ac signals by the same mechanism. We hooked up the resistor and the LED
at the end of the circuit to make it easier to check if the power module works fine.
Figure 2.3 PCB (Power Module)
Figure 2.4 Schematic of the Power Module
2.2.2 Microphone Module
The microphone module simply receives any audio signals from the outside of Danger Detecting
Headphones. Please refer to Figure 2.5 for the PCB design of the microphone module which is inside the
orange square.
Since the voltage output of the microphone is relatively small, it’s not possible to use it for the detection
feature without amplifying the output of the microphone. Therefore, it’s required to use an audio
amplifier. We found a low voltage audio power amplifier, LM386. We designed the module as shown in
Figure 2.6. We came up with this design by referring to the datasheet of the LM386. This module
basically receives the input audio signal from outside with the microphone and amplifies the signal with
the LM386. As you can see from Figure 2.6, lots of capacitors were used in this module. Each of them
has its own role. For example, C3, and C7 in Figure 2.6, block the DC voltage so only the AC signal can be
passed. We need to block the DC signal since audio signals are basically AC signals. Capacitors block the
DC voltage because the reactance of a capacitor is
4
𝑋𝑐 =
1
𝑤𝐶
(2.1)
where 𝑤 is angular frequency and 𝐶 is capacitance. Since DC voltage has no frequency, the reactance
will be infinity for DC cases so the capacitor blocks DC voltage. C2 whose capacitance is 10𝜇𝐹 sets the
𝑉
voltage gain to 200 𝑉. C1 has a similar role as the capacitors in the power module since it acts as a
bypass filter. Lastly, C4 acts as a current bank for the output. When sudden surges of current occur, it
will drain. Moreover, when there is the low demand for current, it refills with electrons.
Figure 2.5 PCB (Microphone Module)
Figure 2.6 Schematic of the Microphone Module [2]
2.2.3 Volume Control Module
The volume control module lets the user control the volume of his or her music player. The special
feature of this module is that its analog multiplexer receives the logic bit from the microcontroller as its
select bit. And according to the select bit, the analog multiplexer chooses its output between two inputs.
Figure 2.7 shows the design of the module on the breadboard.
As you can see from Figure 2.8, there are three major components in this module. The first component
is a stereo audio jack (STX-3120), it takes a 3.5 mm stereo audio cable as an input. We chose this audio
jack since every music player uses the 3.5 mm stereo audio cable. STX-3120 also controls the volume by
receiving the electric signal from the music player of the user.
The volume control module also uses the LM386 amplifiers since the output from the audio jack is too
small so, without the amplifiers, the analog multiplexer will not output the signal. We set the voltage
𝑉
gain to 20 𝑉 of the amplifiers.
5
The last component is the analog multiplexer, SN74F257. It receives the logic bit from the
microcontroller. Based on the logic bit, it chooses one of the inputs and sends the output signal to the
speaker. Please refer to Figure 2.9 and 2.10 to understand the operation of the analog multiplexer.
Figure 2.7 Volume Control Module
Figure 2.8 Schematic of Volume Control
Module [3]
Figure 2.9 Logic Symbol of SN74F257 [4]
Figure 2.10 Function Table of SN74F257
6
2.2.4 Microcontroller Module
The main component of the microcontroller module is ATMega328P-PU, which is also called an Arduino
UNO. Through the software design inside the chip, it performs the key functions to detect the car horn
frequency. Since we did not need to use all the I/O pins of the ATMega chip, we have built our own
circuitry for the ATMega328P-PU instead of a complete Arduino Uno board. This way, we were able to
not only save a lot of money, but also reduce the physical size of the entire PCB board as below. We
chose our clock to be 16 MHz instead of 8 MHz, because faster clock signal speeds up the execution time
of the microcontroller, letting the Arduino sample the analog signal more times in a same amount of
time. We expected this to result in more sampling rate, increasing the accuracy of the detection. Since
our design did not require the continuous communication with PC, we did not utilize WiFi
communication. Instead, we decided to use FT232 USB component to communicate with PC. Thus, we
connected the USB port just to upload the new sketch. The connection was simple enough because it
only required Rx and Tx pin of the ATMega chip to be connected to the Tx and Rx pin of the FT232,
respectively. However, we met a huge challenge during the communication. Initially, our circuit did not
have a capacitor C1 in the Figure 2.11, when the reset pin of the ATMega chip was connected to the DTR
pin of FT232 USB. This resulted in AC voltage, which is a noise, going into the DTR pin, arbitrarily
resetting the microcontroller while uploading. Thus, we had to cut out the AC voltage through the
capacitor C1.
Figure 2.11 Microcontroller PCB
Figure 2.12 Microcontroller Schematics
7
3. Design Verification
3.1 Power Module
In the power module, we have used 9 V alkaline battery. The battery should supply 9 ± 1.35 V to the
voltage regulator. This can be easily verified by connecting voltmeter to the battery. This voltage passes
the voltage regulator LM7805, and output should be 5.0 ± 0.25 V. As you can see in the Figure 3.1, max
voltage value is 4.98 V and min voltage value is 4.80 V. These both values are within the range of 5.0 ±
0.25 V.
Figure 3.1 5 V Voltage Regulator Verification
3.2 Microphone Module
In order to verify the microphone module, we focused on outputting the result through the oscilloscope.
This way, we were able to easily check if the output voltage matches with our expected voltage stated in
the requirements. The first important requirement was if the voltage output from the microphone itself
was from -2.5 V to 2.5 V. Using the oscilloscope, we were able to verify the output voltage was within
the expected range.
The second important requirement was the output voltage of the op-amp circuit. Since the signal was
amplified and given offset through the op-amp, the output should have been from 0 V to 5 V. We
successfully verified that the output voltage matches with the expected range.
3.3 Microcontroller Module (ATMega328p-pu)
To verify the performance of ATMega328p-pu, we first supplied the ATMega328p-pu with the 5 V. When
we connected the voltmeter with the pin 7, the result value was 4.998 which is in the range of 5.0 ±
0.165 V. ATMega328p-pu can also receive the analog signal between 0 V and 5 V. As you can see in the
Figure 3.2 the voltage is within 0 V and 5 V.
8
0
1
2
3
4
5
6
7
8
3.91
4.18
3.75
0.38
2.59
4.17
0.38
1.25
1.95
10
11
12
13
14
15
16
17
18
0.5
2.57
4.17
2.84
0.57
2.68
4.18
4.16
0.39
9
0.68
19
2.16
Figure 3.2 Analog Input from Microphone [5]
ATMega328p-pu performs FFT and digital filter, and these also needed to be verified. FFT was verified by
comparing the results of the different coding (MATLAB and Arduino). As you can see Figure 3.3 shows
the MATLAB code and Figure 3.4 is the result of FFT. Figure 3.5 is the result after running band pass
filter.
Figure 3.3 MATLAB Simulation Code
Figure 3.4 Before Band Pass Filter
Figure 3.5 After Band Pass Filter [6]
9
3.4 Volume Control Module
The operation of volume control module was verified by connecting the voltmeter to the digital power
supply pin and GND. The measured voltage is in the range of 5 V (±0.5%). The volume control module
also need to mute the music when the Arduino detects the car horns. This was verified by checking
whether the voltage of pin 8 output 0 V.
10
4. Costs
Price is always one of the most important factors in the market since it might be the first or last thing
that consumers consider before they buy the product. Table 4.1 outlines the cost of each component
while Table 4.2 outlines the cost of labor. As you can see from the last row of Actual Cost column of
Table 4.1, the total price is not that expensive compared to any normal headphones in the current
market.
4.1 Parts
Table 4.1 Parts Costs
Parts
Manufacturer
Bulk Purchase
($)
1.30
Quantity
Digikey
Retail Cost
($)
2.38
1
Actual Cost
($)
2.38
9 V alkaline battery
Voltage Regulator
(LM 7805CT)
Digikey
0.62
0.24
1
0.62
Microphone
(CMA-4544PF-W)
Audio amplifier
(LM386N-1/NOPB)
USB Interface Module (DEV09716)
Microcontroller
(ATMega328p-pu)
Analog Multiplexer
(SN74F257N)
Speaker
(CLS0261MAE-L152)
Audio Cable
(AK203/MM)
Audio Jack
(STX-3120-3B)
16MHz Crystal
(ECS-160-20-4XDN)
PCB
Digikey
0.96
0.33
1
0.96
Digikey
0.98
0.37
3
2.94
Digikey
14.95
N/A
1
14.95
Adafruit
5.95
4.76
1
5.95
Digikey
0.70
0.29
1
0.70
Digikey
5.16
2.36
2
10.32
Digikey
2.61
1.45
1
2.61
Mouser
1.18
0.64
1
1.18
Digikey
0.70
0.40
1
0.70
PCBWay
33.0
1.0
2
66.0
Resistors, Capacitors
Total
Digikey
-
0.31
-
0.005
32.28
18
-
5.60
114.91
*Note: The bulk-purchase costs are based on 1000 quantities for each component and the retail cost is
based on 1 quantity for each component.
11
4.2 Labor
Table 4.2 Labor Costs
Hourly
Rate
Hours Invested
Tae Hun Ahn
$40/hr
156
$15,600
Daniel Bang
$40/hr
156
$15,600
Yoon Mo
Yang
$40/hr
156
$15,600
468
$46,800
Name
(12 weeks *
13hrs/week)
Total
Labor Total (2.5 * Hourly Rate * Total
Hours)
As shown in Table 4.2, the total labor cost is $46,800. The overall cost of this project, therefore, is
$114.91 + $46,800 = $46,914.91. It’s important to compare the actual cost with the bulk-purchase cost
in Table 4.1. The bulk purchase will reduce the cost by 72%. Therefore, if we mass-produce our
headphones, the amount of money that costs to manufacture the PCB will significantly decrease.
4.3 Grand Total
Table 4.3 Grand Total
Type
Total ($)
Parts Costs
114.91
Labor Costs
46,800
Grand Total
46,914.91
12
5. Conclusion
5.1 Accomplishments
At the end, we successfully built an entire circuit that could verify all the functionalities except for the
changed subcomponent, volume control module, from the design review. The end product showed a
feasible precision on the Fast Fourier Transform algorithm, compared to the MATLAB simulation. It also
filtered out the noises other than 300 ~ 400 Hz so that the accuracy of the detection was reliable.
5.2 Uncertainties
We are uncertain of the detail in range of the detection. Since the car horn sound in a real life emits
much more decibel than the car horn sound recorded in a smartphone, it was rather difficult to test the
range of functionality without an accurate decibel meter. Since we were able to confirm that the
microphone module receives a signal of a normal conversation in two meters, we assumed our
headphones to be able to detect car horn sound, which is much louder, in five meters. In order to prove
the reliability of our headphones, we have to verify this requirement in a real life before bringing the
product to the market.
5.3 Ethical considerations
During the entire project, we followed the IEEE Code of Ethics. The following is from the IEEE Policies,
Section 7 - Professional Activities (Part A - IEEE Policies). We also followed the detailed descriptions as
below.
1. To accept responsibility in making decisions consistent with the safety, health, and welfare of the
public, and to disclose promptly factors that might endanger the public or the environment.
Since our project was all about detecting “danger” around us, we always kept in mind about safety issue
while building the final product. We paid extreme care while we were soldering, and cleaned up the lab
after we were done. While we took care of the power module, we always checked if any power supply
was shorted, which might have burnt our entire circuit. Overall, we had made great decisions regarding
the safety issues.
3. To be honest and realistic in stating claims or estimates based on available data.
Most of the requirements on our project were verified through the multimeter, oscilloscope, Arduino
software (IDE), and MATLAB. Since these programs and machines were only used to show the
measurement of our result, there was no opportunity for us to change our data to seem more plausible.
By the end, we had been truly honest and realistic in stating claims.
9. To avoid injuring others, their property, reputation, or employment by false or malicious actions.
Throughout the semester, our major concern was the safety. When we made a mistake burning one of
our laptops by sourcing the current in an opposite direction, we quickly pulled out the battery wire in
case of injuring other people. After this incident, we always paid close attention on our every action.
Also, we saw some number of people in other groups got their components stolen while they were out.
13
Since we knew how painstaking it is to order new components via online, we vowed not to cause any
harmful action to hurt others in their project. Eventually, this ethical consideration was well kept in our
case.
5.4 Future work
There are four possible future works. First, we can improve our FFT running time by trying different
types of FFT libraries. There are several FFT open libraries for the Arduino, but we could not test every
single FFT libraries and check the runtime. Therefore, in the future, we would like to pick the best library
and algorithm to optimize overall performance Second, we can improve our sound quality of
headphones by using different MUX. We have researched a lot about the mux and found out that MUX
requiring negative voltage can generate much better sound quality. We, however, could not generate
negative voltage in our system so we decided to use an analog mux, SN74F257, which only required
positive voltage. Third, we can apply our system to more broad industry. For example, we can apply our
danger detecting mechanism on the car audio system. If the car detects car horns, the car can
automatically mute the car audio system so that the driver can see what is actually going on around his
or her car.
14
References
[1] How to Connect a Voltage Regulator in a Circuit [Online]. Available:
http://www.learningaboutelectronics.com/Articles/How-to-connect-a-voltage-regulator-in-a-circuit
[2] How to Build a Microphone Amplifier Circuit [Online]. Available:
http://www.learningaboutelectronics.com/Articles/Microphone-amplifier-circuit.php
[3] LM386 Low Voltage Audio Power Amplifier, National Semiconductor Corporation., Dallas, TX, 2000.
[Online]. Available: http://www.ieee.org/documents/ieeecitationref.pdf
[4] SN54F257, SN74F257, Texas Instruments Incorporated., Dallas, TX, 1993. [Online]. Available:
https://www.ti.com/lit/ds/symlink/sn74f257.pdf
[5] Arduino. “ReadAnalogVoltage.” Arduino. 21 Sept. 2016. [Online]. Available:
https://www.arduino.cc/en/Tutorial/ReadAnalogVoltage
[6] Aasvik, Mads. “Arduino Tutorial: Simple high-pass, band-pass and band-stop filtering.” Norwegian
Creations. 10 Mar. 2016. [Online]. Available: https://www.norwegiancreations.com/2016/03/arduinotutorial-simple-high-pass-band-pass-and-band-stop-filtering/
15