Lab 2: Optical Theremin - Sites at Penn State

advertisement
Lab 2: Optical Theremin
EE300W Section 3
Team Globo Gym
Pawan Murthy, Kevin Minton, Jake Deffibaugh
Abstract
Lab 2 focused on developing an Optical Theremin using photodiodes and LabVIEW code. The
theremin had to be controllable by the user. The circuit design was the easy part; however, the
coding for LabVIEW proved to be a challenging obstacle. The circuit consisted of two
photodiodes connected to an op-amp functioning as a current-voltage converter. The circuit
outputted two signals that are read by the MyDAQ. Once the signals are read, the LabVIEW
code would modify the signal. In order for it to work correctly, the input signals had to be broken
down into frequency and amplitude controls to create a sine wave. Overall, the user will be able
to control the frequency range, the volume and the gain of the diodes. However, the more
features we add, the more complicated the code, so it was wise to be kept as simple as possible.
Introduction
In this project, the main goal is to create an Optical Theremin through LabVIEW and
photodiodes. A normal theremin is a musical instrument whose volume and pitch can be
controlled by moving an object closer to/further away from the photodiodes. It requires no
physical contact. The Theremin this lab asks to create will measure the current produced by the
photodiodes and use this with LabVIEW to process the signals to create a sinusoidal audio wave,
which is outputted by the MyDAQ. By controlling the amount of light entering the photodiodes,
the pitch and volume and can be controlled. One of the other requirements is to allow the user to
see the amplitude and frequency ranges seen by each diode. Also visible to the user is the range
of audio tunes generated.
The design requirements for this project are to generate a sinusoidal audio signal from the
MyDAQ and design the ability to adjust the amplitude and frequency ranges of the audio signal
using LabVIEW’s front panel. Since sub VIs are being used, there will be additional front panels
for auto tune, amplitude, and frequency; however, all these will be incorporated in the main VI,
and thus appear on the front panel of the main VI. Some of the defined requirements include
having an adjustable maximum and minimum light intensity for each diode, a front panel wave
graph that displays the normalized pitch as a function of time, and a normalized amplitude
(volume) wave graph that also displays as a function of time. Another graph to display the light
intensity should also be included on the front panel.
For the next part of the lab, an auto tune feature is to be created for the Optical Theremin. The
point of this feature is that it will tune a specific pitch to a tone in the same tempered scale. This
feature can be toggled on or off by the user on the LabVIEW front panel.
Optical Theremin Theory
In this lab we use a light to voltage circuit to create a sine wave audio output. The photodiode
does the conversion, but an op-amp and resistors are also used. When light shines on the
photodiode, holes and electrons inside the semiconductor generate a current. The current is then
transformed using the op-amp, resulting in a voltage.
The photodiode current can be calculated using I = RL: where I is the current, L is the power and
R is resistive property of the semiconductor diode. The op-amp takes the current and converts it
into a voltage by using ohms law (V=IR). Here, I is the input current and R is the resistivity of
the feedback resistor. By putting them together, the output voltage equation can be derived in
terms of power and optical sensitivity, V=R*L*Rf (Rf is feedback resistor). The output of the opamp is connected to analog channels of the MyDAQ, where the signals are processed.
The signals are then converted into MyDAQ inputs for the LabVIEW code. The voltages are
normalized and coerced. This outputs a value between 0 and 1 according to the intensity of the
voltage. The normalized value is then changed according to the user inputs. The sine wave
generator then uses the scaled values of voltage to generate the amplitude and frequency. The
user can also change the pitch to the nearest half tone if the auto tune feature is on.
By controlling the amount of light on the photodiode receives, the amplitude and the frequency
can be controlled. The amount of light will also determine the volume and pitch of the audio
signal.
Implementation
Bill of Materials
Based on the prices from the Penn State University Bookstore website and newark.com, the cost
of the materials is $272.58. For more information on the cost of materials, labor, fringe, and
overhead, refer to the financial page in Appendix B.
The total price is expected price for one unit of the Optical Theremin. The bill of materials does
not include any audio devices (speakers, head phones, audio cable, etc.), as we expect the user to
have such materials. The average starting salaries per hour for a Penn State Electrical
Engineering graduate determined the manual labor costs.
A way to decrease the total cost would be to buy parts in bulk and reuse the Optical Theremin
design. When buying in bulk, the price per part decreases. If you are working on projects that
require these parts, it would be wise to buy in bulk to decrease the cost of parts. By duplicating
the design, no design phase is necessary, cutting down on the cost of labor.
High-Level Block Diagram
The block diagram maps out the process, helps determine the problem that needs to be solved,
and establishes the tasks to be completed. The data transformation is broken into two
components: frequency and amplitude. Once we understood this, our group determined how to
build the LabVIEW code.
The frequency transformation is made up of three components: a normalized signal, a range
multiplier, and an auto tune feature. We created a sub-VI for the auto tune feature in LabVIEW.
The auto tune feature allows the user to select a specific key and tune it to a note that is in the
chosen scale. The auto tune takes in the input frequency and thresholds the frequency. For each
major scale, the auto tune function is able to play eight notes in eight octaves. While the
amplitude transformation is similar to the frequency transformation, there is no need for a
threshold function because there is no auto tune feature for the current.
At the N = 0 level, the light source is the input and the audio signal is the output. The level of
light from the source is determined by the user’s hands in proximity to the photodiodes. The
audio signal is outputted via an output device such as speakers, headphones, or an audio cable
connected to a computer. To see the entire high-level block diagram, refer to Figure 1.
Figure 1: High-Level Block Diagram
The solution to building the Optical Theremin started simple: what should be input and what
should to be output. As time progressed, we continued to discover how to design the system,
what ideas needed to be kept simple, and what ideas needed to be expanded.
Hardware/Realization
The op-amp controlling frequency outputs to AI1+ on the MyDAQ. The op-amp controlling
amplitude outputs to AI0+. Both op-amps are configured as a current-voltage converter with a 1MΩ resistance in the feedback loop. The photodiode outputs a current, which the op-amp
converts to a voltage so the MyDAQ can read the input. A basic circuit diagram built in Multisim
can be seen in Figure 2.
Figure 2: Multisim Schematic for Current-Voltage Amplifier
The user controls the input by limiting the amount of light into the photodiodes. The system
reads the current from the light source, turns it into a voltage, and outputs the signals into the
MyDAQ. This is then used as the input signal in the LabVIEW code. The completed circuit can
be seen in Figure 3.
Figure 3: Circuit Board of Optical Theremin
LabVIEW VI Analysis
The user can use a few functions on the Main VI front panel. They can change the minimum and
maximum frequency presets to whatever they want, they can view the inputs and outputs, they
can turn the auto tune feature on and off, and they can choose what key the auto tune is in.
Figure 4: LabVIEW Main VI Front Panel
The LabVIEW code consists of a Main VI and four sub VIs. The Main VI block diagram
represents the data translation from the N=2 level of the high-level block diagram. The DAQ
assistant reads the voltage signal being inputted. We learned that if the DAQ parameters are not
set correctly, the interface will not work. For example, the frequency must be at least twice as
much as the bandwidth due to Nyquist Sampling. We realized that if the user changes the
MyDAQ used, the parameters must be reset.
Figure 5: Main VI Block Diagram
After the signals are read from the MyDAQ, the signals are split into amplitude and frequency.
Both of those signals then move into frequency VI and amplitude VIs.
Figure 6: Frequency VI Block Diagram
Figure 7: Amplitude VI Block Diagram
The pitch maker creates an array of frequency values that will be used for the auto tune. In the
pitch maker, the user can also control the number of octaves (starting from the lowest) that the
auto-tuner will use. We chose to do this outside of the while loop in the Main VI so that we do
not generate new pitches in the loop for each iteration.
Figure 8: Pitch Maker VI Block Diagram
The auto tune takes the frequency signal and measures what octave it is in. It then thresholds the
incoming frequency and rounds it to the nearest note within a major scale. This gives users the
opportunity to personalize their auto-tuning to whatever key signature they want. The auto tune
is set to recognize tonal qualities within frequency. The changed frequency then gets sent back to
the main VI, where the new signals are output into a speaker.
Figure 9: Auto Tune VI Block Diagram
Value Statement
The objective of this lab is to attempt to construct a Theremin using Labview working together
as a team. This lab also tested how well we could work together as a team and how each of us
contributed something to make the team function. This project really showed how teams function
and how each of us can use our full potential to accomplish a common goal.
Design Modifications Made During Testing
During the course of this project, some methods and parts were either altered or discarded, and
new methods were adopted. When we look back on our final design as compared to our initial
design, there are very few changes. We experimented with different ways to code sub VIs;
however, our overall design has stayed the same.
All of the modifications were made when we built the VI and tested the circuit. No member of
our group is completely proficient with LabVIEW, so mistakes are inevitable. The auto tune VI
has remained unchanged; however, we have to keep changing the signal processing VI, as it took
us a while to figure out the correct sample rates due to Nyquist Sampling rules.
We had to change the amplitude and frequency VI since some of our initial calculations were
incorrect, giving us the wrong pitch for a note. We also had to remember to keep changing the
amplitude to match the frequency.
DAQ Assistant Setting Parameters and Observations
Determining the settings for MyDAQ reader and writer was difficult. The most frustrating part of
this was choosing the amount of input samples to read. However, after a lot of trial and error, we
eventually discovered that it wanted Nyquist sampling. The amount of samples had to be chosen
so we got maximum data with great quality. We wanted smooth quality sound from the
Theremin, so we set the samples rates high and samples low.
Conclusion
We successfully constructed an Optical Theremin using LabVIEW code and a circuit design.
This was a team effort, with all group members contributing to different parts of the project. We
created the Optical Theremin by using photodiodes that depended on the amount of light they
received. The current from the light was converted to a voltage, which was then input to the
LabVIEW code through the MyDAQ to process the amplitude and frequency of the wave. This
wave was finally converted to an audio signal, which was outputted by our speakers.
Appendix A: Gantt Chart
Appendix B: Financial Page
Cost of Materials
MyDAQ
$233.35
Breadboard
$36.80
Photodiodes
$1.14
1 MΩ Resistors
$0.80
TL074CN Op Amp
$0.49
TOTAL
$272.58
COST OF LABOR
Est. Labor: Engineering rate: $35/hr.
(3 Engineers, 13 hours each)
$ 1365.00
Fringe
15% of Est. Labor
$ 204.75
Overhead
40% of (Labor + Fringe)
$ 627.90
Total Labor Estimation
$ 2187.65
OTHER COSTS
Contingency
10% of (Total Cost + Total Labor)
Grand Total
$ 246.02
$2706.25
Download