EE 300W Laboratory 2

advertisement
TeamRocket
Joelle McCormack
Patrick Barnett
Matthew Hood
Laboratory 2
Optical Theremin
3/07/2014
Optical Theremin
2
Abstract
Introduction
An Optical Theremin is a musical instrument that can be played without using any physical
contact. Using a light detecting circuit the user should be able to control frequency and amplitude of the
audio tone based on light intensity. The user should be able to set the range of audio tones
generated. The user should be able to configure the intensity range that will be seen by each sensor or
calibrate the sensors to the ambient light levels. Using the mm TRS connector on the myDAQ, an audio
signal should be generated. The user should be able to adjust multiple settings through LabVIEW’s
front panel including the maximum and minimum light intensity levels and the range of
frequencies. The front panel in LabVIEW should display the normalized waveform that controls pitch
as a function of time, the normalized waveform that displays volume as a function of time and the
numeric indicators of the light intensities detected.
Rationale
The problem can be decomposed into three main parts: light-detecting circuit, myDAQ interface, and
LabVIEW processing. Two separate light detector circuits allow the user to control the audio tone’s
frequency and amplitude independently. The myDAQ interface takes the signals from the circuit and
makes them inputs to a LabVIEW VI. In the VI, user controls are added to normalize the light intensity
of each diode, as well as set a range of output sound frequency. The normalized and frequency
limited signals are sent to a waveform generator, and an the audio waveform is outputted by the myDAQ
mm TRS port.
Figure 1: Block Diagram
Optical Theremin
3
A sensor circuit to measure the leakage current of the photodiode can be constructed by monitoring the
leakage current with an OpAmp, as shown in Figure 1. Ideally, no current flows into the inverting input
of the OpAmp, so the leakage current is equal to the feedback current. This small (microamp) current is
amplified by the large feedback resistor, so that:
π‘‰π‘œ = 𝑅1 βˆ™ 𝐼𝑝
Figure 2: Sensor Circuit
Implementation
We used a TL074 OpAmp to measure the current from the photodiode. The TL074 OpAmp has high
input impedance on the order of 10 ohm, so the approximation that no current flows into the inverting
input is valid. The TL074 is also a good choice due to its low noise rating, which is important when
trying to amplify small micro amp leakage currents.
12
The circuit used to run this program made use of two of the OpAmp’s on the TL074 package. The noninverting terminal was tied to ground while the inverting terminal was tied to both a 1.1Mohm resistor
and the negative terminal of the photodiode. The positive terminal of the photodiode was tied to ground
while the other side of the 1.1Mohm resistor was tied to that OpAmp’s output. The output was then
measured by the analog inputs of the MyDAQ. To ensure the frequency and amplitude light adjustments
could be controlled independently, longer wire jumps were used to ensure a further distance between
photodiodes.
The output voltage was tested to have a large swing, from 50 mV in the dark to 760 mV under a LED
flashlight. This large range is important when trying to quantize the audio output into distinct
amplitudes and frequencies, without the need for further amplification.
The two DAQ Assistant tools in the main VI’s have settings in place to gather adequate data at their
given sampling rates. The first DAQ Assistant tool which reads in data, reads continuously gathering 1k
samples at a rate of 10kHz. The second DAQ Assistant tool, which outputs the signal to the myDAQ’s
Optical Theremin
4
audio out port, generates 1k samples continuously at a rate of 80kHz. The simulate signal function is set
to run as fast as possible with a sampling rate of 40kHz.
Four LabVIEW VI’s were created along with the circuitry to create the Optical Theremin. A main VI
worked to acquire data and pass it along to the 3 sub-VI’s used. In the following figures the front panel
and block diagrams used in the project can be viewed. Explanations of each block diagram are included.
Figure 3: Part 1 Front Panel
Optical Theremin
5
Figure 4: Part 1 Block Diagram
The above front panel and block diagram represent the LabVIEW code for Part 1 of the Optical
Theremin experiment. In the front panel of the VI the min/max light intensities can be set for either
photodiode while the frequency range can also be adjusted. Accompanying graphs illustrate the change
in the amplitude and frequency output over time. In the block diagram, the DAQ Assistant tool obtains
data from both analog inputs of the myDAQ. One of these sets of data corresponds to the frequency
control, the other corresponds to the amplitude control. User controls adjust intensity and frequency
levels desired and are inputted into two sub-VI’s. After the normalization within these sub-VI’s, the
simulate signal function generates an audio signal. The second DAQ Assistant tool in the block diagram
outputs the audio signal to the MyDAQ’s audio output.
Figure 5: Frequency Block Diagram
Using two controls, one to adjust the range of light intensities and the other to adjust the frequency
ranges desired, this code normalizes the frequency level based on the voltage being measured through
Optical Theremin
6
the analog inputs of the MyDAQ. Using the In Range and Coerce tool, the outputted value for the signal
frequency is maintained between the values adjusted by the user with the frequency control.
Figure 6: Amplitude Block Diagram
The amplitude normalization block diagrams works like the frequency block diagram. In this diagram,
the light intensity range and actual voltage measured are used to create a normalized output amplitude
within 0 and 1.
Figure 7: Part 2 Front Panel
Optical Theremin
7
Figure 8: Part 2 Block Diagram
The front panel and block diagram of Part 2 include the autotuning feature of the optical theremin. Using
an enum control with a case structure, the user can select to either enable the autotuning feature or
bypass it and force the program to function like part 1.
Figure 9: Autotuning Block Diagram
In this block diagram the case structure is used to select the musical key to play in. An array of the first
octave of a given key is used to build 10 octaves of notes ranging from roughly 20Hz to 20kHz. Using
the output of the frequency sub-VI, a fractional index is generated to select a frequency from the already
made array.
Value Statement
This optical theremin works efficiently over a wide range of musical notes with a limited number of
physical resources. In addition to being able to being able to produce any frequency between a range of
Optical Theremin
8
20Hz to 20kHZ it can be used to generate pitches belonging to certain musical keys. The instrument is
easy to use and adjust given the program’s user controls.
Conclusion
Using LabVIEW, photodiodes, and OpAmps, an optical theremin was constructed. The Theremin is user
controllable, with settings that are adjustable during the programs execution. Using Sub-VI’s to
normalize the frequency and amplitude signals; an output audio wave was constructed. A separate SubVI was used to tune the normalized frequencies to notes within musical octaves. An enum control is
present within the code that further allows the user to specify the specific key the theremin is tuned to.
The produced theremin meets the design requirements set forward in a straightforward and organized
manner that users should be able to understand.
Appendices
Bill of Materials
No.
1
2
3
4
5
6
Part No.
TL074
S120
Description
Breadboard
Low-Noise JFET-Input Op-Amp
NI MyDAQ with LabView
Photodiode
1.1MΩ Resistor
Logitech Speakers
Quantity
1
1
1
2
2
1
Cost
$19.95
$0.28
$225.00
Total
$19.95
$0.28
$225.00
$0.07
$10.39
$0.14
$10.39
Optical Theremin
9
Download