I implemented Matlab functions that performed analog transmission, and analog-digital transmission. Below I will outline the basics of the methods I created, and show some example output from the methods.

**Analog Modulation**

The three techniques used for analog modulation are amplitude modulation, frequency modulation, and phase modulation. Initially, I spent a lot of time trying to write functions to perform all three modulation techniques. Later, though, I discovered that Matlab has built-in functions in the communications toolbox that perform analog modulation. The functions modulate discrete-time analog signals using suppressed carrier amplitude modulation, single-sideband amplitude modulation, frequency modulation, and phase modulation. Furthermore, Matlab also provides functions that demodulate signals as well.

The Matlab functions saved some time and effort for me, but I wrote code that can either suppress the carrier or not. For amplitude modulation, the input signal is multiplied by a carrier cosine wave with a much higher frequency. The resulting signal can be more difficult to demodulate (and requires a different demodulation technique) if there are negative values in the input signal. To fix this problem, a constant is added to the input signal before modulation. The constant is chosen so that the new signal has no negative values. When the constant is not added to the input signal, the modulated signal is said to have a suppressed carrier. The functions I created allow the user to observe both suppressed carrier modulation amplitude modulation as well as unsuppressed carrier modulation. The Matlab functions also allow users to choose between having a double-sideband or a single-sideband. Regular amplitude modulation is double sideband modulation: the frequency spectrum of the modulated signal has both positive and negative values, and the spectrum is symmetric across the zero frequency axis. Single sideband modulation has only positive frequency components, and suppresses the negative frequency components.

I have run into problems with the demodulation, however. At first, I was having problems with consistency with the amplitude demodulation. I fixed those problems, but the demodulated signals are not exactly the same as the input signals, even when channel noise is not added. Usually, the demodulation still gets the basic shape of the input signal, but at times the average value or the maximum and minimum values of the demodulated signal is different from the input signal. I haven’t solved this problem, but I believe the problem to be inherent in the types of signals being fed into the program and the demodulation schemes. Of course, in real life demodulation is rarely, if ever, perfect.

When starting this project, I also wanted to allow the user to see the effects of channel noise on modulation and demodulation. For my Matlab modulation/demodulation functions, I let the user specify the variance of the Gaussian noise that he/she would like to add. Then, the modulation functions still modulate the input signal, but then the function adds Gaussian noise with the specified variance to the modulated signal. After adding the noise, the functions demodulated and output the noisy modulated signal. The Matlab functions mesh with the functions I created to allow the user to modulated and demodulate analog signals, and observe what happens to the demodulated signal when channel noise is present.

Example of AM

Example of FM

Example of PM

Example of AM Demodulation

Example of FM Demodulation

Example of PM Demodulation

**Analog-Digital Modulation**

Converting an analog signal to a digital signal involves two processes: sampling and quantization. Sample takes data samples of the input analog signal at a certain frequency, and quantization rounds the sampled data to predetermined levels. Normal analog to digital conversion involves first sampling a continuous signal. The main problem I had with sampling was that Matlab doesn't really operate on continuous signals. If I allowed the user to input signal data, then I would have only discrete data. The discrete input data limited my sampling capabilities. Instead of being able to sample at any point in time of the input signal, I had to interpolate the data between the given data points. When my function runs into points that don't exist in the input data, it samples the closest existing data point to the desired data point. This solution is by no means perfect, but given a fine enough spacing of data points, the actual result is very close to the desired result.

There are two types of sampling techniques: natural sampling and flat-top sampling. For natural sampling, my function multiplies a switching waveform (a square wave whose frequency is the given sampling frequency) with the analog signal. For flat-top sampling, my function multiplies the analog signal with an impulse sampling waveform. The impulse sampling waveform has impulses of one that occur at a frequency of the given sampling frequency. After each impulse, the program repeats the value given by the product of the impulse and the input signal for a given time period tau. Clearly, tau cannot be larger than the inverse of the sampling frequency, although my function does not check for this condition.

