Self-Playing Xylophone

Self-Playing Xylophone

Self-Playing Xylophone Matt McKinney, Electrical Engineering Project Advisor: Dr. Tony Richardson April 1, 2018 Evansville, Indiana Acknowledgements I would like to thank Jeff Cron, Dr. Howe, and Dr. Richardson for helping me through the senior project process. Table of Contents I. Introduction II. Background and Problem Definition A. Background B. Problem Statement III. Design Approach A. Design process B. Software Design C. Hardware Design D. Mechanical Design E. Parts List F. Standards and Constraints G. Costs IV. Results V. Conclusions and Recommendations A. Recommendations B. Conclusions Appendix A Appendix B Appendix C References List of Figures 1. Picture of Xylophone 2. Software Flowchart 3. SD Card Circuit 4. Key Striking Circuit 5. Solenoid Mechanical Layout 6. Final Project List of Tables 1. Table of Costs I. Introduction Many engineers struggle with the concept of music and many musicians struggle with the concepts of engineering. Music and engineering are simply two very different subjects. This project, a self-playing xylophone, blends these two unlike subjects. This is done by using engineering principles to create music. To do this first a microcontroller reads in a song. Next the microcontroller uses pin manipulation as an input to supporting circuitry. Finally this circuitry controls solenoids which strike xylophone keys to play a song. The final result plays a song. This project is useful for STEM education purposes. It could be taken into a school and used as a demonstration piece to excite kids about the possibilities of engineering. II. Background and Problem Statement A. Background Before addressing how to play a xylophone with solenoids, it is important to explain how humans play xylophones. The musician holds two mallets. The instrument is a collection of keys that each play a specific note when struck by a mallet [1]. Striking these keys in the right order plays a song. A xylophone is pictured in Figure 1. Figure 1: Picture of Xylophone [2] B. Problem Definition The minimum specification of the project was to play a simple song. This was done by using the microcontroller to control 4 solenoids that strike the keys of the xylophone. The microcontroller had a song preloaded on it. It will directly control 4 pins that were each linked to a solenoid. The microcontroller used its programming of the song to play the xylophone. After this was done the project was expanded upon. After a simple machine capable of playing music was created, the next step was to improve the system. This was done by adding features and expanding on what was already completed. The project currently plays 15 keys. A demultiplexing system allows for controlling more solenoids. A power circuit powers the solenoids. The software also plays more keys and reads in musical files. The final product is also user accessible both in price and function. This means that a normal person should be able to use this product and also afford it. III. Design Approach A. Design Process The first task is to read in the song and interpret it. To read in the song it was chosen to use an SD card. The challenge with this was to access the contents of the SD card with the microcontroller. This was further complicated when one of the pins for this was already in use as an output. The problem had to be worked around by rewriting the output code to use different pins. The first musical file format it was planned to use was MIDI, but MIDI was overly complicated for this project. So instead, ABC file notation was used. It is not overly complicated, but still holds all the song information that this project needs. ABC is also easily interpreted as characters by the microcontroller. For the output to control the solenoids, the project uses pin manipulation. The challenge was to pick the correct pins because the microcontroller has a limited number of pins. This problem became further complicated by the use of an SD card and using serial communication for debugging. The solenoid activation pins had to be reassigned. The circuitry must be capable of controlling and powering the solenoids. It is necessary for the logic circuit to be able to control all of the solenoids given a limited number of microcontroller pins. This problem was further complicated by the fact that it is not easy to locate the correct parts. Many of the ideal parts are no longer in production. When powering the solenoids, it was important to find the right components that could provide the necessary amount of power, not burn out while providing that power, and also be cost effective. The solenoids must be able to play the song while also not drawing too much power. They must also be cost effective. The mechanical had to be made so that the project could be supported. First a small prototype was built only using a couple of keys. After that a full design was created and constructed considering aesthetics, durability, functionality, and cost. B. Software Design At the highest level the software reads in a musical file from an SD card. Then it uses the file information to control I/O pins that play the xylophone keys The microcontroller establishes communications with the SD card. Next, it opens up the musical song file. Once the ABC (file overview of ABC file notation in Appendix A) is being read off the SD card, the next step is to create an output based on the ABC file input. Stepping through the file line by line, each character is evaluated. First, the header section of the ABC file is ignored. Next, each note is read in. The code checks where the note is on the scale and how long it is played. This is done determining if the note is an upper or lower case letter. Then subtracting based on whether it is upper or lower case. Then it is checked if the note has a character a certain character after it. If there is, another subtraction is made. Through these two subtractions, the note in the song is converted into a number which correlates to a position in an array. The position in the array correlates to the physical key on the xylophone which is to be played. After determining the note, the next character is checked to see how long the note is to be played and a delay is set that correlates to how long the note should be played. Finally, to play the note the physical key to be played is loaded into the I/O pins. The output is quickly enabled and disabled to strike the key and then there is a delay corresponding to how long the note is to be played. If the note is within range, the note is played for the desired time. Then the next note in the song is checked and the process is repeated until the song is over. A flow chart of the code is given below in Figure 2. Figure 2: Software Flow Chart C. Hardware Design At a high level, the hardware provides power to the project, allows for the SD card to communicate with the microcontroller, controls and powers solenoids, and provides power to the project. The SD card circuit is straightforward with wires running directly between the microcontroller and SD card reader. The circuit shown below in Figure 3. Figure 3: SD card circuit After the music file is interpreted by the microcontroller the next step is to demultiplex the 5 pins from the microcontroller into a single output. This was done by making a 5 to 32 demultiplexer. This was done by cascading five 3 to 8 demultiplexers. The demultiplexers are active high because the solenoid retracts when they are turned on. This circuit runs on 5 volts. After the demultiplexer there is a power circuit which powers the solenoids. This circuit consists of an NPN transistor which is being used as a switch and a diode snubber. This circuit is triggered by the 5 volt logic circuit, but provides 12 volts to the solenoid. The circuit is shown below in Figure 4. Figure 4: Key striking circuit The solenoid is used to strike the xylophone key. The solenoid has an electromagnet which retracts the cylinder when it is turned on and releases the cylinder when it is turned off. To strike the key the solenoid is quickly turned off and then back on. This is shown below in Figure 5. Figure 5: Solenoid mechanical layout. D. Mechanical Design The goal of the mechanical design is to support the rest of the project. The mechanical design consists of two parts: the xylophone and the support apparatus. The xylophone was first altered by cutting off the extra plastic with a Dermal tool. After doing this there was only the xylophone. Next, polycarbonate was cut and drilled and mounted above the xylophone with a hole above each key. A solenoid was mounted in each hole so that it can strike its corresponding key. A polycarbonate sheet was mounted above the unused sharps and flats keys to support all of the hardware and software electronics. The mechanical design is shown in Figure 6. E. Parts List SD Card Module: Used to interface SD card with microcontroller. [3] UNO R3 Board ATmega328P: Microcontroller used in project. Picked because this Atmel chipset is well developed, cost effective and the engineer had experience with it. [4][5] MM74HCT138N: 3:8 demultiplexer used to link micro output to solenoid power circuit. Also active high which is required for project. [6] N2222: NPN transistor used to power solenoids.

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    19 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us