cdr_004_brainshare_2015-3-8

16
Lab 2 Optical Theremin Team Brainshare, Section 004 Harrison Ruhl, Garrett Hipkins, Ben Kilheffer

Upload: garrett-hipkins

Post on 30-Sep-2015

9 views

Category:

Documents


0 download

DESCRIPTION

Concept Design Report

TRANSCRIPT

  • Lab 2 Optical Theremin

    Team Brainshare, Section 004 Harrison Ruhl, Garrett Hipkins, Ben

    Kilheffer

  • Abstract Our task was creating an optical Theremin in which the frequency and the amplitude of the audio signal can be controlled by light using photodiodes and operational amplifiers. For this task a TL074 Op-Amp was used to convert the output current of two photodiodes into voltages. Then a MyDAQ was used to take the voltages into LabVIEW where the data is normalized and placed together into one signal. Additional requirements called for the use of auto-tune and distortion, which can be selected on the front panel of LabVIEW. The signal is then passed back through the MyDAQ and to the speakers through the audio output. Introduction Theremin instruments have been around since 1928. Our task was to use light intensity to create a Theremin instrument, or an optical Theremin. The task of creating an optical Theremin was given to the group with the requirements that the amplitude and frequency is to be controlled by photodiodes and an operational amplifier. Secondary requirements for the design were to have the capability to auto-tune the sound and to add distortion to the sound. The design requirements were as follows: Hardware and Main VI

    1. The frequency and amplitude of the output waveform must be controlled by photodiodes

    2. The user must be able to set the minimum and maximum frequency and amplitude on the front panel

    3. The output waveform and the frequency and amplitude must be displayed on the VI front panel

    4. The input voltages for both controls must be displayed on the front panel Auto-tuning

    1. The user must be able to turn auto-tuning on and off from the front panel 2. The VI must adjust an input frequency to the nearest in-tune frequency if turned

    on Distortion

    1. The user must be able to specify what type of clipping: hard, soft, or none, is used

    2. The user must be able to set the clipping percentage between 30% and 90%

  • 3. Hard Clipping must clip any value over the clipping percentage 4. Soft Clipping must decrease any value over the clipping percentage based on the

    percentage Rationale A traditional Theremin is a musical instrument that the musician does not physically touch. Antennas identify his or her physical hand location to vary the frequency and amplitude of the audio signal. Our optical Theremin is a variation of this concept. Instead of antennas, we use photodiodes to change the frequency and amplitude of the audio signal. These photodiodes produce a current that is directly related to the amount of light intensity the silicon chip receives. This varying current then becomes the varying voltages for the audio signal. The analog voltages are then sent through a signal-processing program to generate the audio signal. Every musical note has a frequency associated with it, and when a frequency matches that value, it is considered in-tune with that note. Notes that do not equal this value are considered sharp or flat of the note, based on whether it is higher or lower than the value respectively, and are also considered out of tune. Auto-tuning involves raising or lowering the frequency of an out of tune note to the nearest in-tune value, in order to make it sound better. The auto-tuning portion of the LabVIEW program auto-tunes frequencies based on a list of in-tune frequency values provided. The list of frequencies was generated using the list of first octave frequencies provided to us in the Lab 2 handout. It was also generated using the relationship that the frequency of any note in the next octave is twice the frequency in the current octave. For example the value for C1 is 32.70Hz, so C2 would be 65.4Hz, and so on. There are two types of distortion included in the distortion subVI, hard-clipping and soft-clipping. Distortion creates a cut-off point where any amplitude values above that point will be clipped. For hard clipping any value over this cut-off point will be set to the value of the cut-off point, creating an immediate cut-off. For soft clipping the amplitude of any value over the cutoff is reduced to create less sudden and more gradual cut-off, while still clipping the signal.

  • Block Diagram Analysis The high-level block diagram can be seen in appendix 1. At the most basic level, this project was broken into three components: input hardware to control the Theremin and create the LabVIEW inputs, software to process the inputs and create the audio output, and hardware to output the result as sound. These components were broken down again into the operations the input hardware would perform and what the audio output would be output through. The final layer of the block diagram shows the specific parts or programs we planned to use to do these operations. The block diagram in appendix 1 is the initial diagram we developed. After this was developed the auto-tuning and distortion requirements were added to the project and we began adding additional VIs to the main LabVIEW VI. These additional VIs could form another layer of the block diagram, although this is not shown on the diagram. Implementation Work on the optical Theremin was done over a 5 week period as outlined in the work schedule in appendix 2. Early work focused on designing the initial high-level block diagram and the circuit to create the input voltages. As work progressed the focus shifted to designing the individual VIs for the LabVIEW code, with the final week devoted to troubleshooting and debug. These sections describe the final state of each portion of the Theremin. The modifications made to the design of each section are discussed in the next section. Hardware Circuit A schematic of this circuit can be seen in appendix 3. The circuit contains 2 photodiodes, 2 10M resistors, and 2 TL074 Op-amps powered at 15V. The photodiodes produce a current based on how much light they receive which is converted to a voltage by the op-amps. Each voltage output for the op-amp configurations is equal to -I*R volts. Since the photodiodes conduct a reverse bias current, the voltage at the output is positive. These voltages are input to the LabVIEW VI via a MyDAQs analog inputs and act as controls for the frequency and amplitude of the Theremins output respectively. Main VI A screenshot of the program front-panel is provided in appendix 4. A list of the DAQ-assist and simulate signal parameters can be seen in appendix 5 A screenshot of the main VI block diagram is provided in appendix 6A.

  • The main VI uses the built-in DAQ-assist blocks to sample the input voltages and convert them to arrays which are averaged to produce a single value for processing, one for frequency and one for amplitude. Each value is passed through a normalization subVI to ensure that it remains within the user-defined range for it. The normalized frequency passes through the auto-tuning subVI and the frequency and amplitude are fed into a simulate signal block. The simulate signal block generates a sine wave of the specified frequency and amplitude which is then output to the distortion block. The output of this block was then fed to the MyDAQ audio output using a second DAQ-assist block. The front panel of the main VI contains controls for the minimum and maximum frequency, and knobs to control the minimum and maximum amplitude, which are limited to a range of -2V to 2V to match the audio-output limits. An on/off switch for the auto-tuning and a stop button are also present. A three-option enumerated control allows the user to specify what kind of distortion, if any, is used, and a fill-slider allows them to control the clipping percentage. In addition to the audio output, the output waveform, frequency, and amplitude are displayed on graphs, along with the input voltage values controlling the frequency and amplitude. Amplitude Normalization A screenshot of the amplitude normalization subVI is provided in appendix 6B The amplitude normalization sub-VI ensures the output amplitude remains within the range specified. It negates the minimum value and shifts all of the input values by that amount. The shifted input is then compared to the 6V maximum (also shifted) to determine the percentage of the maximum amplitude setting to output. It then makes sure the value is within the specified range before shifting it back and outputting it. Frequency Normalization A screenshot of the frequency normalization subVI is provided in appendix 6C. The frequency normalization VI first determines what percentage of the maximum expected voltage (6V) the input voltage is, and converts it to a frequency relative to the maximum frequency the user wants. This value is then compared to the max and min frequencies and raised or lowered to them if it exceeds either before being output. No shifting is done here as we expect the minimum frequency will always be at least 0.

  • Auto-tuning A screenshot of the auto-tuning subVI is provided in appendix 6D. The auto-tuning sub-VI, if auto-tuning is on, will first compare the input frequency to the lowest frequency note of each octave to determine which octave (represented by a row of a 2D array) the frequency is in, which will be extracted from the array. That row will then be fractionally indexed, with the input frequency as the threshold. The output index is rounded to an integer, and the value at that index of the array row is output as the frequency. If the user does not have auto-tuning on, the input frequency passes directly through the subVI and is output with no change. Distortion A screenshot of the Distortion subVI is provided in appendix 6E. The distortion subVI of the Theremin did not work as expected, and the there are still several errors in it. Initially we planned to modify the amplitude before the output signal was generated by the simulate signal feature. We would have used the clipping percentage the user specified to determine what value to clip the amplitude at and then modified amplitude values higher than that point. An enumerated control would allow the user to specify which type of clipping, if any, was used. The result of this would then be output to the simulate signal block. Using feedback from the lab TAs and debug, it was determined the entire block needed to be moved after the simulate signal block to modify the output signal directly. By doing this, nothing needed to change to determine the clipping point, but the remainder of each case of the case structure needed to be inside a loop, as it now needed to process an array of values, not a single value. The feedback also resulted in changing the subVI to use the in-range and coerce block in LabVIEW, which we were not initially using. The range was set between the positive and negative values of the clipping point. The in-range output of this block was then used to determine whether to output an unmodified value (if it was in range) or a coerced value (if it was out of range). While the program can run without errors with the block and output correctly, neither the hard-clipping or soft-clipping operations appeared to be working as they are intended. The screenshots included represent the state of the subVI after these changes were made.

  • Materials Needed A complete bill of materials for this project is included in appendix 7. Design Modifications Some portions of our circuit and code required significant modification as we tested them, while some required very little. We initially began using smaller resistance values in the photodiode circuit, but found that they gave us a smaller maximum voltage to the MyDAQ, so we began increasing the resistance. We eventually settled on the 10M resistors as they gave us approximately a 6V maximum, which in turn gave us a large number of step values. The main VI did not initially have the distortion subVI where it is, as it was initially prior to the simulate signal block. The reasons why this was moved were detailed in the distortion portion of the implementation section. Additionally the output waveform graph is generated from the signal before it passes through the distortion block. It should be generated after the block and we did not realize this mistake when we moved it. These changes required us to modify the DAQ-assist parameters several times. The values in appendix 5 are the final values we used. The auto-tuning VI initially was going to use build array blocks to create the 2D array of frequencies. We could not get the array to generate correctly, so we ended up putting the values in manually as a 2D array constant. Several other minor changes were made to the interior of the case structure as this VI was debugged. The frequency normalization VI required fairly little modification. The amplitude normalization VI initially had no shifting and compared the input voltage to the user set maximum amplitude instead of the max input of 6V. This caused issues keeping the output in the specified range and the later caused the VI to think the input was almost always higher than the maximum output, and therefore always output the max value. Both of these were changed to fix these issues. The changes and issues for the distortion VI were covered in detail in the distortion section of implementation. Conclusions An optical Theremin is realizable by constructing a current to voltage converter with the use of a TL074 Op-Amp, two OP906 photodiodes, two 10M resistors, a MyDAQ, and LabVIEW software. In addition, our design meets the hardware and main VI design

  • requirements. As described above, there were issues with the distortion part of the code and therefore we were not able to meet those design requirements. The optical Theremin was realized by using the two photodiodes as current sources that varied based on the amount of light intensity. This current source was then turned into a voltage output based on the configuration of the TL074 Op-Amp seen in appendix 3. These two voltages are then wired into the analog inputs of the National Instrument MyDAQ. The analog voltage inputs are then manipulated through the use of LabVIEW software. Within the LabVIEW software, there are subVIs created to handle signal normalization, amplitude and frequency modulations, auto-tune features, and distortion modulation. These features can be seen in the front panel from appendix 4. The output of the LabVIEW software was through the MyDAQs 3.5mm audio output. As discussed earlier, we had some issues with the distortion features of the overall project. We originally placed the distortion features before the generated signal, so the distortion was just changing the code output number that is sent to the signal generator instead of changing the generated audio signal. We attempted to correct this feature, but we were unsuccessful due to the fact that we had a limited amount of time to fix the feature. The main objective to create an optical Theremin was accomplished, however not all design requirements were met in the allotted time. The hardware designs were successfully implemented and part of the software design was successfully implemented. The distortion feature of the software was the only requirement not successfully realized.

  • Appendix

    1. Initial Block Diagram

    2. Project Work Schedule (Gantt Chart)

  • 3. Hardware schematic

    4. Front Panel

  • 5. DAQ Assistant Parameters DAQ Assist 1(left side)

    2 analog voltage input channels on ai0 and ai1 N samples sampling 10 samples to read 1kHz sample rate

    Simulate Signal

    20,000 samples per second 2000 samples

    DAQ Assist 2(right side)

    1 voltage output on audio left Max voltage of 2V Min voltage of -2V Continuous Sampling 2k samples to write 20 kHz sample rate

  • 6. LabVIEW block diagrams

    6A: Main VI

    6B: Amplitude Normalization subVI

  • 6C: Frequency Normalization subVI

    6D: Auto-tuning subVI

  • 6E: Distortion subVI

  • 7. Bill of Materials

  • 8. Circuit