User Tools

Site Tools


2014:fpga_pianoman

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
2014:fpga_pianoman [2014/12/16 01:12]
eweiler
2014:fpga_pianoman [2014/12/16 01:33] (current)
eweiler
Line 1: Line 1:
-====== FPGA Pianoman ​====== +====== FPGA Piano ====== 
-{{:​2014:​1.jpg?​200|}}+{{ :​2014:​1.jpg?​500 |}}
 ===Abstract=== ===Abstract===
-Never understand why a piano has so many keys? Think a single octave is more than enough? The FPGA piano allows you to practice your favorite scales or chords and even lets you listen to some of your favorite tunes while you take a break. Our piano has two different modes Piano Mode and Song mode. In Piano Mode, the user can toggle the switches to play different tones and chords from the eight notes in an octave. In Song Mode, the user can depress the buttons on the FPGA to play four different recorded sequences: scales, a simple repeating pattern, Happy Birthday, and (FPGA)Piano Man.+Never understand why a piano has so many keys? Think a single octave is more than enough? The FPGA piano allows you to practice your favorite scales or chords and even lets you listen to some of your favorite tunes while you take a break. Our piano has two different modes Piano Mode and Song mode. In Piano Mode, the user can toggle the switches to play different tones and chords from the eight notes in an octave. In Song Mode, the user can depress the buttons on the FPGA to play four different recorded sequences: scales, a simple repeating pattern, Happy Birthday, and (FPGA)Piano Man. 
 ===Reasoning=== ===Reasoning===
-We undertook this project because it offers a synthesis of digital logic synthesized on an FPGA and the world of analog signals that show up in other classes. Additionally,​ the piano provides a fun opportunity to explore musical interactions with the FPGA and translate between the frequencies of electronics and the frequencies of hearing. ​Also we spent a lot of time this semester modulating clock frequencies and coordinating timing, so we wanted a final project that allowed us to demonstrate our understanding of these concepts. ​+We undertook this project because it offers a synthesis of digital logic synthesized on an FPGA and the world of analog signals that show up in other classes. Additionally,​ the piano provides a fun opportunity to explore musical interactions with the FPGA and translate between the frequencies of electronics and the frequencies of hearing. ​Lastly, ​we spent a lot of time this semester modulating clock frequencies and coordinating timing, so we wanted a final project that allowed us to demonstrate our understanding of these concepts. ​
 ===Implementation=== ===Implementation===
 ==Note Tones== ==Note Tones==
Line 20: Line 20:
 ==Analog Circuit== ==Analog Circuit==
 For certain songs and Piano Mode we wanted the ability to play multiple notes at once as chords. This meant that we would need to be able to add any combination of our eight FPGA output signals (notes) together. We chose to build an analog summing amplifier because the circuit was reasonably easy for us to understand and implement quickly. The eight outputs of the FPGA are the eight voltage inputs to our voltage adder. The output is a scaled version of the sum of the input voltages and it is used as the input to the speaker. A diagram of the circuit is shown below. We used this site for reference and to choose our resistor values: http://​www.electronics-tutorials.ws/​opamp/​opamp_4.html. ​ For certain songs and Piano Mode we wanted the ability to play multiple notes at once as chords. This meant that we would need to be able to add any combination of our eight FPGA output signals (notes) together. We chose to build an analog summing amplifier because the circuit was reasonably easy for us to understand and implement quickly. The eight outputs of the FPGA are the eight voltage inputs to our voltage adder. The output is a scaled version of the sum of the input voltages and it is used as the input to the speaker. A diagram of the circuit is shown below. We used this site for reference and to choose our resistor values: http://​www.electronics-tutorials.ws/​opamp/​opamp_4.html. ​
 +
 We use a TLO81CP operational amplifier with Vcc = 5V and -Vcc = GND. We used an 8 ohm speaker. R = 1k ohm and Rf = 10 ohm. V1, V2, … V8 are the signals coming out of the FPGA. Vout is the signals added together and is the input to our speaker. To test our system, we used an Arduino Leonardo to provide a 5V power supply. We use a TLO81CP operational amplifier with Vcc = 5V and -Vcc = GND. We used an 8 ohm speaker. R = 1k ohm and Rf = 10 ohm. V1, V2, … V8 are the signals coming out of the FPGA. Vout is the signals added together and is the input to our speaker. To test our system, we used an Arduino Leonardo to provide a 5V power supply.
  
 +{{ :​2014:​2.jpg?​500 |}}
 +
 +===Testing===
 +To test our initial octave, we wrote a simple test bench that creates each note module and allows us to visually inspect the waveforms in ModelSim to ensure that the notes in our octave matched the frequencies for a C scale. This enabled us to verify relative period size and timing, but not much else as audio signals are significantly slower than the system clock and are very close together. As a supplemental form of testing we loaded our octave onto an FPGA and checked that the notes sounded correct by playing the scale a few times. This proved to be a very useful form of testing because our ears are quite good at detecting an incorrect octave or chord. ​
 +
 +To test our songs, we loaded the song data onto the FPGA and played it a couple of times, ensuring that notes and timings were correct. We also had a number of our friends listen to it and try to guess the song to gauge the quality of our versions. Knowing that we could not perfectly reproduce songs using our system we judged a song to be sufficiently correct when it could reasonably recognized as the original song. 
 +
 +===Difficulties===
 +Since no one in our team is particularly knowledgeable about music, we had to spend a bit of extra time figuring out how to encode proper octaves, notes, and frequencies for our piano. We also had to spend time figuring out how to make notes play for different amounts of time during songs so that we could play a range of eighth, quarter, and half notes. One difficulty that we did not find a particularly elegant solution to is the storage of song data. Our current solution involves hard coding a note to be played every 1/16th of a second which requires lots of space in the code and time for the implementer. ​
 +
 +===Continuing this Project===
 +If another team were interested in continuing this project in the future, the next steps would be to expand our song and note repertoire. To do this they could to find a method to execute slurs between notes and create notes for every key on the piano and expand the note encoding to support each note and common chords. Our code is available at https://​github.com/​benkahle/​fpga_piano and is comprised of piano.v which includes the piano logic, pianoTopLevel.v and piano.ucf which allow Xilinx synthesis, piano.do which runs a ModelSim simulation and shows waveforms of important signals, and songGen.py, the Python script for song data generation.
  
 +===Reflection===
 +==System Stats==
 +As a comparison to some of the other systems we have synthesized onto an FPGA this semester, the FPGA piano required the following structure components:
 +  * 1 112x4-bit ROM (Happy Birthday song data)
 +  * 1 183x4-bit ROM (Piano Man song data)
 +  * 1 43x4-bit ROM (“Random” song data)
 +  * 1 8x4-bit ROM (Octave song data)
 +  * 1 4-bit Adder
 +  * 3 8-bit Adder
 +  * 15 24-bit Up Counters
 +  * 56 Flip-flops
  
 +==Work Plan Reflection==
 +Because of volatile finals schedules we were unable to follow our original work plan but still managed to meet often and accomplish each task within a reasonable time frame. It was fortunate that we had scoped our green feature set to be relatively easy to quickly implement. This allowed us to be flexible about which of our yellow features we implemented.We chose to pursue switching octaves and playing chords because we were excited about the prospect of being able to play a wider variety of songs. This flexible work plan structure with green, yellow, and red features allowed us to get something simple working quickly and then have fun extending the project. ​
2014/fpga_pianoman.1418710327.txt.gz · Last modified: 2014/12/16 01:12 by eweiler