Escolar Documentos
Profissional Documentos
Cultura Documentos
Fall 2004
1 Overview
The goal of this lab is to understand a simple modem, the Frequency Shift Keying (FSK) Modem, referred to by the International Telecommunications Union (I.T.U.) as V.21. The V.21 modem communicates 1s and 0s by sending either a 1650 Hz tone or a 1850 Hz tone, respectively, for 1/300 second. Thus the overall data rate is 300 bits/second (one bit is sent in 1/300-th of a second). Even though 300 bps is quite slow compared with the theoretical maximum of 56 kilobits per second over a phone line, the V.21 format is still used in almost every modem call. This is due to the fact that receiving and decoding it is so simple. A V.21 modem call can be received without using difficult techniques such as equalizers, cancellers and matched filters. Furthermore, it can be received accurately even in the presence of a significant amount of noise. For these reasons, V.21 is used as an initial handshake between two modems, meaning that V.21 is a way to communicate some basic startup/control information between the two modems. You can hear the V.21 modem tones at home when your V.34, V.90, V.92 phone line modem or fax machine starts a phone call. V.21 is also used to transmit caller ID information over the phone line.
1.1 Transmitter
1.1.1 Converting from Text String to Binary String
An FSK modem is a digital communication system, so it transmits zeros and ones. In order to transmit messages in an alphabet, there must be a binary representation for each character in the alphabet. The standard for this representation is ASCII where eight bits are used to represent characters, numbers and special punctuation. For example, the upper-case character A is represented in ASCII with the number 65, which has an 8-bit binary form as 01000001; lowercase b is 98 in ASCII, or 01100010. Therefore, if we want to encode a message, such as Hello World, for the FSK modem, we must turn the eleven characters of the message into 0s and 1s. Since blanks are counted as characters, we would end up with 88 bits. Given a vector of bits, we could generate the appropriate sinusoids by agreeing to the convention that 1650 Hz is used for a 1, and 1850 Hz is used for 0. MATLAB has some useful functions for doing ASCII conversion and also for turning decimal numbers into bits. Check out help on the following functions: CHAR Convert numeric values to character array (string) ABS Convert character array (string) to numeric values DEC2BIN Convert decimal integer to a binary string BIN2DEC Convert binary string to decimal integer Run the script char(30:50), please refer to its help to understand the result. Also, try the following MATLAB expression abs([ABC;b01]), and note that the ASCII equivalents are returned in a matrix1. To test your knowledge at this point, write a MATLAB expression that
1
In MATLAB, a string is actually an array of characters, so [ABC;b01] is a 2 3 array. Use size to verify this fact.
1/11
Fall 2004
will give the binary representation for the message Hi!. Use the optional argument in dec2bin to get an 8-bit string for each character (with leading zeros). Notice that, when you convert a text string into binary format, you will get a column vector, each row is an 8-bit long binary string. You may want to use MATLAB function reshape to form your binary message into one string, so that it will be easier to generate your FSK signal in the next step. Be aware that the function reshape is based on column-wise operation. By convention, we send the most significant bit of byte first2. For example, H corresponds to 01001000, and i 01101001. So, the binary string sent out should be in order 0100100001101001.
To test your function, input character H, use a duration of 50 millisec, even though that is only 20 bps, because then it will be easy to identify the tones on a spectrogram. Use a sampling rate of 9000 samples/second. Make a spectrogram of the generated FSK signal in order to show how the individual bits correspond to sinusoids. Use a window length that is the default of 128. Your spectrogram plot should look like Fig. 1. Notice those vertical bars on the spectrogram plot, and try to explain the cause of it. Conceptually, what could be the solution to this problem?
This is called the Big-Endian convention. As expected, there is a Little-Endian convention, too. The debate on choosing one over the other has been going on for decades. Check online materials for more details.
2/11
Fall 2004
1.2 Receiver
The receiver for V.21 must determine which of the two tones is present, and must make this decision every 1/300-th of a second. A block diagram of the FSK V.21 demodulator is given in Fig. 2. Each of the main sections will be described in more detail below.
1.2.1 Mixing
A basic operation that most modems need to perform is frequency shifting of the input signal. According to the frequency-shifting property of the Fourier Transform, this can be done by simply multiplying the input signal by a complex exponential.
3/11
Fall 2004
When x(t ) is multiplied by the given complex exponential at frequency f c Hz, the exponents simply add and the resulting w(t ) is as follows:
1 1 w(t ) = e j 2 ( f1 fc )t + e j 2 ( f1 + fc ) t . 2 2
Note that the new frequencies in w(t ) are simply the old frequencies shifted down (to the left on the f axis) by f c , i.e., f1 f c and f1 f c . Also note that w(t ) is complex, so we no longer have the condition of complex conjugate symmetry between the two complex exponential components. This simply means that now our signal is really two signals: a real part signal and an imaginary part signal. If we want to filter this complex signal with a real filter, we simply filter the real part and the imaginary part separately with the same filter. In MATLAB, the filter() function does this very thing for you. The purpose of the filter is to remove the complex exponential with frequency f1 f c while leaving the other component whose frequency is f1 f c . Thus, the filter output should be of the form
y (t ) = Ae j 2 ( f1 fc )t ,
where A will depend on the gain of the filter in its passband. For V.21 FSK, we will choose f c so that the original frequencies of +1650 Hz and +1850 Hz in x(t ) are shifted to -100 Hz and +100 Hz respectively, and these are the frequencies passed by the filter. This is achieved by choosing f c = 1750.
fsamp = 9000Hz.
(1)
This value is chosen to be rather high so that the input signal will appear to be continuous if we use the MATLAB plot() command. In Fig. 3 the continuous-time signals have been replaced with their sampled versions, e.g., x(t ) becomes x[n] , w(t ) becomes w[n] , and so on. The complex exponential used in the mixer must also be converted from e j n signal e c . What is c ?
j 2 f c t
to a discrete-time
Figure 3: FSK system demodulator system simulated as a discrete-time system at a sampling rate of fsamp . 4/11
Fall 2004
frequency3 at = 2 (1500/9000) =
1 . 3
In the FSK V.21 system, the frequency shifting of the mixer will generate spectrum lines that must be removed by filtering. If we demand that these unwanted spectrum components must be reduced in magnitude by a factor of 100, then we have given the specifications on the stopband ripple. A reduction by a factor of 100 means that the stopband ripple must be less than 0.01, or 40 dB. The passband, on the other hand, must be made wide enough so that the desired frequency components will go through the LPF with little or no change. Since the LPFs frequency response will have a passband ripple, we will use a specification on the passband of 1 dB, which forces the passband magnitude to lie between 0.89 and 1.12. For detailed digital filter design, refer to Section 1.3 of this lab.
Figure 4: Frequency estimation in a dual-frequency FSK system can be performed with a slicer. Slicing is defined as follows:
(2)
Remember that the frequency response of a digital filter, H ( e ) , is a function of the frequency variable that runs from
j
= to = .
5/11
Fall 2004
It is a non-linear operation, but in the case where x[n] is a single cosine input, the filter output will be of the form y[n] = Ae slicer (2) reduces to
s[n] = ( Ae j 0 n ) ( A*e j0 ( n 1) ) . j 0 n
If the objective were to determine the frequency 0 , then it is sufficient to take the imaginary part
d [n] = Im{s[n]} = Im{| A |2 e j0 }
d [n] =| A |2 sin( 0 )
and use d [n] to calculate the arcsin() to get an estimate of 0 . However, the FSK V.21 system is even simpler than that, because we only need to decode two cases: a zero or a one. When 0 < 0 we have a 1, and when 0 > 0 we have a 0. In addition, the sign of 0 is the same as the sign of | A |2 sin( 0 ) , so we only need to check the sign bit of d [n] to perform the decoding.
As will be seen in the final implementation of this lab, the recovery of the V.21 signal reduces to discriminating between a +100 Hz tone and a -100 Hz tone. Taking the imaginary part of s[n] , the slicer output, will provide an easy way to determine whether a 1650 Hz or 1850 Hz tone was originally present. Thus we can define b[n] as an estimate of the bit that is represented by the slicer output at time n .
0 b[n] = 1
(3)
In MATLAB, you can use the find() function to implement (3) by creating a zero vector of the same length as d [n] and then changing all locations where d [n] < 0 to 1.
Table 1: FSK Decoding Rule Note that y[n 1] can easily be obtained from y[n] by with a delay of one sample. In the interest of keeping the vectors the same size, the filter() command can be used to create y[n 1] : y1 = filter([0 1],1,y)
6/11
Fall 2004
samples (assuming bit rate of 300 bps and sampling rate of 9000 samples/sec) and the sinusoid switches between 1650 Hz to represent a 1 and 1850 Hz to represent a 0. In our discrete-time simulation, the signal d [n] at the output of the slicer is either positive or negative at each sample time, and we have just seen that the sign of this signal is an indicator of whether a 1 or a 0 is being encoded at any particular sample time n . Now we should remember that if the bit rate is 300 bps and the sampling rate is 9000 Hz, this means that each bit of the encoded message is actually represented by a group of 30 consecutive samples. We can determine the sequence of bits by simply looking at the signal during each bit interval. Since each of these intervals is 30 samples long, we can find the middle (where the answer is likely to most robust) by simply sampling the sequence b[n] at a point that is offset by 15 samples from the beginning of each bit interval. When there is noise in the communication channel, which is always true in real life, you dont want to base your result on only one sample in each bit interval. One way to mitigate the noise effect is to use a majority vote scheme, that is, in one bit interval, if more than half of 30 samples are negative, then it is more likely that the decoded bit is a 1. At last, we need to group the bits into 8-bit sets then convert them into ASCII symbols. This completes the decoding simulation. The MATLAB functions bin2dec and char can convert a bit stream to ASCII. Try the following example: bstr = [0 1 0 0 1 0 0 0] char(bin2dec(char(bstr+abs(0))))
The Signal Processing Toolbox in MATLAB provides numerous functions that will perform filter design, but often this toolbox is not available.
7/11
Fall 2004
f f s Hz. Even though the frequencies are given in hertz, the filter design GUI yields a digital filter. The sampling frequency fsamp controls the relationship between the given analog cutoff
frequencies, f p and f s , and the filters frequency response H (e j ) which is actually a function
of .
Question: Determine the values of for the passband and stopband edges in Fig. 5.
Figure 5: The filtdemo MATLAB GUI for digital filter design. The magnitude is given in dB (decibels). The frequency axis is labeled in hertz from DC to half the sampling frequency. (Note that fsamp = 6000 Hz in this figure.)
8/11
Fall 2004
In Fig. 5, the value of M = 23 was entered by hand. Obviously, the stopband cutoff frequency f s must be greater than the passband cutoff frequency f p . If we try to make f s and f p nearly equal, then the filter length L would have to be very large, so it is customary to allow a transition region between the passband and stopband. Once the magnitude response has been manipulated into a desirable form, the filter coefficients can be extracted from the GUI by running the following in the command window. [bb,aa] = filtdemo(getfilt); Since this is an FIR filter, only the vector bb is needed. It will contain all of the filter coefficients for the FIR filter.
2 Procedures
2.1 FSK Modem in VAB
In this demonstration VAB part, you will hear what a two-tone FSK transmitter sounds like. The worksheet 2-Tone FSK Transmitter.Lst can be found on desktop of every computer in the lab, and it looks like that shown in Fig. 6. Every time you type in a letter, you will hear a pattern of tones repeating itself. Different letters will have different tone patterns. Based on the knowledge you have got from Section 1.1, explain the relationship between the letter you type and the tone pattern you hear.
Fall 2004
Suppose you are about to construct a 2-Tone FSK Receiver.Lst worksheet, you want to pair two computers up and form a two-tone FSK air modem just like you did on LAB 4 (DTMF modem). Suppose you have ideal bandpass filters for those two tones (their lengths are suitable), and noise effect can be ignored. Now, do you think your air modem will work properly? What could go wrong? Try to find the most critical issue we are not considered here. Explain why it is critical.
10/11
Fall 2004
3 Report Components
Your report should answer the questions asked in both the VAB and MATLAB components of the laboratory. Please make sure that the questions are answered fully, along with any explanation or justification necessary, and that plots are appropriately labeled and referenced.
11/11