Optical Theremin - Sites at Penn State

advertisement
OPTICAL THEREMIN
Critical Design Review
Irvine, Sean Patrick
Sean Irvine, Jen Holmes and Zach Sevcik
Contents
Abstract ......................................................................................................................................................... 2
Introduction .................................................................................................................................................. 2
Rationale ....................................................................................................................................................... 2
Implementation ............................................................................................................................................ 3
Value Statement ........................................................................................................................................... 4
Conclusions ................................................................................................................................................... 4
Appendix ....................................................................................................................................................... 5
Gantt chart ................................................................................................................................................ 5
High Level Block Diagram .......................................................................................................................... 5
Circuits ...................................................................................................................................................... 6
LabVIEW screenshots ................................................................................................................................ 7
Bill of Materials ........................................................................................................................................... 13
1
Abstract
The traditional Theremin is an electronic musical instrument that is played without any physical contact.
It uses two antennas to sense the position of the musician’s hands and controls two oscillators, one
being for frequency which is the pitch and the other for amplitude which is the volume. These signals
are then sent through an amplifier and outputted through speakers. Traditional Theremins are
expensive and bulky; however, by using photodiodes and other various hardware and software
components, the Theremin can be manipulated optically which saves on cost and space since the circuit
contains minimal parts and the software has replaced most of the original hardware.
Introduction
The Theremin is an early electronic instrument created by Russian inventor Leon Theremin. Known to
have an eerie sound, it is famous for being played for Star Trek and many other entertainment fields.
The traditional Theremin uses two metal antennas emitting magnetic fields. Your hands disrupt these
fields which sends sinusoidal signals to the processing unit which then produce and amplify the signals
through speakers.
In 300W, the second lab has the goal of producing an optical version of the Theremin using hardware
and software components to downsize the instrument in size and cost. This makes the instrument more
customizable by allowing for tuning of the system while it is in operation. The front panel of the
LabVIEW code allows for adjustment of the frequency and volume range, as well as an auto-tune feature
that adjusts the input frequencies to audible musical notes in a range of different octaves. This allows
the outputted sound to be comparable to other modern day instruments.
Rationale
The hardware for this design begins with the photodiodes, which in practice convert light energy into
current and can act as a current source. This is then amplified using a simple op amp circuit consisting of
an op amp with low input bias and offset currents and a large resistor to match the voltage range of the
MyDAQ. The low current specifications of the op amp are critical because the photodiodes produce an
extremely small amount of current.
The incoming signal is sampled by the MyDAQ using the program LabVIEW and converted to a digital
signal which is split into its frequency and amplitude components. These signals must first be placed into
a one by one array and then converted into a type double by extracting the data from the array. The
sensitivity of the photodiode can then be adjusted by multiplying the input voltage by a control varied
by the user. Both voltages are then continuously normalized to the highest input voltage and the
frequency and amplitude ranges can be controlled by sliders on the front panel. The user is then given
the option of using an autotune feature which will round the frequency input to the nearest whole note
to improve sound quality. These scaled amplitudes and frequencies are then synthesized into an output
sinusoid that is written back to the MyDAQ to be played through its audio jack.
2
This product is designed with user control and simplicity in mind. The code was created to be readable
and understandable by those with a simple understanding of LabVIEW. The circuitry is also designed
simply for easy troubleshooting and setup by all users. The user has control over a variety of features of
the Theremin through the front panel which is easily understood by inspection.
Implementation
The first step in the realization of the project was the photodiode circuit. Two separate circuits were
built, one for frequency and the other for amplitude, on opposite ends of the breadboard. Both were
built in the following manner: the op amp chip, TL074, was powered by +/- 15V, the non-inverting inputs
of the op-amp were grounded, the inverting input was connected to the negative end of the
photodiode, the output was connected to a large resistor (3 MΩ) that then went into the negative end
of the photodiode as well, and the positive end of the photodiode was grounded. This setup allowed for
the op-amp to act as a transimpedance amplifier which converts current to voltage. The resistor value
was calculated by taking the maximum input voltage range to the myDAQ (0-10V) and the photodiodes
reverse light current range (16-35 μA) into Ohm’s law. After some trouble shooting, the estimated value
of the current range in the room was taken to be .1-1 μA instead since the circuit was not working like it
should. This gave the resistor value of 3 MΩ.
The myDAQ was connected next using its +/- 15 V supply, both input and output analog ground
connections, the 0 +/- input connection was used for the frequency output and analog ground, and the
1 +/- input connection was used for the amplitude output and analog ground. Then, after debugging, the
LabVIEW coding was begun.
The signal was taken into the code, enclosed entirely by a while loop, using the DAQ Assistant with
settings of 0-10 V input range and 3,000 continuous samples read at 200kHz. The signal was then split
into frequency and amplitude data and put into an array of scalars which then had each value extracted
for manipulation.
The amplitude data was then multiplied by the amplitude intensity sensitivity control and normalized.
This was done by finding the max of the data and dividing it into all of the data. The set was then
multiplied by the amplitude maximum control and input into the simulated sine signal with settings of
20,000 samples being read at 200 kHz.
The frequency data was then multiplied by the frequency amplitude intensity control and normalized.
This was done by finding the max of the data and dividing it into all of the data. The set was then
multiplied by the frequency maximum control and inputted into a case statement that gave the option
of turning the auto-tune feature on and off. If it is off, the data is just passed into the simulated sine
signal with the same settings as stated above. However, if the auto-tune feature is on, the frequency VI
is used to create the desired pitch values of nine octaves ranging from 16 Hz-21 kHz. This array of values
is then used with the thresholding function to assign the input data set values to actual musical tones.
These values are then indexed into an array and extracted for output into the simulated sine signal.
The simulated sine signal is then outputted through a second DAQ Assistant to the myDAQ’s audio jack
as sound. The settings of the DAQ Assistant were an input range of -2 – 2V and 3,000 continuous
samples read at 200 kHz.
3
Value Statement
This project’s value can been seen in the little amount of space it takes up, the minimal costs it takes to
make it, and the ease of play compared to the traditional Theremin. Combining both hardware and
software helped to greatly downsize the space the instrument requires and the cost that goes into its
creation. The hardware components were extremely cheap and take up about a square foot of space.
The software can be used on other various projects as well making it extremely useful and relatively
cheap and it requires no physical space to be implemented. The software also helps to make the
instrument easier to play because of the front end user interface that allows for customization of the
instrument while it is in operation.
Conclusions
To decrease the production time and cost of a traditional Theremin, we constructed a Photo-Theremin.
This was done to make the Theremin more user friendly. By giving the customer the ability to control
the frequency range, the instrument would be much easier to customize to the musician’s specific
needs. Some difficulties hindered us from completing this lab in a timely fashion such as the sample
rate. This took us a long time to fix the bugs, and in the end, we never made the signal sound quite like
an analog signal. Although the sample rate ratios were never perfect, the device still played through all
of the frequencies and intensities. We succeeded in creating a Theremin using photodiodes, but the end
product did not function to the caliber that the original Theremins functioned.
4
Appendix
Gantt chart
Figure 1: Gannt Chart
Initial High Level Block Diagram
Inputs: light & user settings
Output: sound
Photodiode circuit
with op-amps
•One diode for
frequency
•One diode for
ampllitude
Analog input to
myDAQ
•Output from
circuit
•Acquire with
DAQ Assistant
Convert to arrays
of scalars
•Split the data
first
•Output to
waveforms
Create simulated
sine wave
•Sample
continuosly
•Mono audio
output signal
Output to Audio
Jack
•Control
freq(pitch)
•Control amp
(volume)
Figure 2: N=1 Block Diagram
Justification: Two photodiodes will be used in the circuit, one for pitch control and the other for volume
control. These will be incorporated into two separate amplification circuits which will amplify the
changes in the diodes’ leakage current due to the changing light intensity which will eventually be
transformed into an audio tone after some signal processing done by LabVIEW. The circuits’ output, in
an analog form, will be inputted to the myDAQ and converted into scalar arrays so that the data can be
manipulated. A sine wave will then be simulated using the adjusted frequency and amplitude ranges and
outputted to the audio jack. This will successfully convert the amplified light intensity changes to an
audible audio tone output.
Analysis: The initial block diagram was very similar to what the end product looked like. The photodiode
circuit was built and then its outputted waveform was taken in by the myDAQ. It was then manipulated
into an array of scalars. Next, the data was normalized, which was not a part of the original block
5
diagram, but it should have been. The frequency portion was then given an auto-tune feature which was
also not in the original block diagram because it came as an additive to the project in week 3. Finally,
the data was sent into a simulated sine wave function and was output to the myDAQ’s audio jack.
Circuit
Figure 3: Op Amp Circuit Layout
The circuit diagram is shown here. It is a simple inverting amplifier circuit using the photodiode as a
current source. This circuit amplifies the signal and inverts the signal for a positive voltage.
6
LabVIEW screenshots
Figure 4: Main LabVIEW VI Block Diagram
The first issue encountered when writing the code for this project was how to convert the sampled data
into a type double form for manipulation. The data could not be converted directly, so it was inserted
into a blank array and extracted as type double, which seemed like a roundabout way of doing things
but was the simplest solution. After this voltage is scaled by a control for sensitivity, the next challenge
was to normalize the signals. The current scaled voltage is compared to past values which were
initialized to one and the max is taken. This maximum value is used to normalize the voltage and then is
passed by a shift register back to the beginning. The maximum value for the frequency and amplitude
are then set by multiplying the normalized voltage value by a control.
For the frequency, the value is passed to a case statement controlled by a Boolean switch for auto
tuning. If the switch is on, the value enters the statement and is used to find the index of an array with
the closest possible frequency value. This array was created in another subVI shown below. If false, the
frequency value is just passed through the case statement. This value is extracted from the array and
converted to type double, then displayed to the user and inputted to the simulate signal module. The
amplitude is done the same way without the auto tuning.
The simulated sinusoid is then displayed on the front panel and written to the MyDAQ’s audio output.
The front panel can be seen below.
7
Figure 5: Main LabVIEW VI Front Panel
Figure 6: Frequency LabVIEW VI Block Diagram
The auto tune array initialization subVI is done simply by manually entering the first array then doubling
the array values and appending them to the end of the initial array. This is repeated until the array is
filled and then is outputted to the main VI. The front panel of this subVI simply shows the output array
and can be seen below.
8
Figure 7: Frequency LabVIEW VI Front Panel
9
Figure 8: Input DAQ Assistant Settings
The frequency voltages were read on the channel named Voltage and the amplitude voltages on channel
Voltage_0. The minimum and maximum voltages were set to range from 0 to 10 volts, within the range
of our minimum (no light) and maximum (flashlight) voltages. The sample rate was optimized through
trial and error by checking for errors at the input and output. Continuous sampling was used to ensure
the fasted rate possible. The samples to read was minimized to limit the time it takes to read and the
rate was maximized to increase the response rate of the processing system. These values are identical to
the output settings because one will be limited by the other.
10
Figure 9: Simulated Sine Wave Settings
Configuring this sine wave was fairly simple since the amplitude and frequency are set externally by the
rest of the main VI. The sampling rate was set to the same value as the input and output settings and
the number of samples was determined by the run as fast as possible setting.
11
Figure 10: Output DAQ Assistant Settings
The voltage output is sent to the audio output jack of the MyDAQ, which has a maximum voltage
magnitude of two. As said above in the input settings, the sampling rates are the same to optimize the
process.
Spec Sheets
Op Amp TL071 - http://www.ti.com/lit/ds/symlink/tl071a.pdf
Photodiode OP906 - http://www.ti.com/lit/ds/symlink/tl071a.pdf
12
Bill of Materials
Component Cost Description
TL-074 Op-Amp; Vcc±=±18V; Vin=±15V; Vid=±30V
$0.95
NI myDAQ Multi-functional signal generator, DMM, Oscilloscope, and power supply.
$175.00
Photo Diodes 3mm photodiode;
$3.96
Breadboard 4 buses; Tie-point 1660
$16.00
Total
$195.91
13
Download