Sie sind auf Seite 1von 9

Laboratory 2 - Designing an Optical Theremin

Team #2: Monstars Peter Lin, Matt Brewer, Kyle merson !""# $ection %

Abstract The task outlined in this lab was to create an optical theremin using both circuitry and LabVIEW programming components. Our design used photodiodes in order to detect the intensity of the light in the room. We then used the NI my !" in order to transfer the light intensity information from the circuit to LabVIEW. Within the LabVIEW program we were able to normali#e the $alues of the input data. These $alues were used to generate a digital simulated sinusoidal signal. This signal was output using the my !"%s audio out &ack' which allowed the simulated wa$e to be produced as an audio output. !fter completing the initial portion of the LabVIEW code we then added in code that would allow us to auto(tune the signal. The fre)uencies of the input signals were compared to the fre)uencies of a specific musical key and were coerced to fit within the key. This design is easy to implement' and is fairly simple to ad&ust. Introduction ! Theremin is a purely melodic electronic musical instrument typically played by mo$ing the hands in the electromagnetic fields surrounding two pro&ecting antennae *http+,,www.merriam(webster.com,dictionary,theremin-. The Theremin detects the distance of each hand from the antennae' which control the pitch and $olume of the tone that is produced. !n optical Theremin uses a similar concept' but instead of using the disruption of an electromagnetic field' it utili#es light intensity to control pitch and $olume. This becomes possible by replacing the antennae with photodiodes. Our task was to create an optical Theremin with a detector circuit front end and signal processing in LabVIEW. Rationale ! photodiode is a de$ice that operates similarly to an LE . !n LE takes a $oltage or current and outputs it in the form of light' while a photodiode absorbs the light around it and then translates it to a $oltage or current. The photodiode uses a .IN &unction' which consists of a nearly intrinsic semiconductor region surrounded by hea$ily doped . and N regions. It is fairly simple to manipulate the amount of light that a photodiode absorbs' simply by obstructing the light source with your hand. This will make the operation of the optical Theremin akin to that of the normal Theremin. The photodiode operates as a current source' which means that we need a way to con$ert those currents in to $oltages before we input them into LabVIEW. ! transimpedance amplifier is an op(amp configuration that will allow us to do this. We configured our op(amp to do so by tying the non(in$erting terminal to ground. The

photodiode was placed so that the anode was tied to ground and the cathode was connected to the in$erting terminal. ! feedback resistor was placed between the output and in$erting terminals of the op(amp completing the transimpedance amplifier and allowing us to con$ert the currents produced by the photodiode into $oltages. ! my !" was used to read the input $oltage $alues. LabVIEW was used to ac)uire these $alues from the my !". LabVIEW also allowed the user to ad&ust the ma/imum and minimum light intensity le$els and the range of fre)uencies. The LabVIEW front panel displayed the wa$eforms that show pitch as a function of time and $olume as a function of time. It also displayed indicators that show the light intensities of the photodiodes. Initial Block Diagram and Justification

!t the most basic le$el *N01- of the diagram only the inputs' the o$erall transformation' and the outputs are labeled. The system inputs are the amount of light being detected by the photodiodes' the range of the light intensity' and the range of the output fre)uency of the music produced+ the latter two are user defined. The output of the system is a musical tone' which the user of the system is able to alter the pitch and $olume of by altering the amount of light that each of the photodiodes detects. The second le$el *N02- of the block diagram breaks down the transformation into three ma&or components. The circuitry segment of the transformation pro$ides the data to be input into the LabVIEW program. The LabVIEW code takes the information recei$ed from the my !" and manipulates it so that the desired output is obtained. The musical tones are then output using the my !"%s audio output &ack.

