# Purpose

To familiarize you with numerical output via a digital-to-analog (D/A) converter:
• Discrete representation of continuous signals
• Limitations imposed by CPU speed
• Synthesis of complex signals

# Due dates

You must hand in answers to the questions at the beginning of your laboratory session on Thursday, October 30. This part of the assignment is worth 17 points.

You must demonstrate your program to your TA during your laboratory session on Tuesday, November 4. This part of the assignment is worth 25 points.

# Background

Morse code is simply a vehicle for exploring the use of the computer in signal synthesis, and you are not responsible for knowing anything about it. In order to design the appropriate synthesis algorithms, however, you need to understand some of its properties and how it is taught.

Morse code is a representation of the letters, digits and punctuation characters by sequences of short and long bursts of tone. It was originally developed for transmission over telegraph lines, and was later used for radio transmission. Although its use has diminished with time, proficiency is still a requirement for most amateur radio operator's licenses. An interesting sidelight is that Morse code identification is transmitted by radio navigation aids used by aircraft, and until recently Morse code proficiency was required for instrument-rated pilots in Australia.

The basic timing element of Morse code is called a unit, and is the length of the short burst of tone. The long burst of tone has a length of three units, and the silence between tone bursts has a length of one unit. A minimum of three units of silence separates characters, and a minimum of seven units of silence separates words.

Morse code transmission rates are measured in words per minute, with the ``standard'' word being ``Paris''. In other words, a speed of 20 words per minute involves transmitting ``Paris'' 20 times in one minute. In the table below, a short burst of tone is represented by a dot and a long burst of tone is represented by a dash. If we count the units making up the word ``Paris'', including all of the silences, we find that there are 52. Thus a code speed of 20 words per minute involves transmission of 1040 units per minute.

When one is learning Morse code, it is extremely important to realize that it is an audible, not a written form of communication. You cannot achieve any reasonable proficiency by learning the patterns of dots and dashes given in the table below. Instead, you must learn the sound of the character, just as you learn the sound of a song. When learning code, the standard audible presentation of each character is the sound that character would have if the message were being transmitted at 20 words per minute. This standard requires that the length of a unit be about 58 milliseconds (1040 units per minute). The period of silence between characters is adjusted to produce a transmission rate compatible with the student's proficiency.

The frequency of the tone used for the short and long bursts is somewhere in the 800-1000 Hz (cycles per second) range. If the tone were exactly 1000 Hz, then each cycle would require 1 millisecond and a short burst of tone for code practice would consist of 58 cycles.

 A: .- J: .--- S: ... B: -... K: -.- T: - C: -.-. L: .-.. U: ..- D: -.. M: -- V: ...- E: . N: -. W: .-- F: ..-. O: --- X: -..- G: --. P: .--. Y: -.-- H: .... Q: --.- Z: --.. I: .. R: .-.

# Equipment

Each group will need access to a pair of headphones of the type used with portable CD players or MP3 players. The headphones plug into the socket mounted on the MB5.

Design and implement a program that reads a sequence of typed characters from the MB5 UART 2, and outputs them as Morse code to the MB5 D/A converter. Use the comint.src module you developed in an earlier assignment to read from the UART. (You may obtain a comint.src module from another group if you wish.) Click here for the C file containing the 800-sample sine wave discussed in the reading. You can use this data to synthesize appropriate tones.

Your program must accumulate a complete line of text (which might, of course, be only a single character) before doing any translation. It should then output the Morse code for the entire line. You may place a 136-character limit on input line length, and it is up to you whether you allow editing by means of backspace characters.

The Morse code output for a line should conform to the specifications given above with respect to tone frequency and character timing. It must provide the appropriate separation between characters and between words. Remember that the lengths of the silences are tied to length of a unit, which is the time it takes to output a short tone burst. One easy way to create a silence of the appropriate length is to design the output routine to take the D/A converter address as a parameter. When you want to hear a tone, supply the correct D/A converter address as the argument; when you want to hear silence, supply an address that isn't connected to anything.

This assignment requires you to make several important design decisions:

• How represent the tones in memory.
• How to translate characters.
• How divide the problem into C and assembly language modules.
These decisions are not arbitrary; when you give your demonstration, you must be prepared to explain not only what you did, but why you did it. You should plan to spend some time discussing possible approaches with your group and with other groups. Collaborative approaches to problems like this generally lead to solutions more quickly than individual approaches, and the solutions are better.

# Questions

1. Write a loop in assembly language to output samples from a memory array to the D/A converter.
1. (2 points) How do you know that your loop will terminate?
2. (2 points) How do you know that your loop will not output any spurious (unwanted) samples to the D/A converter?
3. (5 points) Use the information in Appendix IV-D of the text to determine the number of clock cycles that your loop will execute between beginning to write one sample and beginning to write the next sample.
4. (2 points) What will the frequency of the sound output by your loop be if the memory array contains some number of 800-sample sine waves?

2. It is possible to create a tone burst by having a quarter-cycle table and a program to construct an appropriate number of full cycles. At the other extreme, one could pre-compute and store the samples for the entire tone burst. This is a classic time/space tradeoff.
1. (3 points) What arguments would you use to decide between storing a quarter-cycle table and storing a full-cycle table?
2. (3 points) Would there be any perceptible difference in quality between using a loop to output a full-cycle table an appropriate number of times and storing the complete tone burst? Explain briefly.

# Demonstration

You must demonstrate your program to your TA on one of the machines in the Microlab. Be sure to hand your TA the written justification of your design decisions at the time of the demonstration.
 Instructor Revision 1.44 (2007/08/27 00:15:44)