Accelerometer Music Instrument University of Texas at Austin TI Innovation Challenge 2015 Project Report Team Leader: Team Members: Advising Professor: Video Texas Instruments Mentor (if applicable): Date:12/13/2014 Qty. List all TI analog IC and TI processor part number and URL James Tsao, jmtsao@utexas.edu Dushyant Bhatnagar, dbhatnagar@utexas.edu Jonathan Valvano, Provide link to video that you ve uploaded to www.ti.com/videos 1) Explain where it was used in the project? 2) What specific features or performance made this component well-suited to the design? 1 LM3S811 48 pin LQFP Used as the primary processing unit of the project. Timers and relative ease of soldering onto a PCB made this component well-suited to our design. 1 TLV5161 (12-bit DAC) Used as a DAC to output sound in the project Familiarity with the component from previous projects made it well-suited to our design. 1 TPA301 audio amp Used to amplify our audio output from the DAC to a 32 ohm speaker. The small size and relative ease of soldering this component made it suitable to our project. 1 LM4041 shunt diode reference Used to create a voltage reference for our DAC. Familiarity with the component from previous projects makes it suitable for our project. 1 LM2937 3.3V regulator Used to regulate power to the board. Small size and expected power needs were considered when choosing this regulator. Submit your TI Innovation Challenge project to http://tiic-na.hartehanks.com. Your team is encouraged to post your project as early as possible- Your submission will be kept offline until the contest has officially closed! Instructions: Submit your project and include the following documents o Your full class report, which much include this TI project report. o Upload a video of demonstrating your project to www.ti.com/vidoes (must log into my.ti) and provide the link to that video in this project report. We d love to see your team engaging with TI products! o Link to supplemental photos
Project Abstract The objectives of this project are to design, build, and test an accelerometer-based musical instrument. The project will provide educational experience in interfacing a two-dimensional accelerometer, interfacing a DAC and speaker amplifier, and performing DAC output based on real-time input from the accelerometer. Additional objectives include interfacing buttons and an LCD screen which will provide greater user feedback in operating the instrument. The overall goal is to create an intuitive instrument to create music with, based on tilt. Please submit your class report with this one page document. Your class report should include the following (Max of 10 pages, excluding appendix): Table of contents List of figures and tables A detailed written description of the project design Hardware Design Any Software Architecture used (include any software code as part of Appendix) Testing and Results / Conclusions Future Work / Recommendations Acknowledgements and/or References Appendix: schematics, CAD drawings, Critical IC Bill of Materials, User Manual, etc. SSQW057
Table of Contents: Accelerometer-Based Musical Instrument Objectives and Project Description 1 Hardware Design 3 Software Design.5 Measurement Data.5 Analysis and Discussion 9 Figures and Tables: Figure 1: Schematic of hardware component of project 3 Figure 2: DAC output testing based on accelerometer tilt 5 Figure 3: Accelerometer output testing based on tilt. 7 Table 1: DAC testing. 8 0
A) Objectives 1. Overview 1.1. Objectives: Why are we doing this project? What is the purpose? The objectives of this project are to design, build, and test an accelerometer-based musical instrument. The project will provide educational experience in interfacing a twodimensional accelerometer, interfacing a DAC and speaker amplifier, and performing DAC output based on real-time input from the accelerometer. Additional objectives include interfacing buttons and an LCD screen which will provide greater user feedback in operating the instrument. The overall goal is to create an intuitive instrument to create music with. 1.2. Process: How will this project be developed? The project will be developed on the LM3S811 microcontroller. Inputs to the prototype will include three buttons and a ADXL202 two-axis accelerometer. Outputs to the prototype will include an ST7735 LCD screen and a speaker. The speaker will be interfaced through a TLV5616 DAC and a TPA301 surface-mounted audio amplifier. The system will be built on a PCB and run on battery power. The LM3S811 will be flashed using JTAG from a TM4C123 microcontroller, which will in turn be connected to a personal computer. The main software modules being used in this project are a screen control module, a DAC/sound output module, an input capture module for the accelerometer, and a button interface/debouncing module. Our general design process will be to design and test the DAC and screen output modules, then to do the same for the accelerometer and button input modules, and finally to interface all of the modules and test the complete system. 1.3. Roles and Responsibilities: Who will do what? Who are the clients? Dushyant Bhatnagar and James Tsao will develop, build, and test the system. They will develop a PCB layout, assemble the board, and develop code to run on the board. The clients of this system are the other EE445L students, TAs, and professor, as well as anybody else interested in using this system as a musical instrument. 2. Function Description 2.1. Functionality: What will the system do precisely? The system s primary functionality is to take the tilt of the instrument using and accelerometer and to convert that tilt into a musical output. This musical output will be based on the tilt of the instrument and gestures performed with the instrument, such as quick or slower shaking of the instrument. This output will be outputted through a DAC and an audio amplifier, and into a speaker to output sound at a volume loud enough to be heard from at least three feet away. The sound output can be switched between voices by input from three buttons. These buttons will be used to interface with an LCD screen that will display a menu and information about the current sound output. In this menu, the user will be able to change the voice of the instrument, the volume of the instrument, and various other options, such as free-play mode or a guided tutorial mode for the instrument. Upon turning the system on, this menu will display. The user will first select these aspects of the musical player, and then be able to begin creating music. While playing music, the buttons can be used to return to the menu or stop sound output from the instrument. The foreground will initialize the instrument and display current information about the instrument, including current volume, voice, and a waveform, to the screen. Background 1
processing will include interrupts to handle button input and to read input from the accelerometer. Sound output to the DAC will also be handled in a background thread. DAC output will be handled through manual SSI, without using an onboard SSI module. Instead, the ST7735 LCD will be handled through the LM3S811 s onboard SSI module. The buttons will be handled using edge-triggered interrupts on the microcontroller s GPIO pins, and the accelerometer will be handled using edge-triggered timer interrupts to capture the PWM waveform outputted by the accelerometer. The musical output will also be handled through timer-based interrupts that will output the correct waveform at the correct frequency to the DAC. 2.2. Performance: Define the measures and describe how they will be determined. The system s software modules must be well-organized and easily modified by future developers. The sound output should follow a reasonable and replicable pattern based on user gestures with the instrument. Backward jumps in the ISRs are not allowed. Some quantitative measures to take into account when operating this system will be the SNR of the DAC output, the power required to run the system, the operating time of the system on battery life, and the musical range of the instrument. 2.3. Usability: Describe the interfaces. Be quantitative if possible. Inputs include an accelerometer and three switches. These inputs will be attached directly to the PCB, but only the buttons will be exposed physically to the user. Outputs will include a 32-ohm speaker and an ST7735 LCD screen. A DAC and audio amplifier will be interfaced to the 32-ohm speaker. 2.4. Prototype: How will the intermediate process be demonstrated? The prototype system will run on the LM3S811 microcontroller, soldered onto a PCB along with all of the other necessary components and peripherals for the system. During some portions of testing, the project may be tested using a DC power supply rather than batteries. This is to verify the function of our voltage regulator and to conserve batteries during the testing phase. 3. Deliverables 3.1. Reports: The reports for this document will include a requirements document, documentation of this project s hardware design, an explanation of the project s software design, measurement data, and a page of analysis and discussion. 3.2. Outcomes: The physical outcomes of this project include a prototype of our accelerometer-based musical instrument and a report documenting the design and implementation of our prototype instrument. 2
B) Hardware Design 3
4
C) Software Design Our software design for this project consists of four major modules: an accelerometer handler, a button handler, a screen interface, and a sound/dac interface. Our main takes button inputs to start/stop playing notes or sound and to navigate menus, and then takes accelerometer input to alter the frequency of our DAC output to the speaker. This allows our instrument to play different notes based on accelerometer tilt. Menus and various measures of the note being played are displayed on the LCD. Our inputs, the accelerometer and buttons, are primarily handled through interrupts. The accelerometer uses a timer-based edge triggered interrupt to take the period of time that the accelerometer s PWM output is high. This allows our software to parse the varying PWM output that the accelerometer outputs, and then put that value through calculations to get a frequency value to output to the DAC. The buttons are edge-trigger interrupted with a timer-based wait to debounce them. The speakers are interfaced using SSI. Since the LM3S811 has only one SSI module, we manually operated an SSI transmission procedure to the DAC using GPIO output. The screen portion of our software uses the microcontroller s SSI module. D) Measurement Data DAC output testing based on accelerometer tilt: 5
6
Testing of accelerometer output based on tilt: 7
DAC Testing: DAC output value Voltage (V) 0 0 500 0.328 1000 0.630 1500 0.841 2000 0.884 2500 0.883 3000 0.883 3500 0.881 4000 0.883 Power consumption: The system runs at 3.3V and at a maximum of about 125 ma. This means that our system draws 0.4125 W at maximum. 8
E) Analysis and Discussion We can clearly see on the oscilloscope that the frequency of the waveform outputted to the DAC varies significantly based on tilt. The same goes for the accelerometer input. However, the accelerometer s PWM output would occasionally shake or jump in terms of the high period. Furthermore, we do not get the full 12-bit precision of our DAC, as evidenced by our DAC testing. We get about 11 bits of precision, likely from noise in our system. Because of these two factors, our sound output was not as clean as we had hoped, though it did vary recognizably with tilt. Our system draws significantly more current than we expected. Our predictions for our system s power consumption were based on a previous speaker-based project which drew at maximum 88 ma at 3.3V. Since our system sometimes drew 125 ma, our chosen voltage regulator was likely unable to handle the load of our system. Although the voltage regulator could regulate a 4.5 and 9 Volts to 3.3 Volts, it became extremely hot very quickly, and a nearby capacitor in the voltage regulator circuit popped. We likely should have used the LM2937 voltage regulator, which can handle up to 500 ma. However, due to time constraints we were unable to collect these parts in time for demonstration of our project, and had to do the majority of our testing using power from a DC power supply. During our soldering process, we also may have damaged our audio amplifier, or the noise in our system ruined its output. When testing the amplifier on an oscilloscope, it seemed to output random noise rather than the relatively clean DAC signal that we were outputting. We bypassed this problem by resoldering our speaker directly to the DAC. This made our sound output quieter, but significantly cleaned up our sound output. For future development, we might consider switching to a higher-power voltage regulator and switching out the surface-mount audio amplifier for a through-part component. Additionally, for the end user, we might try to reshape our PCB to make it more ergonomically accessible. 9