You are on page 1of 15

EE 300W Lab 2: Optical Theremin Critical Design Review

Team Drunken Tinkers:


S6G8
Levi Nicolai,
Harvish Mehta,
Justice Lee

October 21, 2016

Abstract
The objective of this lab is to create an Optical Theremin, which is a musical sound
device that is controlled by two light sensing photodiodes. The Optical Theremin consists
of a TL074 op-amp, LabVIEW, myDAQ, speaker, and two photodiodes. The current
emitted from the photodiodes is converted to a voltage and amplified through the TL074
op-amp. This voltage is inputted to the myDAQ, and processed by LabVIEW to outputted
into an audio out signal and three digital outputs on the myDAQ. These ports control the
speaker, and three LED indicators.
Introduction
The goal of this lab was to design an Optical Theremin that controlled the
frequency and amplitude of the output signal. The input signal enters the Optical
Theremin and becomes a modified output. Using two photodiodes, we designed a circuit
that would allow the user to control the output sounds frequency and volume. By
changing the intensity of the light received by the photodiodes, thon could increase or
decrease the output amplitude and frequency. The level of frequency played would be
shown through LEDs. The benefit of having this device over the regular instrument is the
lack of overlapping controls for amplitude and frequency, which is often found in a regular
device. This way the user has more control over the instrument. As a result, people who
want to have the frequency of their instruments separated from the volume would find
that the Optical Theremin fulfills the requirements.
To process the input signal, we used LabVIEW and a National Instrument myDAQ.
For simplicity, the voltage supply was also provided by the myDAQ. The photodiodes
generate a current which is then converted into a voltage by the TL074 op-amp and
inputted into the myDAQ. The myDAQ inserts the data into LabVIEW. LabVIEW then
normalizes the voltage input and runs it through several algorithms to allow the input
voltage to control the output signals pitch and volume.
An autotune, octave selector, and equalizer were also implemented. The auto tune
was implemented to compare the input frequency values to an array of notes and coerce
the frequency into being outputted as that note. The octave selector allowed the input
frequency to be limited to only a certain octave of notes while still being auto tuned. The
equalizer took the input frequency and lit up specific LEDs relative to the range of
frequencies being outputted.
Rationale
Our high level block diagram (see Figure 11 appendix A), shows the subsystems
of our design and the hierarchy of each subsystem. In the N=0 level of our block diagram,
it depicts our main design, the Optical Theremin, which receives an input and produces
an output. The inputs to the Optical Theremin are user controlled and their hierarchy is
explained in the N=1 and N=2 levels of the block diagram.

At the N=1 level of our block diagram we depict the transformation process that
takes effect from input to output. The circuit for our project is drive by light intensity and
this is read into the myDAQ as a signal. The signal is read into the computer which
transforms the input into a waveform signal and is again output through the myDAQ. The
circuit is one of two user controlled signals. This is the physical user control. The virtual
user control is the computer which is discussed in more detail in the N=2 level of our block
diagram.
At the N=2 level of our block diagram we give the details of the circuit and computer
communications with the myDAQ. The circuit (see Figure 1) consists of two photodiodes
to produce two separate currents which are controlled by light intensity. These signals
are sent through a TL074 operational amplifier set up as a trans-impedance amplifier
which converts the current to an amplified voltage. The myDAQ reads in these voltages
through LabVIEW and uses them to produce two separate signals; a signal for amplitude
control, and a signal for frequency control. The user can set the volume of the output
using the amplitude signal, and can set the range of frequencies of the output using the
frequency signal. When the signals are set to their desired settings, they are sent through
the Simulate Signal VI within LabVIEW and this signal is sent back out through the Audio
Out port of the myDAQ.
Implementation
Theory of Design
The project design asked for user controllability of frequency and amplitude of the
output signal. Photodiodes produce a current relative to the light intensity it receives. Op
amps receive the current and convert it into voltage signals that the myDAQ compile.
The NI myDAQ is used as the connection between the physical circuit and the
LabVIEW software. It inputs the outputs of the physical circuit into the LabVIEW program.
Then it outputs the audio out signals as well as digital output signals from LabVIEW to a
set of speakers and LEDs.
The LabVIEW is used to construct a virtual environment for processing the input
signal. Upon entering the LabVIEW program, the input signal is split into 2 parts:
frequency and amplitude. Each part is processed individually. In Max&Min, the max
value and min value of the input signals are found and are then used normalize the
signals. The normalized signal is then processed into a range of values. For frequency,
Autotune matches the input frequency to the nearest musical note. Octave Selector
mimics Autotune but only allows notes within an octave to be outputted. These signals
are combined and simulated through filters that act as equalizers. The equalizer produces
digital output signals that power LEDs and an audio out signal that sends signals to the
speaker.
Analog Input Circuit Design
The physical circuit design to create a voltage signal input into the myDAQ utilizes
two photodiodes, one TL074 chip, two bypass capacitors, voltage source, and two 1 M
ohm resistors. As seen in Figure 1, this circuit operates through light sensing photodiodes.