The third le$el *N03- of the block diagram breaks down each of the three main sections of the transformation further. The circuitry portion of the design is subdi$ided into a photodiode segment and an op(amp segment. The photodiodes are used to detect the amount of light that is around. The light is then con$erted to current and the op(amp' configured as a transimpedance amplifier' con$erts the current to $oltage. The LabVIEW segment is broken into $olume' pitch' and auto tune *own section- controls. The $oltages pro$ided by the circuitry portion of the design are normali#ed and placed in an array when entered into LabVIEW. The pitch and $olume of the musical tone produced is proportional to the amount of light that each of the two photodiodes identify. The musical tone is output through the audio output &ack on the my !" and is played through any speaker containing a 2,45 connection. Implementation The photodiodes used were the 678(2149(N diodes. These photodiodes input current into an op(amp configured as a transimpedance amplifier. 3.3 mega ohm resistors were placed in the feedback loop of this amplifier' which con$erted the currents produced by the photodiodes into $oltages. The $oltages ranged from 1.19 $ ( 1.: $ when placed in normal ambient room lighting. This means that the currents produced by the photodiodes ranged from 24.3 n! ( 624.3 n!. These $oltages were then input into the my !". ;ircuit <oard Layout

LabVIEW reads the $alues from the my !" for both photodiodes. The first $alue is used to set the fre)uency of the output tone while the second $alue is used to set the

$olume of the output tone. The LabVIEW front panel allows the user to ad&ust both the light intensity le$els and the range of output fre)uencies. It also displays the wa$eforms that control pitch as a function of time and $olume as a function of time. The front panel displays numeric indicators of the light intensities of both photodiodes and allows the user to turn on or off the auto(tune feature. The auto(tune subVI allows the user to select a key for fre)uencies to be tuned to. Input fre)uencies will be ad&usted to notes in the selected key before being output to the my !". =ront .anel isplay

LabVIEW Block Diagram Analysis The autotune feature of the LabVIEW code allows the user to further place limitations on the audio signal that is produced. The user can select a particular key and ha$e the output signal auto(tuned to certain fre)uencies that lie within key. The entire auto(tune subVI is encased within a case structure. If the case structure has an input that is false' then the input will be directly wired to the output *auto(tune is turned off in this case.- Otherwise' if the case structure has an input that is true' the auto(tune VI will run. The first structure in the auto(tune VI is a case structure that allows the user to select a key. Each key has a different array of se$en $alues which correspond to that particular key. The case structure selects a key based on an integer input' with each integer $alue mapping to a particular key *this map is shown with a comment.- Ne/t' a for loop creates an array that repeats the fre)uency pattern of the key for the desired number of octa$es.

This is done by multiplying each $alue in the input array by a power of two and appending it to the array. The completed array and input fre)uency are used as the inputs for the Threshold 2 !rray =unction. This gi$es the e/act inde/ $alue of the input fre)uency within the array *which is likely not an integer.- The resulting inde/ $alue is rounded to the nearest integer. The output fre)uency is the $alue of the array that corresponds to the rounded inde/ $alue.

!utotune <lock iagram The amplitude control block diagram normali#es the measured input amplitude to be between 1 and 2 depending on the ma/imum and minimum amplitude ranges. The fre)uency control block diagram first normali#es the input fre)uency to the desired amplitude range' and then it normali#es this $alue to the desired fre)uency scale *dependent on desired ma/imum and minimum fre)uency ranges.- The ma/,min $alues for both amplitude and fre)uency are set by the user on the main front panel. Optical Theremin without !uto(Tune

The autotune portion was written afterwards and added into the main block diagram as a subVI. Optical Theremin with !uto(Tune

=re)uency ;ontrol

!mplitude ;ontrol

Description of Design Modifications Throughout the design and testing phases of the pro&ect' our biggest challenge was determining the $alues for optimal sample rate and buffer si#e. The !" !ssistant parameters needed to be ad&usted to produce a smooth output signal' not a choppy' distorted signal. <oth the !" !ssistant >eader and !" !ssistant Writer were configured to perform at optimal conditions. If the number of samples to read is too large' the !" will take longer to read all the samples since there is more information to process. This will cause a lag in the response time to the change in light intensity hitting the photodiode. Through some trial and error' we concluded that the !" !ssistant would read 281 samples at 81k?#. =or the !" !ssistant Writer' we used continuous sample mode and ad&usted the buffer si#e to produce a smooth sinusoidal output signal. If the sample rate is too low' then the output will appear choppy and distorted. ?owe$er' if the sample rate is too high' then sample regeneration can occur.

@ample regeneration occurs when the !" !ssistant writes information faster than it is recei$ing the information. The same signal is regenerated and this produced an error from the program. The buffer si#e needs to be chosen strategically because as it increases the slower the program runs and the more >!A is being used. In the final design' the number of samples written was 61'111 samples at a rate of 41 k?#. !nother modification we made was the resistor $alue of the feedback resistor used in the transimpedance amplifier. In order for the optical theremin to be used in a wide range of lighting settings' we needed the gain of the amplifier to be $ery large. !fter ad&usting light intensity' we tested se$eral different resistor $alues including 821k ' 2.2A ' and 3.3A . The !fter some trial and error with the resulting $oltages *which depends on the ambient light'- we decided on two 3.3 A resistors for the gain of the two transimpedance amplifiers.

onclusion !n optical theremin' a musical instrument that can be played without physical contact' was designed and implemented. The my !" ac)uires a $oltage signal from the transimpedance amplifier circuit that depends on the light intensity incident on the photodiodes. LabVIEW processes this $oltage signal and outputs a sinusoidal wa$e through the audio output &ack on the my !". The result is a system that outputs a sound wa$e that can be can be ad&usted by $olume or pitch based on the light intensity that hits two photodiodes.

Appendices! <ill of Aaterials+ 678(2149(N photodiode+ B1.8C per unit *3TL1:9 Op(!mp+ B1.8C per unit NI my !"+ B2:C.11 3.3 AOhm >esistor+ B1.12 per unit *31.2 u= ;apacitor+ B1.13 per unit *3LabVIEW software *student edition-+ B31.11 <readboard+ B23.1C Total+ B323.C3 ;ost of Labor+ Engineering labor rate+ DB71.11,hour Time spent working+ D28 hours Estimated total cost of labor+ DBC11 Aa&or @cales Esed+