The Grand Cold Piano

 

ELE 408 Final Project

 

 

 

Our final project was the design and implementation of an electronic piano using the Cold Fire processor. We thought the idea of making sound from a computer board would be a fun and interesting thing to do, since we all love music. Our piano has several different play modes to choose from. The piano can be played in the “play mode”, where the user enters keystrokes on the keyboard to produce a note at a certain frequency, heard from the attached speaker. A user can play in the record mode where each and every note the user plays will be recorded into 1 of 5 different recorded locations. And Finally, the piano can be played in the “play back mode”, where a recorded song will be played out to completion. The piano has a definite niche in the consumer digital music industry as a piano/recorder device.

            To create a musical instrument we first had to understand the fundamental basics of sound.  All sounds, everything ranging from fire alarms to bird chirps, are composed of frequencies.  The human ear can only detect sounds with frequencies ranging from 20 – 20000 hertz.  Musical notes that we hear such as the A, B, C, C#, D, etc… have specific frequencies.   Our goal was to program the ColdFire to output a frequency to the speaker corresponding to the note the user typed in. 

            We used the Timer module to output the certain frequencies that we wanted.  As we learned in lab 4 , the frequencies that the TOUT pin of the Timer Module produced depended on the value of the Timer Reference Register.  The equation:  TRR = System Clock/(2*frequency*Pre-Scalar Value+1) where TRR is the Timer Reference Register and System Clock was 45 MHz and the Pre-Scalar Value was set to $7F and 16 corresponded to value we set in the Timer Mode Register to divide the clock by.  With that we calculated precisely the appropriate TRR values for all the notes that we have.  So to play a different note all we had to do was load the TRR with the corresponding value. 

            After having found out how to play different notes using the Timer Module we had to develop a user interface to get the notes from the user and relay it to the program.  What we ended up with was using the UART module to detect what key was pressed on the keyboard.  Using code that was very similar to the one we saw in lab 5 we were able to input the ASCII value of the key the user pressed.  This is in a loop that will continuously check the user input from the keyboard.  We then had many comparisons to detect exactly what value the pressed key was and depending on the key that was pressed it would branch to a subroutine corresponding to a note that would load the Timer Reference Register with the appropriate value to output the respective frequency to the speakers via the TOUT pin. 

            We then had to limit the duration of time that each note was played for.  We decided that each note would be played for roughly half a second. To accomplish this we wrote a loop with NO OP instructions that would execute for half a second and then we set the Timer Module to play a high frequency undetectable by the human ear thus stopping the note. We then return to the keyboard loop to listen for another input.

            We incorporated into this project a feature to record and playback notes on the piano.  Specifically we designed a multi- record and playback mode capable of recording into and playing back from 5 different channels.  Of course the channels could easily be expandable depending on the size of memory.  Each channel has the capability to play 400 notes or play for roughly 200 seconds.  To accomplish this, our keyboard loop, in addition to detecting which note was pressed would detect which channel to record into or play from; each channel having a different key for recording and playing back.  As the flow diagram specifies once a record mode has been detected we will set the record register with the appropriate value of the channel to recorded into. For example, if the user has specified that he wants to record into channel ‘1’ then the record register is set to $1000 meaning that we will store the recorded notes in memory form $1000 to $2000. Channel 2 corresponds to memory addresses between $2000 to $3000 etc….

At this point the mode register is set to ‘1’ to indicate that we are in recording mode.  The notes that are played are recorded into memory until on of two things happen 1) we run out of memory space at which point control returns back to the keyboard, or 2) the user has specified that he has finished recording.  The user specifies that he is finished recording by pressing the ‘0’ key (this part is the same for all channels) and at which time the mode register is set to ‘0’ to indicate that we not recording anymore. And then control returns back to the keyboard loop.

            To use the playback mode the user can press one of 5 keys to signal which channel to play back. 

Then we just sequentially move the value that was stored in memory for that channel play the note for half a second and then get the next note and play that note and so on.

            Volume- Volume control can be achived with the help of an inverting gain amplifier. The input to this amplifier is the output of the Tout pin of the Timer module and the out put of this Operational amplifier is the input to the speaker. The way to control the input is to either increase the value of R2 to decrease the volume or increase the value of R2 to decrease the value. The diagram belows details the setup for the circuit. Vout = -(R1/R2)* Vin

 

Future Considerations- Currently we have only one harmonic of the project working and that comes from the Tout pin of the motorolla coldfore board. We spent many hours trying to get the parallel port of the board to function properly but we needed more time. The functionality we have attained is the ability to play notes, and record. We would like in the future to add more harmonics to the machine and possibly even cords. Harmonics are multiples of a particular frequency say for example the note 'A' is 254 Hz then the second harmonic would be 2*254 and the 3rd harmonic would be 3*254 and so on. The sound from a tuning fork is very simple and consists of only one harmonic the fundamental but the sound from instruments is a little more complex than just multiples of the fundamental they also have intensity and phase shift. Intensity is the amplitude of the wave and phase shift is how many degrees the particular harmonic is out of phase with the fundamental. Cords could be achieved simply by adding additional output ports to output the different notes played and combining them together.

Individual Responsibilities:

Brian Tyler – worked on design and implementation of the user input from the keyboard and making the ColdFire output the frequencies of the notes to the speaker.

Tim Satgunam – worked on design and implementation of the record and playback modes of the piano.

Chris Pepper - worked on design and implementation of all analog specifications such as the volume control and harmonics.

Webpage:

www.ele.uri.edu/~satgunat/