There are also two types of quantizing techniques: uniform quantizing or non-uniform quantizing. Furthermore, there are two types of non-uniform quantizing: A-Law and u-Law quantizing. For uniform quantizing, my function takes in the number of levels to round to (must be a base two number). The function then computes what levels to round to by creating an evenly spaced vector between the maximum and minimum value of the input signal with a size of the given number of levels. Next, the function rounds all the values of the input function to the computed levels using a Matlab function. Non-uniform quantizing is a little more complicated than uniform quantizing because the levels aren't evenly spaced. Non-uniform quantizing is more sensitive to average values in an input signal because there are more levels near average values in the signal than near other values. Non-uniform quantizing takes in an input u/A, where higher u/A's mean the quantization is more sensitive to average values. However, non-uniform quantizing can be accomplished by transforming the input signal, uniformly quantizing the new signal, then performing an inverse transformation. For u-Law quantizing, the transformed signal is equal to

ln(1+u*|m(t)|)/ln(1+u)

where m(t) is the input signal. For A-Law quantizing, the transformed signal is equal to

A*|m(t)|/(1+ln(A)) if 0<=m(t)<=1/A

(1+ln(A*|m(t)|))/(1+ln(A)) if 1/A<=m(t)<=1

After transforming the input signal, non-uniform quantizing is relatively simple. Another way to sample and quantize a signal is through delta modulation. Delta modulation is a type of Differential Pulse Code Modulation (DPCM). When planning this project, I had planned on implementing DPCM as well, but basic DPCM turned out to be more difficult than I anticipated. The idea behind DPCM is that signals don't change very much very quickly; so instead of measuring what the value of a signal is at every data point, one can anticipate how the signal will change and can just record whether the signal is different from the prediction. Implementing a predictor, however, was too difficult for me in this project, so I only implemented delta modulation. Delta modulation is given an input delta, and starts at a base value. If the first sample is greater than the base value, then delta modulation outputs a 1, and the process adds delta to the base value. If the sample is less than the base value, delta modulation outputs a 0 and subtracts delta from the base value. The same process continues for every sample point. My function for delta modulation takes in a delta value and a sampling frequency and computes the delta modulation values.

Delta modulation signals are already in binary, and are ready to go through digital modulation. Sampled and quantized signals have been converted to a digital format but still need to be converted to binary, line code, and finally digital modulation. To convert quantized signals to binary, my binary conversion function takes in the input signal and the levels the signal has been quantized to. Then, the function assigns a binary value to each level. The binary values for all the levels will have lengths of the base 2 log of the number of levels. Then, the lowest level is assigned a value of all 0's, the second lowest is assigned a value of 1 to the right-most digit and 0's to all other digits, etc.

The binary values are then fed into functions that convert the binary into line code. I have functions which convert binary signals to the following types of line code: unipolar, bipolar, return-to-zero, pseudoternary, Manchester, and multi-level. The line code converts the binary code into a format that is less susceptible to error when transmitted. All of the types of line code except for multi-level code can then be fed into functions that modulate the code using OOK, BPSK, and FSK. Multi-level signals have different levels corresponding to different binary values. I wasn't sure exactly how to modulate multi-level code without converting it back into binary, which would be the same as unipolar code, so I don't allow multi-level code to be digitally modulated.

The function that modulates the line code using OOK outputs a sine wave for 1's in the input signal and 0's for 0's in the input signal. The function that modulates the code using BPSK outputs a sine wave with a phase of 0 degrees for 1's in the input signal and a sine wave with a phase of 180 degrees for 0's in the input signal. Finally, the function that modulates the code using FSK outputs a sine wave with a relatively high frequency for 1's in the input signal and a sine wave with a relatively low frequency for 0's in the input signal.

Establishing the above functions allowed me to be able to show others what the basic communications processes look like, but to allow users to easily use these functions I had to create a Matlab GUI.

Example of Natural PAM Sampling

Example of Quantization

Example of Return to Zero Line Code

Example of Manchester Line Code

Example of On-Off Keying

Example of Binary Phase Shift Keying

Example of Frequency Shift Keying