CSC 465 Lab Assignment 5

PCM Simulation programming exercise

 

 

Due: Thursday, April 26, 2001.

 

 

Overview

 

This exercise will compare different PCM (Pulse Code Modulation) methods for digital transmission of an analog data transmission signal. Your program will simulate the transmission of a character string from sender A to receiver B. You may conduct this exercise with a partner. If so, the contribution of each should be well-documented.

 

Please remember that this exercise is a simulation. It will require the skillful use of a spreadsheet program (e.g. Excel) or at least some skillful programming in conjunction with a spreadsheet. Use the programming languages and tools of your choice.  You will not generate physical signals but instead will simulate them with floating point values, the sine function, and the like.

 

 

Goal

 

Your goal is simulate transmission of an ASCII message, comparing the analog signal sent by modem A with the analog signal received by modem B and outputting the received message, for several different sets of specifications.

 

 

Transmission Scenario

 

A's modem is given an ASCII sequence to transmit. For this exercise, ignore start bits, stop bits and parity. The signal goes out onto a voice-grade (POTS) telephone line according to these specifications:

(a)    Use an AC (sine wave) carrier of 600 Hz having a peak amplitude of 10 volts (e.g. ranges from -10 volts to +10 volts).

(b)   Apply the signal to the carrier using an ASK (amplitude shift keying) scheme: if the bit being transmitted is 0, multiply the carrier voltage by 0.5, and if the bit being transmitted is 1, do not modify the carrier.

(c)    Transmit at 300 bps (bits per second).

 

When the modem signal reaches the end office, it is digitized by a codec using Pulse Code Modulation (PCM) at a rate of 8000 samples per second – this is described in detail below. The signal is transmitted on a T1 carrier to B's end office, where a second codec translates it back to an analog signal for transmission to B's modem.

 

 

Method

 

Translate each input character into its 8-bit ASCII equivalent in binary.  Each sender's bit is converted into an analog “signal”, which is then sampled and converted into a digital value for "transmission". The “received” digital value is converted back into an analog value, and this value is compared with the original analog value of the corresponding sample.  I am interested in any differences (error) between the original and the received analog sample.  Then translate the sequence of analog sine waves back into bits and each group of 8 bits back to an ASCII character for output.

 

As part of this exercise, you simulate B’s end office converting its sample into an analog voltage.  In real life, there are methods for recreating a sine wave from such samples (as long as there are at least 2 samples per cycle, according to Nyquist).  I will not ask you to attempt this.  Instead, use this crude but sufficient method: over each bit period, keep track of the maximum magnitude of all samples (after translation to a voltage).  If the maximum is greater than 5 volts, assume the bit is a 1 (as per the ASK method described above), otherwise assume it is 0.

 

Be aware of bit order.  The first bit transmitted will be the first bit received.  Obvious enough!  But the second bit transmitted will be the second bit received, and the receiver must know whether that bit is higher- or lower-order than the one that preceded it.  It doesn’t matter to me whether a character’s bits are transmitted low-to-high bit order or high-to-low, as long as both sender and receiver are on the same page. 

 

 

Using ASCII Codes.

 

For simplicity, assume that the message to be transmitted consists only of lower-case alphabetic characters and the space character.  Thus only a small range of ASCII values will be used.  Implement this as you wish, but use the actual ASCII values for those characters.  Be aware of this:  some of the experiments will cause the receiver to get incorrect values -- we want to test the limits of some transmission protocols.  These incorrect values, when matched to an ASCII code, may result in a control or other non-printing character.  To avoid unpleasant-looking output, I suggest this: if a received 8-bit value does not match the ASCII code for a space or a lower-case alphabetic character, output an asterisk (*).  That way you'll know the data were received incorrectly.  If the data were received incorrectly and the incorrect 8-bit value happens to match a different valid character, you'll be able to determine the mismatch visually.  Of course, your program can also match each output character to its corresponding input character and point out mismatches to you.

 

 

8-bit Pulse Code Modulation. 

 

The transmitted analog signal is sampled 8000 times per second.  Each sample (a voltage) is translated into an integer in the range -127 to +127. Thus +10 volts translates to +127, 0 volts translates to 0, and -10 volts translates to -127.  The digital value transmitted is an 8-bit sign-and-magnitude representation of this value, with the high order bit reserved for sign and 7 remaining bits for absolute value (this is irrelevant to your simulation, but interesting to know).  On the receiver’s end, the integer value is translated back into a voltage.  Since the original analog voltage is a continuous value and its digital representation is discrete, there is necessarily a little error when digital is converted back to analog.

 

 

First Simulation Experiment

 

The first set of simulation runs involves experimenting with the modem’s transmission rate.  The PCM sampling rate is fixed at 8000 samples of 8 bits each per second.   Here are 4 runs to make:

 

1.      The first run uses specifications given above:  carrier signal 600 Hz transmission rate 300 bps.
 

2.      The second run will double this: 1200 Hz carrier and 600 bps transmission. 

3.      The third run will double it again, to 2400 Hz carrier and 1200 bps transmission. 

4.      The fourth run will use a 2400 Hz carrier with 2400 bps transmission. 

 

For input, use that famous initial telephonic sentence: watson come here i want you

 

For each simulation run,

(a)    output the receiver’s regenerated message to see if it matches the original.   If it matches for all 4 runs, then break the rule of POTS and try a higher frequency carrier until it produces garbage.

(b)   at each sampling point, compare the original analog voltage reading against its corresponding reconstructed voltage reading.  Report the average magnitude (absolute value) of this error.

 

 