After the photodiodes receive light they create a current that is inputted to a negative
terminal of an Op-Amp to which amplifies the current to a voltage signal. The 1 M ohm
resistor causes a large voltage signal that is readable in LabVIEW. The bypass capacitor
creates a reduction of noise at the power source.

Figure 1: Analog input circuit design representation portrayed in MultiSim using


equivalent parts as physical circuit.

LabVIEW Front Panel

Figure 2: Front panel containing controls, indicators, buttons and graphs.

The Front Panel consists of the controls for the LabVIEW program as well as
indicators to identify any bugs, shown in Figure 2. From this panel, all outputs can be
modified accordingly.
Frequency Min Set and Max Set: Sets the min and max of the frequency
bounds.
Frequency, Amplitude, Maximum F, Minimum F, Maximum F2, Minimum
F2: Indicators to ensure there are no bugs within the program.
Auto Tune: Turns on the Auto Tune subVI.
Octave Selector: Turns on the Octave Selector subVI
File Read? Boolean switch to determine whether or not a .wav file will be
read in place of the inputs of the photodiodes.
Low Freq., Mid Freq., High Freq.: LED indicators of frequency for Bass, Mid,
and Treble.
Amplitude, Frequency, Waveform Graph: Graphs showing output Amplitude
and Frequency which are used for debugging. The Waveform graph shows
Power Density Spectrum of the output signal.
Volume, Mid, Treble, Bass: Knobs for controlling Volume, Mid, Treble, and
Bass.
Octave: Only operates if Octave Selector is on. Determines what Octave
will be output.
Main.VI
As seen in Figure 3, the main.vi depicts the bulk of the programing done in
LabVIEW. These next sections will break the main.vi into Input DAQ Assistant,
Normalization, Equalizer, Output DAQ Assistant, and Spectral Measurements.

Figure 3: Block diagram of Main.VI incorporating all Sub.VIs and Main Code
Input DAQ Assistant
Utilizing the myDAQs AI0 and AI1 analog input ports, we read in the
voltages from the output of the trans-impedance amplifier. Since the DAQ
assistant only has a single output which had merged the two inputs into a

single output, we used the split signal VI to separate the signals to utilize
for amplitude and frequency separately (figure 3). The voltage range was to
-10V to 10V to ensure we did not get any errors if there was a spike in
voltage.
Normalization
The normalization part of LabVIEW is to take the input signal range
and limit it to a range between 1 and 0. This allows the range of the input
signal to be transferable to any range desired.

Figure 4: Normalization block diagram implementing mapping equations


In order to normalize the input, we used the equation below:
=

This equation, implements a percentage in LabVIEW. X is the input


while Y is the output. This percentage is then magnified by a constant due
to the sensitivity of the diodes, which caused the normalized output to spike
initially. This spike caused all other inputs to be drastically smaller so the
constant magnified the result to viewable level.
Once magnified, the output is then coerced into a limit max of 1 and
a limit min of 0.
Simulate Signal
After mapping the amplitude and frequency to the desired ranges,
this data is then fed into the Simulate Signal VI within LabVIEW, as seen in

figure 3. This VI produces a sinusoidal wave which we can output to the


myDAQ through the Audio Out port.
Equalizer

Figure 5: Block diagram of the equalizer


The Equalizer splits the frequency of the input signal into three different
ranges. This is done by using the filter VI within LabVIEW. The treble filter is set
as a high pass filter to only let through higher frequencies, the mid tone is set to a
band pass filter allowing only mid tone frequencies, and the bass filter is set as a
low pass filter allowing only low frequencies. These signals are multiplied by the
control indicators on the front panel to vary the amount of output of each that gets
added to the total output. By summing the three outputs of the filters, we acquire
a single output which is output through the audio out port on the myDAQ.
The audio wav file is read through a file read button. When the file read
button is on, the case statement is true, and the sound file is outputted. This signal
is also outputted through the audio out port.

Output DAQ Assistant 2


This DAQ Assistant outputs audio out signals from the equalizer,
which sends a signal to the myDAQ. The myDAQ then outputs the signal.
Spectral Measurements
This takes the input audio signal and shows the power density
spectrum in a waveform located on the Front Panel.

