Multi-Timbre Harmonica
Transcript of Multi-Timbre Harmonica
i
Multi-Timbre Harmonica
By
Project Contributors (alpha order)
Jiahao Lin jlin76
Yang Shi yangshi5
Zihao Zhou zzhou35
Final Report for ECE 445, Senior Design, [Fall 2016] TA: Yuchen He
December 6th, 2016
Project No. 10
ii
Abstract
The object of the multi-timbre harmonica is to enable most of the music aficionado to play
only one musical instrument for multiple timbre. In that case, people can create music
pieces in the music timbre from instruments they don’t know how to play. The approach we
adopt to solve the problem is that we use the air pressure sensor to track the action of users
and resynthesize the music timbre in microcontroller using the method of frequency
modulation [1]. The results obtained in this research include the implementation of
frequency modulation system in programming, printed circuit board (PCB) design of three
main boards and the verification of requirements we made at the beginning of project. The
major result of our project is that we find the implementation of algorithm works perfectly
and we need to choose the sensor with higher consistency for further improvement.
iii
Contents
1. Introduction ………………………………………………………………………………………………………………… 1
1.1 Functions & Features ……………………………………………………………………………………………… 1
1.2 Block Diagram ………………………………………………………………………………………………………… 2
1.3 Block Description ……………………………………………………….…………………………………………… 2
1.3.1 Control Block………………………………………………………………………………………………… 2
1.3.2 Accessory Block …………………………………………………………………………………………… 2
1.3.3 Power Block ………………………………………………………………………………………………… 2
2. Design ………………………………………………………………………………………………………………………… 3
2.1 Control Block …………………………………………………………………………………………………………. 3
2.1.1 Push Buttons and Switch…………………………………………………………………………….... 3
2.1.2 Air Pressure Sensor…………………………………………………………………………………………4
2.1.3 Encoder and Decoder Board ………………………………………………………………………… 6
2.1.4 Programmable Microcontroller.……………………………………………………………………. 7
2.2 Accessory Block …………………………………………………………………………………………………….. 8
2.2.1 Air Tube Valve and Servo Motor .…………………………………………………………………. 8
2.2.2 Speaker ……………………………………………………………………………………………………….. 8
2.2.3 Displayer.……………………………………………………………………………………………………… 9
2.3 Power Block ……………………………………………………………………………………………………….. 10
2.4 Software Package ….…………………………………………………………………………………………… 10
2.4.1 Sound signal processing flow chart …..……………………………………………………….. 10
2.4.2 Algorithm Introduction…………..…………….…..……………………………………………….. 10
3. Design Verification …………………………………………………………………………………………………… 12
3.1 Control Block Verification …………………………………………………………………………………… 12
3.1.1 Air Pressure Sensor Verification………………………………………………………………….. 12
3.1.2 Encoder Decoder Board Verification ………………………………………………………….. 13
3.2 Power Verification ……………………………………………………………………………………………….. 13
3.3 Software and Speaker Verification ……………………………………………………………………….. 15
4. Cost …..……………………………………………………………………………………………………………………… 17
4.1 Cost analysis ……………………...…..………………………………………………………………………….. 17
4.1.1 Labor………………………………………………………….….……………………………………………. 17
4.1.2 Parts .……….……………………………………………….….……………………………………………. 17
4.1.3 Grand Total....…………………………………………….….……………………………………………. 17
5.Conclusion.…………………………………………………………………………………………………………………. 18
5.1 Accomplishments ………………………………...…………….….……………………………………………. 18
5.2 Uncertainties ………………………………………...……….….….……………………………………………. 18
5.3 Engineering Ethics …………………………………...…….….….……………………………………………. 18
5.4 Future work ……….……………………………………………………………………………………………….. 19
6. Reference ………………………………………………………….………………………………………………………. 20
Appendix ……………………………………………………………….………………………………………………………. 22
1
1. Introduction
This product is designed for the music aficionados who would like to play the melody using
different kinds of musical instruments especially when he or she does not know how to play
certain kind of instrument. Besides, it allows the them to make changes to the music score
for the part of each particular instrument on our harmonica since most users would like to
play and hear his or her inspirational idea immediately. The current solution are applications
on desktops. In comparison, our project provides a more direct and more convenient
solution. Harmonica is chosen as the carrier for this product since it is relatively easy-to-play
and more portable than other musical instruments.
For our product, the user is able to change the mode of the harmonica between the original
mode which play the music in the original harmonica timbre and the multi-timbre mode
which play synthesized sound using the chosen timbre based on inputs to the harmonica.
1.1 Functions & Features
● There are two modes in the harmonica: original mode and the multi-timbre mode.
● Visually display current timbre: Using the light-emitting diode (LED) lights to tell the
users the current chosen timbre.
● Adjustable air tube valve: The air ought to be redirected from the metal reeds using
the changeable air tube valve when the users want different timbres.
● The air pressure sensor ought to tell the difference from blowing and drawing of
users with different amplitude.
● Easy replacement for AAA battery and the voltage regulator circuit provide the
power of the whole device.
● Buttons for the user to choose the timbre.
● Switch for turning on/off the multi-timbre mode.
● One speaker to play the resynthesis sound during the multi-timbre mode.
2
1.2 Block Diagram
Figure 1. Top level block diagram
1.3 Block Description
1.3.1 Control Block
The control block consists of the air pressure sensor in each hole of the harmonica, the
switches used by users to change the modes and timbres as they wish and the
microcontroller which will receive the information from the sensors and switches and then
transmitted signals to the parts in accessory block. In addition, we add the encoder and
decoder board in order to find the sensor that is activated by the user.
1.3.2 Accessory Block
The accessory block includes servo motor, speaker and LEDs. The motor will open or close
the air tube valve with the change of mode. The speaker will generate resynthesized sound
by receiving signals from the class-D amplifier. And the LED will lighten up when the
corresponding timbre is chosen by the user.
1.3.3 Power Block
We use four AAA batteries, instead of two in the previous plan, as the power resource
because we need higher voltage for most of the components. And we add four voltage
regulators in the power block to decrease the applied voltage to four different levels for
specific requirements of the components.
3
2. Design
2.1 Control Block
The control block is going to receive the user’s commands from the feedback of the air
pressure sensor and then figure out which mode the user has chosen and which sensor the
user is using by the encoder decoder board. According to the specific mode, the control
block sends signals to the accessory block to make the correct action of each part of the
harmonica. The control block includes the push buttons, several air pressure sensors,
encoder decoder board and a programmable microcontroller which provides multiple
functionalities.
2.1.1 Push Buttons and Switch
Description: The buttons are served for the users to choose the timbre they want in
the multi-timbre mode. We are using the push buttons to get rid of the potential faults in
the hardware part. Users are going to push the buttons until they find the LED light standing
for the correct timbre name is on. Besides, the users can choose the mode to be original or
multi-timbre using the switch on one side of the harmonica.
Input: push buttons and switch triggers.
Output: Digital signal to ATmega328p [3] general-purpose input/output (GPIO) pins
on the microcontroller.
Circuit switch:
The switch is an on and off switch of the whole circuit. When the switch is on then
the whole circuit will power on so that the users can choose the mode they want.
Mode switch: (to ATmega328p pin 4)
The switch is an on/off switch of the multi-timbre mode. When the switch is on then
the mode will be the multi-timbre mode. Otherwise, if the circuit switch is on then the
default mode of the harmonica will be the original mode.
Timbre choosing buttons: (to ATmega328p pin 2 and 3)
The user is able to choose the timbre by pressing the left or right button. The LED
lights will be turned on when the corresponding timbre is chosen. The timbre choosing
button will only be activated during the multi-timbre mode. The default timbre in the multi-
timbre mode is the brass.
4
Figure 2. Button and switch schematic diagram
2.1.2 Air Pressure Sensor
Description: The air pressure sensor (2SMPP-03) [2] is used to recognize the change
of the air pressure in order to recognize the action of the user (blow or draw) since the air
pressure will have a sudden drop during the drawing and a sudden rise during the blowing.
Besides, the sensors ought to detect the magnitude of the action in several levels based on
the accuracy of the sensor. The sensor with the most significant change will be detected as
the hole which the user is currently using. We decide to use the MEMS Gauge Pressure
Sensor which can work in the temperature between 0°C and 85°C and in the humidity 95%
relative humidity (RH). The pressure range is between -50 to 50 kPa. Since the humidity of
the breathing is around 95% and the largest air pressure a person can generate is around 2
psi (around 7 kPa), the sensor suits our requirement perfectly.
Input: Air pressure on the detecting part and the atmosphere pressure in the
atmospheric pressure hole.
Output: The change of the output voltage of the sensor component.
Figure 3: Rated pressure vs. output voltage of the sensor [2]
Since the output voltage of the air pressure sensor is in the range of -50 mv to 40 mv,
according to the rated pressure in the tube, the output voltage may have a large error rate.
5
In that case, we will use an amplifying circuit in figure 5 to increase the output voltage of the
sensor to make the detection of the peak voltage more accurate.
The circuit in figure 4 is about how to make a current source (100 μADC) which is
required in the datasheet of the air pressure sensor [2].
Calculation: Icc = 5 V*(R2/(R1+R11+R2))/R3 = 10-4 A.
Where R2, R1, R11 and R3 are resistor in figure 4 below.
Figure 4. Air pressure sensor circuit
Figure 5. Sensor output voltage amplifying circuit
Through the amplifying circuit above, we can amplify the output voltage of the air pressure
sensor so that we can tell the difference between the actions with different magnitude
more easily. For the purpose of this application, R9 is changed to 470 kΩ, which makes the
final amplification gain to be 941. The calculation function is included in the figure 6 in the
next page. We also change the reference voltage to be 3.3 volts so that the stable voltage
output of the sensor circuit will be 2.7 volts.
6
Figure 6. Calculation of gain [4]
2.1.3 Encoder and Decoder Board
Description: The encoder and decoder board is made up of three parts: voltage
comparator, encoder and analog multiplexer. Ten analog signals from sensor boards will be
the input and the voltage comparators will determine if the sensor is activated or not. Since
the stable output voltage of the sensor is 2.7 volts, if the output voltage is higher than 3.3
volts then it means the user is blowing this sensor. And if the output voltage becomes lower
than 2.5 volts then it means the user is drawing this sensor. In these two cases, the sensor
need to be marked as activated. The encoder will give the number of the sensor to the
multiplexer and multiplexer will send the signal of that sensor to the microcontroller in the
end.
Input: Ten air pressure signals and the reference voltages required by the voltage
comparator
Output: 4-bit selection bits to show the number of chosen sensor and the signal of
that sensor to the microcontroller
Ten analog signals will be sent to voltage comparators first. When the output voltage
of a sensor is larger than upper bound reference voltage (3.3 volts) or smaller than lower
bound voltage (2.5 volts), the NOR gate of that sensor will give a logic zero to the encoder to
show that this sensor is activated.
Figure 7. Voltage comparator circuit
If one of the input of the priority encoder becomes zero, then the encoder will create
the corresponding selection bits (4 bit) of that sensor and send them to the analog
multiplexer and the microcontroller as well. For the detailed table of the selection bit,
please refer to Appendix A. Finally, the 16-channel analog multiplexer will send the signal of
the chosen sensor to the microcontroller.
7
Figure 8. schematic of the priority encoder
Figure 9. schematic of CMOS LOGIC 16-CHANNEL ANALOG MULTIPLEXER [6]
2.1.4 Programmable Microcontroller
Description: The programmable microcontroller (ATmega328p) is the core of the
control block. It takes the signal from the buttons and sensors, gets the pitch and amplitude
information and then process them with the signal processing technique to put them into a
different timbre. It will also control the corresponding LED light to be turned on and make
the servo motor to turn on or off the air tube valve. Finally, the microcontroller will make
the speaker produce the corresponding sound using the specific timbre.
Input: 1.8 V to 5.5 V power input, buttons and switch status bits, output voltage of
all ten sensors in the holes of the harmonica.
Output: Commands to activate the servo motor to change the direction of the air
tube valve, commands to change the turned-on LED light according to the button action of
the user, the final resynthesis digital signal sound to the speaker module.
We chose ATmega328p as the microcontroller because it is easy to program using
the same language as Arduino. Figure 10 below is the schematic of circuits around
microcontroller. For detailed ATmega328p pinout table, please refer to Appendix B.
8
Figure 10. Schematic of microcontroller circuit
2.2 Accessory Block
The accessory block contains all components that work with the order coming from
the microcontroller. It includes the displayer (or LED lights), air tube valve and the speaker.
They receive signals from the controller block and perform the corresponding functionalities
by displaying the timbre information, turning the servo motor to operate the air tube valve
or generating the required sounds with the desired pitch and amplitude.
2.2.1 Air Tube Valve and Servo Motor
Description: The air tube valve will change the direction of the wind blowing to or
drawing from the harmonica. Since the designed harmonica has two modes: original mode
and the multi-timbre mode, the harmonica should make the original timbre of the
harmonica when it is in the former mode and it must be mechanically silence in the later
mode. In that case, the air tube valve holds the functionality that it is able to change the
direction of the wind in the multi-timbre mode so that there will be no wind pass the metal
reeds which means there will be no original sound any more. In the original mode, the valve
should not be activated so that the harmonica will behave like a traditional one. In our
project, we will use a bipolar servo motor to operate the valve since we only need the valve
to be either open or close. The working voltage of the motor is around 4.8 V to 6 V. And the
torque that the motor could provide is 19 oz/in which is more than enough to turn our
valve.
In figure 11, air tube valve is shown in red circle and the motor is in blue circle.
Input: The pulse width modulation (PWM) signal from the microcontroller to tell the
motor the angle information.
Output: The motor will close the valve of the harmonica if the signal shows that the
user wants the multi-timbre mode. Otherwise, the valve will be open in default.
9
2.2.2 Speaker
Description: The speaker is going to make the specific sound using the timbre which
the user wants when the harmonica is in the multi-timbre mode. When it is in the original
mode, the speaker should be turned off to get rid of the potential noise and save power.
The pitch range of the harmonica is between C3 to C6 which is 131 Hz to 1000 Hz.[5] The
speaker module is in green circuit in the figure 11.
Input: analog sound signal from the class-D amplifier.
Output: Sound with the chosen pitch and the correct timbre.
Figure 11. Photo of the overview design
2.2.3 Displayer
Description: We are going to use the three LED lights to tell the user which timbre is
currently used and another one LED light to show the current mode of the harmonica. There
will be the corresponding name of the timbre beside each LED light. When the user press
the arrow-shaped button, the LED light will be turned on circularly. The mode light will be
on when the multi-timbre mode is on.
Input: Digital signal from the microcontroller to choose which LED will be turned on.
Figure 12: LED and microcontroller
10
2.3 Power Block
Description: The Power Block provides power for all other blocks in the harmonica. It
consists a switch and a battery. The switch is for users to turn on when they want to use the
multi-timbre mode since the default original mode of the harmonica can be used without
the power block. The battery is the main power source. And we are going to use AAA
batteries. Besides, we are going to use the voltage regulator to change voltage level while
lower voltage is required by some blocks such as the voltage comparator and most of
components in the circuit.
Input: +6.0 V, AAA batteries * 4 (1.5 V each)
Output: +5.0 V±5% for most of components in the circuit including microcontroller
+6.0 V±5% for Stereo 3.7 W Class D Audio Amplifier
+5.0 V±5% for pressure sensor and voltage regulator
+3.3 V±5% and + 2.5 V±5% for voltage comparator
-5.0 V±5% for operational amplifier.
For further power consumption calculation, please refer to Appendix C.
2.4 Software Package
2.4.1 Audio signal processing flow chart
Figure 13. software flow chart
2.4.2 Algorithm Introduction
This algorithm is implemented using “unit generators”: oscillators, adders, and function
generators. The block diagram that shows the implementation of frequency modulation to
produce dynamic audio spectra is shown below. Unit generators 4 & 5 are envelope
11
functions. They specify the envelope of the output signal and the envelope of the
modulating wave. Different envelopes are used to achieve different types of instrument
sounds. The following figures are the reference of the introduction part of the cited
article.[1]
We built the following formula for the frequency modulation of the timbre:
Where:
According to the paper of Chowning, we are able to use the means of the frequency
modulation to synthesize the complex audio timbre. In FM, the instantaneous frequency of
the carrier wave is changing according to the modulating wave. When the modulation index
is greater than 0, there will be side frequency beside the carrier frequency which will take
the partial energy from the carrier frequency.
In order to implement the whole system, we are going to take the note duration from the
sensor. The time period when the output voltage of the sensor is above the threshold
voltage will be set to be the note duration. The exact threshold voltage will be determined
after more test on the air pressure sensor. In addition, the carrier frequency depends on
number of the activated sensor and the action of the user. The amplitude of the sensor will
be decided by the voltage level of the sensor output. The modulation index and the
modulation frequency will be different between two kinds of instruments. Therefore, they
will be stored in the timbre file with the envelope shape information saved in the
microcontroller.
Figure 14. Harmonica notes (from C3 to C6) [8]
12
3. Design Verification
In each block of our system, we have specific requirements in order to ensure the whole
system performs correctly. We list several most important requirements and the
corresponding verification procedures in each block below. For a list of detailed
requirements and verification table please refer to Appendix D.
3.1 Control Block Verification
The most important requirements of the control block are the ones about the sensor part
and the encoder decoder board. The sensor needs to tell the difference from blowing and
drawing and it ought to work well in the required humidity. In addition, the encoder
decoder board should be able to give the correct 4-bit selection bit after gathering
information from the sensor voltage output.
3.1.1 Air Pressure Sensor Verification
1) Requirement: sensor is able to tell the difference from blow, draw and rest
condition, the voltage comparator requires sensor output to have a voltage range
Verification Process:
1. Connect the oscilloscope probe to the output of the pressure sensor
2. Record the sensor output
3. Ensure the output is in between 3.3V and 2.5V
4. Blow air to reach around 2psi to the pressure sensor
5. Record the sensor output
6.Ensure the outputs increases from base voltage and the output is higher than 3.3V
7. Draw air to reach around 2psi to the pressure sensor
8. Record the sensor output
9.Ensure the outputs decrease from base voltage and the output is smaller than 2.5V
but greater than 0V
Base Voltage Draw Blow
1st time 2.61 1.10 4.30
2nd time 2.78 1.98 3.89
3rd time 2.78 1.56 3.20
Table 1. Verification of sensor output in blowing and drawing
See appendix E for plot result
13
2) Requirement: sensor maintains accuracy at human breath humidity (95% humidity)
Verification Process:
1. Connect the oscilloscope probe to the output of the pressure sensor and
2. Blow and draw air to reach around 2psi
3. Use humidifier to change room humidity to 95%.
4. Repeat step 2
5. Verify the sensor has a +- 10% error in humid condition compared to the baseline
value
Base Voltage Draw Blow
1st time 2.97 2.22 3.46
2nd time 2.92 2.04 3.36
Table 2. Verification Process for Item 1: Baseline (42.5% humidity)
Base Voltage Draw Blow
1st time 2.92 2.28 3.39
2nd time 2.89 1.98 3.24
Table 3. Verification Process for Item 1: 95% humidity
3.1.2 Encoder Decoder Board Verification
1) Requirement:
Verification Process:
1. Check the output signal of the encoder which stands for the number of the activated sensor. 2.Do multiple test and the correct rate should at least 90%
3. Blow and draw air to above 3.3V and lower than 2.5V but greater than 0V
4. Check the amplitude of the output waveform from the microcontroller. The amplitude ought to be different. The range is that 0-0.8V for high draw ,0.8V-2V for medium, draw 2V-2.5V for low draw. 3.3V-3.8V low blow, 3.8-4.5V medium blow 4.5V-6V high blow
See appendix A for Quantitative result
3.2 Power Verification
For power block requirements, we need to make sure that the output voltage of the voltage
regulator fulfills the requirements of the components. In addition, the overall power
consumption is small enough so that the whole system can run more than two hours.
14
1) Requirement: Convert 6 volts input (4 AAA Batteries) to 2.5 volts, 3.3volts, 5 volts, and -5
volts.
Verification Process:
1. Put the probes of oscilloscope at the input of the 5V voltage regulator 2. Put the probes of oscilloscope at the output of the 5V voltage regulator
3. Ensure the input voltage is above 6V
4. Ensure the output voltage is 5V
5. Repeat the step1, step2 and step 6 to 3.3V voltage regulator 6. Ensure the output voltage is 3.3V
7. Repeat the step1, step2 and step 6 to 2.5V voltage regulator 8. Ensure the output voltage is 2.5V
9. Repeat the step1, step2 and step 6 to -5V voltage regulator 10. Ensure the output voltage is -5V
Voltage(Volts)
Battery Input 6.18
2.5V voltage regulator 2.51
3.3V voltage regulator 3.43
5.0V voltage regulator 4.98
-5.0V voltage regulator 5.42
Table 4. Voltage regulator table
Everything fulfills the requirement except for the -5V voltage regulator. This is due to the
incorrect circuit design at voltage input and ground.
2) Requirement: harmonica should be able to stay on for two hours
Verification Process:
1. Turn on the harmonica 2. Measure rest current for motor 3. Measure rest current for speaker 4. Turn on harmonica mode 5. Measure operation current for motor 6. Using microcontroller to play C6 pitch on speaker
7. Measure operation current for speaker 8. Measure operation current for microcontroller 9. Calculate the overall power consumption 10. Ensure 4 AAA batteries can provide enough power to the device for 2 hour
Peak Rest
Speaker 2.81mA 2.54mA
15
Motor 31.25mA 3.1mA
LED 0.32mA 0mA
Microcontroller 0.2mA 0.1uA
Table 5. Main components peak current table
Assuming all components are at peak current.
2.81+31.25+0.32+0.2 = 34.58mA * 2hr =69.16mAh
One AAA battery contains 1000mAh. The power supply contains in total of 4000mAh
3.3 Software and Speaker Verification
1) Requirement on software: the algorithm is able to resynthesize same pitches with
different timbre.
Verification Process:
1. Using the Matlab to output the envelope shape we need three different timbres. 2. Compare with the envelope shape in Prof Chowning’s paper [1].
Figure 15 - 17. Envelope shape of three kinds of timbre
Please refer to Appendix F for the envelope shape in Prof Chowning’s paper.
2) Requirement on software: the algorithm should be able to resynthesize pitches from
C3(130.8Hz) to C6(1046.5Hz)
3) Requirement on speaker: the speaker should be able to play pitches from
C3(130.8Hz) to C6(1046.5Hz) above 60 dB
Verification Process for 2):
1. Use the Matlab to produce the sound generated by the microcontroller according to different pitches from C3 to C6 to show that the algorithm actually work in the project. 2. Blow through the original harmonica and use iphone application ‘guitar tuner’ to test the output sound frequency in that pitch. 3. Refer to [5] for the theoretical frequency of that pitch
4. Do multiple times for different kinds of pitches.
16
Physical Frequency(Hz)
Harmonica Frequency(Hz)
Measured Frequency(Hz)
1st time(C3) 130.81 130.8 129.7
2nd time(D3) 146.83 145.6 144.5
3rd time(E3) 164.81 162.9 163.2
4th time(G3) 196.00 194.4 193.8
5th time(D4) 293.66 288.6 290.3
6th time (G4) 392.00 390.6 386.4
7th time (A4) 440.00 430.4 433.1
8th time (C5) 523.25 518.5 513.9
9th time(E5) 659.25 652.4 645.9
10th time(G5) 783.99 770.3 766.2
11th time(C6) 1046.5 1011.4 1018.5
Table 6. Theoretical frequency vs. harmonica frequency vs. speaker frequency
Verification Process for 3):
1. Use the Matlab to produce the sound generated by the microcontroller according to different pitches from C3 to C6 and use the iphone application to test the intensity of that pitch. 2. Do multiple times for different pitches and make sure that measured frequency will be larger than 60dB at any frequency available in the harmonica.
Play Frequency(Hz) Measured Intensity
1st time 257.8 62dB
2nd time 324.6 64dB
3rd time 433.1 65dB
4th time 645.8 66dB
5th time 859.7 69dB
Table 7. Speaker intensity with different frequency
17
4. Cost
4.1 Cost Analysis
4.1.1 Labor
Name Hourly Rate Total Hours Total = Hourly Rate *
2.5 * Total Hours
Jiahao Lin $25 150 $9375
Yang Shi $25 150 $9375
Zihao Zhou $25 150 $9375
450 $28125
Table 8: Labor Cost
4.1.2 Parts
Please refer to Appendix G for detailed parts list
4.1.3 Grand Total
Section Cost
Labor $28125
Parts $349.81
Grand Total $28474.81
Table 9: Total Cost
18
5. Conclusion
5.1 Accomplishments
There are three main type of PCB for this project: pressure sensor board, encoder
decoder board and power and microcontroller board. We have ten pieces of pressure
sensor board. The pressure sensor board is able to transfer user input to electronic signal to
tell microcontroller whether the user is blowing or drawing from the air tube and at what
level of intensity. Our encoder and decoder board succeed in passing the correct signal from
ten sensor signals to the microcontroller. Our microcontroller board has various tasks. We
accomplish to drive the motor at designed angle with it and fulfill our goal to play music on
our speaker with it. For the software part, we are able to resynthesis timbres for three
instruments: flute, bell, brass. In addition, we manage to control the three LEDs on our
product which indicate which timbre is on.
5.2 Uncertainties
Even though most parts are functioning correctly, there are several parts remain
uncertain. First, the source of noise for each sensor board is uncertain. This is a potentially
major reason for our product failing to work. Other than that, it is unclear why the -5 volts
voltage regulator circuit needs to be isolated from other voltage regulator which only differs
in voltage output. Another minor uncertainty is our project is voltage range detection is not
perfect. Specifically, in our voltage comparator circuit, we use 2.5 volts as our lower bound
threshold voltage. However, the output of the voltage comparator is sometimes not correct
until the voltage input drops to around 2.3 volts. The same issue applies to our higher bound
voltage threshold as well. It is uncertain that if it is a gate delay problem or circuit design
error.
5.3 Engineering Ethics
IEEE Code of Ethics [7]:
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;
Our product is for music aficionado to play multiple timbres in one instrument, so it is
our priority concern that the product is free from threat to music aficionado’s health and
safety. With this consideration in minds during the whole design and manufacture process,
our final product is very friendly to the environment as well as public safety. All the
components are mounted or soldered and are tested so that it has no harm to the users.
3. to be honest and realistic in stating claims or estimates based on available data;
19
We do not intent to deceive users or make any conclusion without solid supporting
evidence. We conduct a series of experiments and tests in order to substantiate all the
claims we make. We work with absolute integrity and have zero tolerance on counterfeit
data and ambiguous statement.
5. to improve the understanding of technology; its appropriate application, and
potential consequences;
Although our design and product are appreciable as a prototype, the market version
should have some improvements with respect to portability since we want our product to
be user-friendly. We would shrink the size of the product and cut the cost to make it more
feasible. And with these developments our product would be able to maintain technical
competence.
7. to seek, accept, and offer honest criticism of technical work, to acknowledge and
correct errors, and to credit properly the contributions of others;
Successful completion of our project involves not only our deliberate teamwork but also
our professional attitude towards criticisms. We acknowledge comments and criticisms from
professors, TAs, and our peers humbly and apply them to improve our project. We also
offer our suggestion as well as positive feedbacks to peers during peer reviews and
discussions. In addition, we appreciate all the people who provide us help when we are in
dilemma.
5.4 Future work
Since our product does not attain the desired effect, the primary work is to fix all the
problems of the product. There are several parts which need some modification. As it is
mentioned in Section 5.2, the -5 volts voltage regulator needs to be isolated from other
regulators to use its own ground and 6 volts input voltage. Also, the inconsistency across
different sensors is a problem to the decoder and encoder block. A reasonable fix to this
problem is either provide tunable reference voltage to each pressure sensor to adjust the
base voltage level or change the higher and lower threshold voltage in the voltage
comparator circuit for each pressure sensor. Moreover, the class-D amplifier used in this
project can only be changed manually to adjust the amplitude. It is better to have an
amplifier circuit which can be changed from software. The product can also be improved
with some other features. To increase the portability of this product, it is necessary to
reduce the size of the circuit board and package the circuit in a more concise fashion. For
now, the product use 8-bit to store the sound. The sound produced by the speaker is thus
not up to a high quality. In future, it is better to have 16-bit sound. Finally, even though this
product includes three major instruments, it is always better to have more instrument
timbres available to users so the music composition is less limited.
20
6. Reference
[1] Chowning, John M. "The synthesis of complex audio spectra by means of frequency
modulation." Journal of the audio engineering society 21.7 (1973): 526-534.
[2] 2SMPP-03 MEMS Gauge Pressure Sensor Retrieved September 20,2016 from
https://www.omron.com/ecb/products/pdf/en-2smpp-03.pdf
[3] ATmega328P microcontroller datasheet. Available at:
http://www.atmel.com/images/Atmel-8271-8-bit-AVR-Microcontroller-ATmega48A-48PA-
88A-88PA-168A-168PA-328-328P_datasheet_Complete.pdf
[4] Usage of pressure sensor 2SMPP-03. Available at:
https://www.omron.com/ecb/products/sensor/special/mems/pdf/AN-2SMPP03-
01EN_r1.pdf
[5] S. B. H., "Physics of Music,". [Online]. Available at:
http://www.phy.mtu.edu/~suits/notefreqs.html. Accessed: Sep. 20, 2016.
[6] CMOS LOGIC 16-CHANNEL ANALOG MULTIPLEXER datasheet available at:
http://www.ti.com/lit/ds/symlink/cd74hct4067-q1.pdf
[7] IEEE Code of Ethics. Available at:
http://www.ieee.org/about/corporate/governance/p7-8.html
[8] Harmonica Notes. Available at:
http://harmonicatunes.com/harmonica-notes/
21
Appendix A
Input Number
represented
S3 S2 S1 S0
Sensor 1 0 L L L L
Sensor 2 1 L L L H
Sensor 3 2 L L H L
Sensor 4 3 L L H H
Sensor 5 4 L H L L
Sensor 6 5 L H L H
Sensor 7 6 L H H L
Sensor 8 7 L H H H
Sensor 9 8 H L L L
Sensor 10 9 H L L H
No Input 15 H H H H
Table 10. Encoder selection bits’ table
22
Appendix B
Pin Function Connection
1 Reset signal, active low To reset button
2 Digital GPIO pin To timbre choosing button (left)
3 Digital GPIO pin To timbre choosing button (right)
4 Digital GPIO pin To mode switch
11 OC0B Motor (PWM)
12 O0CA Sound (PWM)
7, 20 Vcc/AVcc, digital/analog voltage supply
To regulated supply from the power block
8, 22 GND To ground supply
15, 16,17 Digital GPIO pin LED
18, 19 Digital GPIO pin User action
24, 25, 26, 27 Digital GPIO pin Sensor number (4 digits)
21 AREF, analog reference voltage
To regulated supply from the voltage block
23 ADC 0 To air pressure sensor information from the MUX
Table 11: Pinout table for the ATmega328p to other component
23
Appendix C
Power supply: 4 AAA Batteries, 4 * 1000mAh = 4000mAh
Power consumption:
Load Current (Active) Current (Rest)
Speaker 2.8mA 2.5mA
Motor 31.3mA 3.1mA
Microcontroller 0.2mA 0.1uA
LED 0.2mA 0mA
Pressure Sensor 0.1mA 0.1mA
Total 34.6mA 5.7mA
Table 12: Power consumption with different modes
Table 4 shows the power consumption of the main components of our project in
active and rest modes. Our goal is to maintain at least 2-hour performance of the project
under active modes. The calculation is shown as follow:
Total hours: 4000mAh/34.6mA = 115.6h
24
Appendix D
Requirement Verification Points
1 Air Pressure Sensor
Voltage Range In order to tell the difference from blow, draw and rest condition, the voltage comparator requires sensor output to have a voltage range
1. Connect the oscilloscope probe to the output of the pressure sensor 2. Record the sensor output 3. Ensure the output is in between 3.3V and 2.5V 4. Blow air to reach around 2psi to the pressure sensor
5. Record the sensor output 6.Ensure the outputs increases from base voltage and the output is higher than 3.3V
7. Draw air to reach around 2psi to the pressure sensor
8. Record the sensor output 9.Ensure the outputs decrease from base voltage and the output is smaller than 2.5V but greater than 0V
10
2 Air Pressure Sensor
Consistency
1. All sensors should be consistent with each measurement
2. All sensors should be consistent with other sensors
Verification Process for Item 1: 1. Connect the oscilloscope probe to the output of one pressure sensor 2. Blow and draw air to reach around 2psi 3. Record the sensor output 4. Ensure the difference between each output is within 10% error
Verification Process for Item 2: 1. Connect the oscilloscope probe to the output of one pressure sensor
2. Blow and draw air to reach around 2psi 3. Record the sensor output
4. Connect the oscilloscope probe to the output of another pressure sensor
5. Ensure the difference for the same input between each output is within 10% error
10
25
3 Air Pressure Sensor
Tolerance Environment tolerance to 95% humidity
1. Connect the oscilloscope probe to the output of the pressure sensor and
2. Blow and draw air to reach around 2psi 3. Use humidifier to change room humidity to 95%. 4. Repeat step 2
5. Verify the sensor has a +- 10% error in humid condition compared to the baseline value
5
4 Air Tube Valve
State Feedback
The valve ought to finish the operation within 2 seconds. 1 second is the limit for users’ flow of thought to stay uninterrupted for software application. Since air tube valve has hardware component, doubling the wait time should be acceptable
1. Power the system
2. Turn on multi-timbre mode
3. Record the time it takes to close the valve 4. Turn off multi-timbre mode
5. Record the time it takes to open the valve with a timer 6. Ensure the time for both operations are under 2 seconds
5
5 Air Tube Valve
Servo Motor
The motor reacts to the microcontroller signal and is able to rotor 90° through various steps both in clockwise and counterclockwise direction corresponding to the signal given by the microcontroller
1. Power the microcontroller and the servo motor
2. Use the microcontroller to send out analog signal to servo motor and makes it turn clockwise 90° angle
3. Ensure the servo motor has turned 90° clockwise after the signal 4. Use the microcontroller to send out signal to servo motor and makes it turn counterclockwise 90° angle
5. Ensure the servo motor has turned 90° counterclockwise after the signal
5
6 Air Tube Valve
Air Tunnel Air tunnel closes and blocks air from the original harmonic sound pieces.
1. Power the microcontroller and the servo motor 2. Use the microcontroller to send a signal to close the air tunnel 3. The tunnel is then closed by the servo motor 4. Blow to the air tunnel 5. Ensure no sound should come out of the harmonica
5
26
7 Displayer
Button
1.Buttons are correctly debounced buttons
2. Buttons change the mode of the harmonica
Verification Process for Item 1: 1. Connect buttons to the microcontroller 2. Power the microcontroller 3. Slide the slide button
4. Ensure the slide action only change harmonica mode by only one
Verification Process for Item 2: 1. Connect buttons to the microcontroller 2. Power the microcontroller. 3. Slide the move-left slide button
4. Ensure the mode is changed to the one on the left
5. Slide the move-right slide button
6. Ensure the mode is changed to the one on the right
5
8 Displayer
LED
LEDs correctly display corresponding states in microcontroller with series voltage under 2V +/- 0.2V.
1. Connect the LEDs to the microprocessor 2. Attach the oscilloscope probe to check the voltage across to the LEDs
3. Power on the microprocessor and LED 4. Ensure the power led lights up
5. Ensure only one of the state LEDs should be on at a certain time 6. Change the mode of the harmonica by modifying
microcontroller state variable
7. Ensure the corresponding LED light up and the previous state LED turns off 8. Ensure the voltage is under 2V +/- 0.2V during all operations above
5
9 Microcontroller
Output Voltage and Current Level
4 analog outputs and 2 digital outputs(0.3V to 6V for speaker, 4.8V to 6V for servo motor).
1. Connect the LEDs, motor, speaker, pressure sensors and buttons to the microprocessor 2. Power the microprocessor 3. Use the microprocessor to take digital input from buttons, analog input from pressure sensors
4. Use the microprocessor to send digital output to LEDs, analog output to speaker
5. Attach probe to the servo motor voltage input
6. Ensure the voltage output for the servo motor is within 4.8V to 6V
7. Attach probe to the servo speaker voltage input
8. Ensure the voltage output for speaker is within 0.3V to 6V
5
27
10 Microcontroller
Signal processing
1. Three default timbre sound should be stored in the memory. 2. The program can resynthesize the correct sound.
1. Using the Matlab to output the envelope shape we need three different timbres.
2. Use the Matlab to produce the sound generated by the microcontroller according to different pitches from C3 to C6 to show that the algorithm actually work in the project.
10
11 Microcontroller
Data reading
1. Read the data from the correct hole (90% accuracy) 2. Read the data and categorize to 3 different amplitude levels
1. Check the output signal of the encoder which stands for the number of the activated sensor. 2.Do multiple test and the correct rate should at least 90%
3. Blow and draw air to above 3.3V and lower than 2.5V but greater than 0V
4. Check the amplitude of the output waveform from the microcontroller. The amplitude ought to be different. The range is that 0-0.8V for high draw ,0.8V-2V for medium, draw 2V-2.5V for low draw. 3.3V-3.8V low blow, 3.8-4.5V medium blow 4.5V-6V high blow
10
12 Power
Voltage Regulator
The whole system need various steady voltage value. Using 4 AAA batteries as power supply and create required voltage source to other components
1. Put the probes of oscilloscope at the input of the 5V voltage regulator
2. Put the probes of oscilloscope at the output of the 5V voltage regulator
3. Ensure the input voltage is above 5V
4. Ensure the output voltage is 5V
5. Repeat the step1, step2 and step 3 to 3.3V voltage regulator
6. Ensure the output voltage is 3.3V
7. Repeat the step1, step2 and step 3 to 2.5V voltage regulator
8. Ensure the output voltage is 2.5V
9. Repeat the step1, step2 and step 3 to -5V voltage regulator
10. Ensure the output voltage is -5V
5
28
13 Power
2 hour on system power supply
The harmonica should be able to stay on for several hours as users may try to compose music. The sensors should give consistent measurement over the target period of time.
1. Turn on the harmonica 2. Measure rest current for motor
3. Measure rest current for speaker
4. Turn on harmonica mode 5. Measure operation current for motor
6. Using microcontroller to play C6 pitch on speaker
7. Measure operation current for speaker
8. Measure operation current for microcontroller
9. Calculate the overall power consumption 10. Ensure 4 AAA batteries can provide enough power to the device for 2 hour
5
14 Speaker
Loudness
Speaker must be able to produce sound above 60 dB at 260 Hz(260 Hz is the lowest frequency that our harmonica can produce
1. Connect the speaker to the microcontroller 2. Power the speaker and the microcontroller
3. Use the microcontroller to output a music note with 260 Hz frequency
4. Set the intensity to maximum if needed. 5. Measure the sound intensity with noise detector 6. Ensure the intensity is above 60 dB. 7. If not, add a non-inverting amplifier
8. change the gain of the amplifier so that the requirement is met.
5
15 Speaker
Frequency range
Speaker must be able to produce sound at frequency ranges from 260 Hz to 1000 Hz(low and high limit of our harmonica) and reaches 60 dB
1. Connect the speaker to the microcontroller 2. Power the speaker and the microcontroller
3. Use the microcontroller to output a music note with 260 Hz frequency
4. Set the intensity to maximum if needed. 5. Measure the sound intensity with noise detector 6. Ensure the intensity is above 60 dB. 7. Increase the frequency by 100 Hz
8. Set the intensity to maximum if needed. 9. Measure the sound intensity with noise detector 10. Ensure the intensity is above 60 dB. 11. Repeat Step 7 to Step 10 until the frequency exceeds 1000 Hz
10
Table 13. Requirement and Verification Table
29
Appendix E
Figure 15. first time blowing
Figure 16. First time drawing
Figure 17. Second time blowing
Figure 18. Second time drawing
30
Appendix F
Figure 19. Envelope shape of brass
Figure 20. Envelope shape of flute
Figure 21. Envelope shape of bell
31
Appendix G
Part Name Unit Cost Quantity Total Cost
Atmel atmega328p $3 2 $6
Adafruit 3’’ Diameter
4Ohm 3 Watt Speaker
Adafruit 1314
$2
1
$2
AAA battery $0.45 10 $4.5
Battery holder $2 2 $4
Air tube valve
from machine shop
~$10
1
~$10
LED $0.35 10 $3.5
Suzuki Harmonica
Model 1072C
$18 1 $18
Omron pressure
sensor
2SMPP-03
$4.5 35 $157.5
Toggle Switch SP3T $5 1 $5
Various resistors,
inductors, capacitors,
etc
~$40
1
$40
Voltage regulator
MIC5219
$0.89 19 $16.91
Voltage regulator
MIC5270
$1.54 10 $15.4
Voltage comparator
MAX907
$3.341
11
$36.75
Op-amp
LM358D
$0.296 30 $8.88
Multiplexer
74HC4067D
$0.585 2 $1.17
Priority encoder
SN54HC148
$0.44 5 $2.2
32
Adafruit Stereo 3.7W
Class D Audio
Amplifier
MAX98306
$9 1 $9
Sparkfun DSP75
Programmable Digital
Sub-micro Servo
Motor
$9 1 $9
Total $349.81
Table 14. Detailed Part list