The Optical Theremin is a musical instrument that produces sound

advertisement
Critical Design Review
3/9/2014
Optical Theremin
With Auto-Tuning Feature
Mohammed Alshehri, Brian Legowik, Adriyel Nieves
THE MIGHTY DUCKS, SECTION 4, EE 300W
OPTICAL THEREMIN
3/9/14
Table of Contents
Abstract ........................................................................................................................................................ 3
Introduction .................................................................................................................................................. 3
Rationale....................................................................................................................................................... 4
Implementation............................................................................................................................................ 6
DAQ Assistant setting parameters and observations ............................................................................... 6
Design Modifications ................................................................................................................................ 6
Final Implementation ................................................................................................................................ 7
Value Statement ........................................................................................................................................ 10
Conclusion.................................................................................................................................................. 10
Appendices ................................................................................................................................................ 11
PG. 2
CRITICAL DESIGN REVIEW
OPTICAL THEREMIN
3/9/14
Abstract
The Optical Theremin is a musical instrument that produces sound waves from the input of
light. The light intensity is altered by each hand before it is measured by a photodiode. These
photodiodes then produce leakage currents in proportion to the intensities of light received.
Both currents are converted to voltages by transimpedance amplifiers.
From the breadboard circuitry, the signals are processed by an NI myDAQ device. LabView code
assigns one input signal to be a frequency control and the other signal to be an amplitude
control for sound wave simulation. LabView front panel controls allow the user to manipulate
the frequency and gain of the output signal. In addition, the LabView signal processing autotunes the frequencies to the nearest half-tone. The resulting audio signal is output through the
myDAQ’s 3.5 mm TRS connector (headphone jack).
Introduction
The Optical Theremin allows music to be produced without any physical contact. The presented
design challenge was to create an Optical Theremin with a detector front-end circuit and signal
processing functions in LabView.
The detector circuit is an instrumental part in the creation of the desired music. Two
photodiodes, which respectively control the music’s frequency and amplitude, produce leakage
current based on received light intensity. The current from the photodiodes is converted to
voltage by a transimpedance amplifier. The user’s hand movement alters this intensity, thus
altering the sound played at the output of the signal processing.
On the other side of the design process, the signal processing code is implemented using
LabView. The voltage signals from the circuit are gathered using the myDAQ device and its
accompanying DAQ Assistant software. The LabView code allows the signal to be manipulated
by a user through front panel controls.
The Theremin generates a user-controllable audio tone from the headphone jack of the
myDAQ. This product is unique because it allows music to be created without contact, much
unlike other instruments. Users that are interested in creating their own music at a basic level
with additional software controls will enjoy this product.
PG. 3
CRITICAL DESIGN REVIEW
OPTICAL THEREMIN
3/9/14
Rationale
For the initial design of the Optical Theremin, a photodiode was used to gather light. This was
amplified using a non-inverting amplifier to increase the gain of the leakage current. The output
of the amplifier went to the myDAQ. With the implementation of LabView coding and user
input controls, the system would then output sound based on the amount of light received by
the photodiodes.
When building the non-inverting amplifier, a gain of 50 was needed to see a significant
response from the covering of the photodiode from light. There were several problems
encountered when using the non-inverting op-amps.
First, the relative current response of the photodiode was around 1% for light input, which
meant that the system responded with a slight delay. Figure #1 shows this phenomenon
graphically. Second, the non-inverting amplifier required two resistors for each op-amp circuit.
Figure #1: Relative Response vs.
Wavelength graph
Through additional research, the use of a transimpedance amplifier (TIA) was determined as
our final choice for the circuit. The op-amp converts leakage current from the photodiode to
voltage. Also, the TIA isolates the photodiode from the output voltage of the op-amp and
reduces the number of components needed for each circuit design.
In LabView, a virtual instrument was built that outputs a sine wave which changes based on the
light intensity at the input of the photodiodes. The user controls the maximum and minimum of
frequency and amplitude. These values were used to calculate normalization parameters,
allowing for data from the photodiode to be coerced between values set by the user minimum
and maximum value.
PG. 4
CRITICAL DESIGN REVIEW
OPTICAL THEREMIN
3/9/14
The final design was improved by implementing an auto-tuning VI and an ambient light control
to optimize the Optical Theremin based on the environment in which the device is being used.
The pitch of a musical note depends on the frequency of the wave. To operate the Optical
Theremin without auto-tuning, the user must precisely move their hands to obtain the desired
note. This can cause for error and make the Theremin a difficult system to use. Auto-tuning
defines a range with equal step sizes which the system will round down or up to obtain a
specified frequency value.
The photodiode is susceptible to unwanted light from the surrounding environment due to the
cylindrical geometry of the diode. The ambient light control allows the user to adjust the
sensitivity of the Theremin based on the ambient light.
Figure #2: Theremin VI Block Diagram
Signal averages are taken to smooth out any noise input from the photodiodes. Their absolute
values are taken since inverting amplifiers are being used. The signals are multiplied since they
are too small to have enough of a noticeable range. The ambient light compensation controls
are subtracted from the signals before they are input into their respective controls. After the
signals are modified they are used as controls for the signal simulators. The signal simulator’s
output is then passed onto the DAQ assistant which outputs through the headphone jack of the
myDAQ.
PG. 5
CRITICAL DESIGN REVIEW
OPTICAL THEREMIN
3/9/14
Implementation
DAQ Assistant setting parameters and observations
Input: 200 kHz; 1k samples; -5 < Vin < 5
The sampling rate was chosen so that the device would be able to deal with as many
frequencies as possible without negatively affecting device application. An accepted sampling
frequency for audio applications is 44.1 kHz/second (industry standard), but the chosen
sampling rate allows for a smoother transition between notes rather than being an optimal
recording frequency. The sample range was set between -5 V and 5 V to take into account any
voltage spikes or changes in the op-amp set up (like using the VI with a different circuit).
Output: 100 kHz; 6.5k samples; -2 < Vin < 2
The output sampling was a result of trial and error because the final DAQ Assistant crashed if
the sampling rate was any higher. These values were chosen so that a smooth output would be
produced rather than a choppy signal associated with low sample rates. The output voltage
limits are smaller than those of the input as a precaution to protect any speakers connected to
the output of the myDAQ.
Design Modifications
Figure #3: Initial Block Diagram
PG. 6
CRITICAL DESIGN REVIEW
OPTICAL THEREMIN
3/9/14
1. When starting the project, we used a DAQ Reader for the myDAQ input, but instead, we
decided to use a DAQ Assistant instead for flexibility in deciding sampling parameters as
well as a much easier interpretation of the data being passed through. The DAQ Reader
required far more sub-VIs to interpret the data before we could use it in the main block
diagram.
2. We initially attempted to implement the frequency and amplitude controls using a
formula. The approach turned out to only lengthen the process of controlling the
signals. It also proved to be more difficult to implement since the coding required would
be difficult to debug. We eventually settled on using separate sub-VIs for each of the
frequency and amplitude signals.
3. For the ambient light issue, we initially tried to use the Normalize Waveform formula
node, which would remove the offset (caused by the ambient light). However, it would
interpret any steady signal as an offset (e.g. signal from a hand not being moved would
be considered an offset and would be subtracted from the equation when the user
might want to sustain the musical note). We modified the design to be implemented
without the Normalize Waveform sub-VI and added an Ambient Light Compensation
control (a slider, numeric control to be set by the user that is scaled and subtracted from
both amplitude and frequency signals).
Final Implementation
Figure #4: Theremin VI Block Diagram
PG. 7
CRITICAL DESIGN REVIEW
OPTICAL THEREMIN
3/9/14
The VI starts with the DAQ Assistant interpreting data from two analog inputs of the myDAQ,
which splits them into two distinct channels. One is for frequency and the other is for
amplitude. Both signals have their average taken in order to be multiplied so they are in range.
Their absolute value is taken since the photodiodes are in an inverting op-amp setup.
Controls are then introduced to compensate for ambient light going into the system. The
ambient light compensation is subtracted from both amplitude and frequency signals.
Figure #5: Frequency Control VI (left) and Amplitude Control VI (right)
The normalized frequency signal goes into the frequency control VI, where it is divided by the
frequency maximum and minimum range set by the user in the front panel. It is then coerced
by the same frequency maximum and minimum. The amplitude signal goes through an identical
process, but it is coerced between the values of 0 and 1 so that it does not overdrive the output
speakers. The post-frequency control signal is pushed through an Auto-tuning VI where a base
octave is generated. From the base octave, other octaves are generated depending on how
many octaves the user inputs. After generating the tones, the signal is put through a case
structure that the user controls by a toggle switch. When the user toggles the Autotune to the
ON position, the input frequency is put through a threshold process based on the octaves
generated. When the user toggles the Autotune OFF, the input signal passes through
unaffected towards the signal generator. Both amplitude and frequency waveform charts are
created before being pushed into the signal generator so the user can see the final effects of
the controls and the auto-tuning on the separate waveforms.
PG. 8
CRITICAL DESIGN REVIEW
OPTICAL THEREMIN
3/9/14
Figure #6: Auto-tune VI
Finally, both of the controlled signals are input into a sine signal generator to create the final
waveform to be output. The output of the signal generator is then passed to the waveform
chart to display the final waveform. Also, it is passed to the DAQ Assistant set up to output the
signal through the myDAQ’s audio output. To deal with the possibility of an incorrect input on
behalf of the user at the controls, there are two error messages to be displayed if the user sets
parameters that are impossible to implement (e.g. frequency maximum less than the frequency
minimum, or amplitude maximum less than amplitude minimum).
Figure #7: User Interface
PG. 9
CRITICAL DESIGN REVIEW
OPTICAL THEREMIN
3/9/14
Value Statement
The Optical Theremin provides customizable controls to allow the user to optimize the settings
of the circuit and signal processing based on the ambient light in the environment. Because of
the compensation for ambient light control, the product can be adjusted to compensate for
light affecting the photodiodes. With the gain control, the user can adjust the maximum volume
of the system without having to change the amplitude bounds while the LabView program is
running. The front panel provides graphs of the amplitude and frequency normalization as well
as the final sound signal graph with the corresponding frequency and amplitude.
Conclusion
The goal of the design project was to design an Optical Theremin, a musical instrument that can
be played without physical touch. Our group successfully completed this objective by fulfilling
the provided design requirements and demonstrating an operating prototype. With the
implementation of circuitry and LabView programming, the Optical Theremin is a versatile
device, allowing for the creation of a wide array of music. Any future will quickly learn that the
device will perform with durability and precision.
PG. 10
CRITICAL DESIGN REVIEW
OPTICAL THEREMIN
3/9/14
Appendices
Appendix A: Bill of Materials
Item
Vendor
Quantity Price/Unit Total
myDAQ
eBay
1
$180
$180.00
510kΩ Resistor
Digi-Key 2
$0.08
$0.16
OP906 Photodiode
Digi-Key 2
$0.59
$1.18
TL074
Digi-Key 1
$0.62
$0.62
$6.00
$6.00
Breadboard/Cables eBay
1
$187.96
Appendix B: Multisim schematic of circuit
PG. 11
CRITICAL DESIGN REVIEW
OPTICAL THEREMIN
3/9/14
Appendix C: Theremin Functional Diagram
N=0
Light
Optical Theremin
Audio Output
User Controls
N=1
Light
Circuit Interface
LabView Interface
Audio Output
User Controls
N = 2 (Circuit Interface)
Light
Light
N = 2 (LabView Interface)
Amplitude Control
Photodiode
Transimpedance Amplifier
Voltage (Represents Amplitude)
Frequency Control
Photodiode
Transimpedance Amplifier
Voltage (Represents Frequency)
Audio Output
Sine Wave
Generator
User Controls:
Frequency Maximum, Frequency Minimum, Amplitude
Maximum, Amplitude Minimum, Octave Select, Autotune
On/Off, Ambient Light Compensation, Amplifier Gain
Auto-tune
Freq.
Normalization
Auto-tune On/Off
Freq. Max/ Min
Ambient Control
Octave Select
Amp.
Normalization
Gain Control
Amp Max/ Min
PG. 12
CRITICAL DESIGN REVIEW
OPTICAL THEREMIN
3/9/14
Appendix D: Gantt Chart
PG. 13
CRITICAL DESIGN REVIEW
Download