490 likes | 739 Views
ELECTRONIC MUSICAL INSTRUMENT Final Report. Mezzo Forte. Background:. Customer: Dr. Pinkston Problem Statement: Musical instruments take a lot of practice time to learn and play songs.
E N D
ELECTRONIC MUSICAL INSTRUMENT Final Report Mezzo Forte
Background: • Customer: Dr. Pinkston • Problem Statement: • Musical instruments take a lot of practice time to learn and play songs. • A need exists for a musical instrument that the user can use to play songs without previous knowledge of how to play any instruments, while having similar flexibility of playing an instrument.
Background: Product • An easy to use instrument • The note being played is controlled by a song file loaded onto the device • The timing and volume of each note is controlled by the user • Has a user interface to allow the user to select from a list of songs in memory
Concept of Operations: Device 1)Plug SD card into the device 2)Power the device ON 3)After the device finishes initializing, choose a song from the given menu using the up and down buttons 4)Press the PLAY button to start the song 5)Play notes from the given song file by pressing the resistive button. Change the volume of the note by changing the pressure applied to the resistive button. 6)Release the resistive button to stop the current note. 7)Continue Steps 5 and 6 until you wish to change songs 8)Press stop if you are in the middle of a song to quit. 9)Choose another song, or power off the device
Concept of PC Software 1)Plug in SD card to the computer 2)Start Mezzo Forte’s Song Generator 3)Using the provided GUI, select notes desired for new song 4)When finished, choose "Convert to .MFS" under File. 5)From here, the user will be guided in naming and saving a song file that the device can read. 6)The user can transfer any other completed songs onto the SD card 7)Remove SD card from the computer
Requirements: • Be capable of playing the range of a piano (27.50Hz-4186.00Hz) without sounding out of tune • Have an interface for choosing/aborting songs • Provide software for developing song files and assisting in transferring them to our device
Requirements: • Have a means for the user to control the timing and volume of notes • Provide a master volume control for the device • The cost shall not exceed $150 • Output the notes to an 1/8th inch TRS jack
Design Approaches • We choose Approach 1 (Micro to DAC) • Simplest hardware design • Most software out of any of the designs • Most familiar with the components involved • Seemed the most feasible for our application and with the budget and time constraints given.
Component Selection: Microcontroller • Needs: • Cheap development board • Enough I/O to complete our project • Software environment that is easy to debug • Fast enough to synthesize audio • Well documented
Component Selection: Microcontroller Processor Clock Freq. Memory I/O Dev. Board Cost C5505 100MHz 320KB 15 GPIO, SPI, I2C, UART, I2S $50 ATMega328 20MHz 31KB 14 GPIO SPI, I2C $30 AT91SAM7S256 60MHz 256KB 30 GPIO SPI, I2C $45.95
Component Selection: Microcontroller • We choose the C5505 (on the ezdsp development board) • In circuit debugger • Sample code inline with what we needed for our project • Development Board included a DAC • Several supported serial interfaces: SPI, I2C, UART, I2S • Fairly well documented board and development environment
Design: Audio • AIC3204 contains the DAC • already attached to our development board • sample programs existed showing how to communicate with it • Audio is synthesized on the DSP, then sent to the AIC3204 for convertion to an analog signal.
Design: Audio • The different frequency sine waves are generated from a pre-generated table, and stored in a buffer on the device • We then use the DMA controller on the C5505 to send this buffer to the DAC • the buffer is auto-resent once it finishes • The DMA controller allows the execution of the processor to continue while data is being transfered the DAC • This allows us to easily use the processor while playing a note (to perform tasks such as filling a buffer for the next note, changing the volume, etc.)
Design: Memory • Design Specifications: • Memory Size: 45kB (4 notes per second for 10 minutes) • Device/Song Memory interaction • Connection to PC • Three choices for song storage: • On-chip Flash memory • SD Card • USB Stick
Design: Memory • On-board M95512 Flash memory • Already on-board for program memory • 64KB Flash memory (for Program and Songs) • Loading data to this memory would require development drivers and software from TI • Small for our needs • External SD card • 1GB+ Memory • Interfaced to the C5505 with SPI • Can use multiple types of formatting to interface with PC • This provides a simple interface for the user to add songs on the PC: just by using the file manager
Design: Memory • External USB Flash Drive • 1GB+ Memory • Additional components needed to interface with development board. • Multiple types of formatting can be used to interface with PC • Our Choice: SD Card for Songs • No extra components needed • PC interaction is simply drag and drop, no special drivers • Inexpensive, can be replaced.
SD Card Design: Commands, Timing, and Responses 1) Send Command to SD Card in 6 byte frames. 2) Card Responds with R1 Response 3) If Successful R1 Response, returns start token, followed by data and CRC for data. 4) If unsuccessful, Error Token is sent
File Allocation Table 32 (FAT32): Preparing to read FAT32 Filesystem Master Boot Record: - Block 0 - Holds Boot Code, as well as partition data - Use Partition Data to find VolumeID VolumeID: - First Official Sector - Explains Format and physical layout of FAT's and data - Also Points you to Root Directory Sector From here, the FAT's need to be located from the information provided in the VolumeID. VolumeID Format
File Allocation Table 32 (FAT32): The File Allocation Tables • File Allocation Tables = Pointers • FAT sectors grouped into 4 byte frames • Frames in FAT's correspond to clusters • Follow the chain to follow data
Analog Button • Based off of a force sensitive button SEN-09375 • Basically a resistor whose resistance decreases as the force applied to the surface increases • We use the 10 bit ADC built in to the C5505 • The force sensitive button is attached as show on the right • This causes the input voltage to the ADC to be proportional to the force applied to the button.
Device Software - ADC • Dynamic Volume Control Procedure • Poll the ADC for the current resistive button reading • Scale and invert the measured value to our value range of volume • Compare the scaled value to our threshold value for playing a note. • If our scaled value is greater than the threshold, play the next note (if not playing) or continue playing the current note (if already playing) • Write the scaled value to the DAC to modify the audio volume level • Poll the ADC again and repeat
Brief Description of I2C • 2 wire bus • Each device on the bus has a unique address • When the bus is inactive all devices monitor for their address • Once the master device writes a devices address it acknowledges and prepares for future transfers
Design: LCD Screen • Part is NHD‐0420D3Z‐FL‐GBW • 4 lines, 20 Characters long • Connected to the microcontroller via I2C • Powered off of 5V • Main method of output to the user • Displays the menu, current song, state information
Design: Menu Buttons • Our limited GPIO pins would be enough for up to 5 buttons • In the interested of increased flexibility we choose to attach the menu buttons to an serial expander • The part we choose was MCP23017 • 16 GPIO pins • Configurable input, output, and pull-up resistors • I2C interface to the microcontroller • DIP makes it easy to work with • The buttons ground a individual pin on press
Design: Master Volume Control • A DIY classic pocket amplifier design by Chu Moy was used for the Master Volume Control due to: • Familiarity with the design. • Compact design • Virtual ground circuit
Design: PCBs • Early in development we realized we were going to need PCBs to fanout certain components • SD Card Slot • Edge Connector • Boards were also required for • Menu Buttons • Master Volume Control
Design: Power • Main device can be powered off a single 6V - 35V source • Powered via a wall plug • A linear regulator controls the power to the device • We currently do not have this connected, as it would disallow programming of the device (it has been tested and does work) • Master Volume requires 9V source • Currently a 9V battery • Could be tapped off the main power line (wall cube)
Design: Packaging • We choose DC-47P • 7.620 x 4.620 x2.555 inches • Using a Dremel Tool we cut the necessary openings • Packaged project shown below:
Software Development Environment • Main Software development tool was TI's Code Composer Studio v4 • Eclipse based environment • Run-time debugging • Developer ported functionality (printf) • Software Version Control - Tortoise SVN • Allowed us to collaborate on different parts and merge changes easily • Simple to backup and revert code to working versions
PC Software - Music Creator • Assists the user in creating songs for our device to play. • Presents to the user a piano keyboard, which they can click on to enter notes. • The octave of the note can be adjusted by the numeric box below the piano keys. • The reference note, octave, and frequency effect how the notes are converted. • Non-converted song files can be saved and reopened later • An install file was included with the PC Program (the .NET installer and the ALUT installer)
PC Software - MIDI Converter • Each MIDI file contains any number of Tracks, or sections of data • Any Track can have up to 16 channels playing simultaneously (16 different instruments) • There is other data present in a Track, such as Tempo, Key Signature, Note effects, etc. • Our device can only play one channel of one track at a time. • The MIDI converter breaks the file down into multiple Tracks, then prints out every channel of every track to a separate file • While this works in getting the channels to play, the main melody of a song tends to change channels, and as such does not allow for a desired conversion
Testing Test Name Description Desired Outcome Observed Outcome Sound Generation Validate that the generated notes are the correct waveform and frequency. Output is a sinusoid in tune Success Volume Control Validates that volume can be changed as more pressure is applied to resistive button or potentiometer is turned. The volume changes smoothly Success Memory Validates that songs can be selected and played from SD card. All songs files are visible to device and are correctly read Success Device UI Validates that there is a menu on the LCD and it is usable. Usable UI Success PC Software Validates that software creates songs usable by our device. Creates usable songs for our device Success
Issues Encountered • Poor sample code • Unstable development environment • Errors in development board design • Connectivity issues in hardware affecting software development • Stress while packaging caused the development board to be damaged
Lessons Learned • SVN is very helpful • Built-in functionality doesn't always work right • Just because it works the first time, doesn't mean it will work the next time. • The importance of reliable electrical connections • Dividing work up allows you to do two things at once, but its also important to note it doesn't allow doing one thing twice at the same time.
Next Steps • More built-in utilities (scales, demo songs) • Fabricate a custom PCB as opposed to using a development board • Integrate master volume control into main packaging • More featured MIDI converter • Note visualization: show where the user is in the song better • More natural analog control for volume and notes • Allow for the user to choose different instruments
Acknowledgments: • Dr. Pinkston • Mr. Powers • Chris Lacey • Everyone in the capstone lab who had to put up with our instrument all year
Demonstration • Demonstrate the Device • Power the device • Insert the SD Card • Choose a song • Play chosen song • In Settings, modify device settings • Choose the same previous song • Play the song, and demonstrate the modified properties • Demonstrate the PC Software • Create a song with the PC Software • Load it onto the SD Card • Start the device and plug in the SD Card • Choose the created song • Demonstrate that the created song plays as desired