Max & Min Sub.VI

Figure 6: The MM sub.vi seen in Figure 3


This sub.vi (figure 6) utilizes feedback loops to continuously adjust the
minimum and maximum voltages read by the myDAQ. They compare the current
input to the value currently stored in the output and if the input value is greater than
the value stored in the feedback node, the feedback node takes on the input value
and the input value gets outputted.
The Max and Min of the subVI both operate the same way, they are just
kept separately and Min takes the smaller value instead of the larger one.

Autotune Sub.Vi
The Autotune subVI (figure 7) takes the input frequency and matches it to
the closest musical note. It utilizes a for loop to duplicate an array of 0 octave
frequencies of notes and doubles them while adding them to the end of an array
to create a long array of musical frequencies from the 0 octave to the 10th octave.
A comparator is then used to match the input frequency to the closest constant on
the note array. The subVI then outputs the constant closest to the array.

Figure 7: Autotune sub.vi as seen in the main block diagram (figure 3)

Octave Selector Sub.VI


The Octave Selector (figure 8 below) takes the input frequency and matches
it to the closest musical note of an octave. The user may choose the octave of the
range of notes. The output frequency is the closest note matching the frequency.
Inside the formula node is a line of constants for each note which is then multiplied
by the Octave input to reach the desired octave. There is then a group of if
statements to compare the input frequency to the closest note and output the note.

Figure 8: Octave subVI seen as Auto Octave Change in the block diagram (figure 3)

LED Sub.VI

Figure 9: LED indicator sub.vi located in the main block diagram (figure 3) as LED
The LED sub.vi (figure 9) allows us to set the range of frequencies in which
we want the LEDs to turn on. Our total range of frequencies was from 50Hz 5000Hz. In order to split the range up to 3 LEDs we divided 4950/3=1650 and
adjusted slightly to avoid hitting the edges of the range and causing an error. The
sub.vi works as follows: if the input frequency is between 45 Hz - 1700 Hz, only
LED 1 will be on. If the input frequency is between 1701 Hz - 3400 Hz, LED 1 and
LED 2 will be on. Any frequency higher than 3400 will turn all three LEDs on at
the same time.
The DAQ Assistant digitally outputs the signals within the required
frequency range to the LED Circuitry. Each LED corresponds with a range of
frequency.
Output LED Circuitry

Figure 10: The physical output LED circuitry from the myDAQs digital outputs

The three LEDs (figure 10) each represent a zone the frequency is in, treble,
mid tone, and bass. As the frequency increase the LEDs turn on and off
chronologically from bass to treble, and treble to bass. The 10k ohm resistors are
inserted to limited the current inputted to the LEDs.
Value Statement
The Optical Theremin allows for the separation of the pitch and volume control. In
a regular instrument such as the guitar, the user controls the frequency and amplitude of
the sound through the vibration of the strings. The length of the string determines the
pitch while the force of the vibration determines the amplitude. However, the relationship
between the pitch and volume in the guitar can make it difficult to hold one control as a
constant while changing the other, such as changing the pitch while keeping volume
constant. The Optical Theremin allows for the user to hold an exact volume while
modifying the pitch to their desire. This separation of pitch and volume controls gives the
user a higher level of control that a traditional instrument wouldnt offer.

Conclusion
The Optical Theremin is a musical instrument that uses two types of user controlled
inputs; one physical and one virtual. The physical user control is the circuit depicted in
Figure 13 in Appendix C. The user controls the inputs using light intensity by hovering
thons hands at different heights about each photodiode. The virtual control is done using
the front panel of the LabVIEW main VI as shown in Figure 2. With the controls given,
the user can control the volume, bass, mid tone, and treble of the output signal. The user
can also set the minimum and maximum frequency output desired. The myDAQ was
used as the read and write process. The signal was read in through the myDAQ AI0 and
AI1 ports and then output through the Audio Out port. On the output side, speakers were
used to transmit the signal to an audio tone which was in the range set by the user.

Appendix A: High Level Block Diagram

Figure 11: High level block diagram depicting the hierarchy of the N=0, N=1, and N=2
levels of the Optical Theremin design

Figure 12: High level block of the LabVIEW component of the Optical Theremin in the
hierarchy of N=0, N=1, and N=2

Appendix B: Tables of Schedule and Bill of Materials

Table 1: Schedule of Optical Theremin design depicted through a Gantt Chart

Table 2: Bill of Materials of the Optical Theremin

Appendix C: Visual Representation of Circuit

Figure 13: Physical representation of the Optical Theremin design project

You might also like