Second Simulation Experiment

 

The second set of simulation runs involves consideration of the differential PCM technique.

In differential PCM, the digitizing of each sample is handled the same as with 8-bit, but the transmitted digital value represents the difference between the current sample and the previous sample (for the first sample, assume the previous sample is 0). For example, if the previous sample was +79 and the current sample is +93, then +14 is transmitted (93 minus 79).  The receiver’s codec must then keep track of the current digital value so each new sample can be applied to it.

 

This set of simulation runs will determine the minimum number of bits required to transmit the difference value without receiving bad characters.  For each run, calculate and output the maximum difference value generated.  Remember the digital scale ranges from 127 to -127, so the difference between two consecutive samples can theoretically range from 254 to -254.  Please calculate the maximum based on absolute values.  Then report the number of bits required to contain a value of this magnitude, assuming the use of sign-and-magnitude representation (e.g. you need an extra bit for the sign).  For this experiment, do not be concerned with the receiver!  We want to determine only if the use of differential PCM will allow us to transmit these digitized data using fewer than 8 bits.

 

Make four runs using the same specifications as the four runs in the previous experiment, and similarly record the results for each.  There is one additional output for each run: the maximum difference between any two consecutive digital samples.  NOTE:  since this is a simple addition to the first set of experiments, they can be combined.

 

 

Third Simulation Experiment.

 

This experiment will put the result of the second experiment to the test.  The first run of that experiment will tell you the minimum number of bits required to send a differential PCM, for 600 Hz carrier and 300 bps transmission rate.  For sake of argument, suppose that value is 6 bits.  That means 1 sign bit and 5 data bits.  The absolute value of the difference between any two digital samples is no greater than 31.

 

For this experiment, modify the sender’s codec to generate a differential value of that length (6 bits, in this example), and modify the receiver’s codec to expect a differential value of that length.  The latter must produce a normal voltage reading as before, since the modem is analog and knows nothing of this differential business.  For this example, the senders codec generates and transmits values in the range +31 to -31 and the receiver’s codec gets each value and adds it to a variable containing the running 8-bit PCM value (+127 to -127 range), then converts that to an analog voltage.

 

The third series of simulation runs explores the degree to which we can compress transmission through differential PCM.  Use the same input message: watson come here i want you, and generate similar output: the reconstructed received message plus the average error between corresponding original and received voltage readings.

 

1.      The first run works as described above.  600 Hz carrier, 300 bps, x-bit differential PCM, where x is the result of the first run of the second experiment.  If the receiver’s regenerated message does not match the original, you've made a mistake.  Error should be very small.

2.      The second run also uses 600 Hz carrier and 300 bps, but reduce the number of differential PCM bits by one (e.g. x-1).  Again see if the output message matches the original.  It may or may not.

3.      Continue in this manner until most of the received characters are incorrect, and report the minimum number of bits required to correctly receive the transmitted message.  This value may be x or may be smaller.

 

Here's something you need to be aware of when designing this experiment: on the second and any subsequent runs, it is possible for the difference between two samples to be greater than the maximum allowed by the differential PCM.  Suppose, for example, you are running an experiment using 4-bit differential PCM.  Since one of these is a sign bit, that means the range of transmitted differential values is limited to +7 to -7.  If sample k is 106 and sample k+1 is 82, their difference is -24.  But the largest negative value that 4-bit differential can transmit is -7, so it has to transmit -7 instead of -24.  The receiver gets the -7 not knowing any better and its reconstructed signal, if accurate up to that point, will drop from 106 to only 99.  That represents an error, but its significance is not known until signals are translated to bit values and matched to ASCII codes.

 

 

 


This will require some analysis; the simulation is not very difficult but contains a lot of details. I suggest the program be controlled by a time variable which is updated upon each PCM sample. At this time, the transmitted analog signal value (in volts) can be calculated by a function, and the digital signal value calculated from that by another function. A third function will transform the digital signal value back to an analog value, which is then compared to the original. Use the programming tools of your choice.

 

 

 

To turn in.

 

1.      A printout with results of all simulation runs, plus an analysis for each simulation experiment that includes conclusions concerning performance.

2.      A spreadsheet file named pcm.xls containing data for the first two simulation runs from the first and the third experiments.  Sheet1 contains data from the first run of the first experiment, sheet2 contains data from the second run of the first experiment, sheet3 contains data from the first run of the third experiment, and sheet4 contains data from the second run of the third experiment.  Rename each sheet appropriately.  Each row represents a sample, and there should be columns for: the character being transmitted at the time that sample was taken, the bit value (0 or 1) being transmitted at the time that sample was taken, the original analog sample, the 8-bit PCM value, the transmitted value (which may be 8-bit PCM or may be x-bit differential), the received or reconstructed 8-bit PCM value, the reconstructed analog value, and the difference between original and reconstructed analog value.  Submit spreadsheet file to your eccentric upload folder.

3.      For each sheet in the spreadsheet, select an interesting 40-sample sequence and produce a graph comparing the original analog signal with the reconstructed analog signal.  By "interesting", I mean a sequence that includes a transition from a 1 bit to 0 bit or vice versa.  Identify the starting sample number, and graph the same 40-sample sequence from each of the four sheets.

4.      Source file(s) for program(s) you ran to produce the first run of the first experiment and the first run of the third experiment.  Submit to your eccentric upload folder.

 


[ assignments | CSC 465 | Peter Sanderson | Computer Science | SMSU ]


Last reviewed: 5 April 2001

Peter Sanderson ( PeteSanderson@smsu.edu )