

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Material Type: Assignment; Professor: Manwaring; Class: ST:Sem-Scholarshp/Serv Prog; Subject: Computer Science; University: University of Idaho; Term: Unknown 1989;
Typology: Assignments
1 / 2
This page cannot be seen from the preview
Don't miss anything!


Introduction The tasks of this laboratory assignment involve connecting a speaker to a microprocessor system and making simple music with it. It requires writing software to make the speaker switch on/off at fixed frequencies, required by the sounds of the music. The software to be written consists of two functions: SoundOn and TimeWait. A program, melody1.cpp has been provided that will interpret simple melodies. These functions will be placed within it.
The expected outcomes of this assignment are (1) getting further practical experience with making hardware connections to a microprocessor device and (2) having experience with time calibrating real-time software.
Task 1 Download melody1.cpp. Read through the code giving special attention to how melody1.cpp uses SoundOn and TimeWait. These functions are unique in that they must operate with real timing constraints.
In the laboratory write-up include a paragraph or two about strategies for implementing the SoundOn and TimeWait functions. Explain how to incorporate both frequency and timing information into the sound function. Be as detailed as possible in explaining the algorithm.
Task 2 Write and calibrate SoundOn and TimeWait functions. Use the processor’s signal P10 (not the same as Pin 10 on the 40 pin connector!) for the signal ouput that will drive the speaker.
The sound function must output a 50% duty cycle square wave at the correct frequency (plus or minus a few hertz is ok, it just has to “sound” good). Outputting a square wave is not har. For instance, the blink program in the first lab outputs a very slow square wave and it is extremely simple. The complication arises when the function must be configurable for many different frequencies. It is probably not reasonable to write a mathematical function that translates a frequency into square wave parameters. Because of time delays in the executing code and the logarithmic nature of music, solving for such an equation is difficult. Instead, a simple method is to graph frequency vs. square wave parameters for several values and to use a graph to approximate the rest of the values. [This is a basic, easy-to-do solution. Better (and more complex) methods are surely available. Report on one if it becomes apparent.]
In order to pass off task 2, verify that a call to SoundOn outputs a square wave at the appropriate frequencies and durations.
Task 3 Put together the speaker circuit. Integrate the designed SoundOn and TimeWait functions into melody1.cpp and play some tunes. Get the project working and pass it off.
Note: the speaker has about eight ohms of resistance. A reasonable current of about 20mA is adequate for sound generation. The biasing resistors in the circuit are used to control the current. If the speaker plays too softly, measure the voltage across it and compute the current. Make sure the current is around 20 mA.
In order to pass off, demonstrate your working system to the instructor/TA.
Task 4 Write a report detailing everything done to accomplish the lab. Include all source files, any pertinent information about the hardware, any neat or interesting things learned and any problems encountered. As always, all program listings are to include name, date and assignment number. Make sure the report includes an introduction and a conclusion. Follow all the guidelines listed in the reporting format document.
Extra Credit Using the melody language, write and play a new song (one that has not previously been provided). In order to receive credit, demonstrate the song to the instructor/TA and email the melody file to the instructor.
Note: Any extra credit work must also be included in a standard write-up.