Simulating The Ideal System

The simulation of the digital communication system in Figure 9.1 divides into two parts just as the figure does. The first part creates the analog transmitted signal, and the second part implements the discrete-time receiver. The message consists of the character string:

01234 I wish I were an Oscar Meyer wiener 56789

In order to transmit this important message, it is first translated into the 4-PAM symbol set ±1,±3 (which is designated m[i] for i = 1,2,... , N) using the subroutine letters2pam. This can be represented formally as the analog pulse train Sfco1 m[i]S(t — iT), where T is the time interval between symbols. The simulation operates with an oversampling factor M, which is the speed at which the "analog" portion of the system evolves. The pulse train enters a filter with pulse shape p(t). By the sifting property (A.56), the output of the pulse shaping filter is the analog signal ^i-Q1 m[i]p(t — iT), which is then modulated (by multiplication with a cosine at the carrier frequency fc) to form the transmitted signal n-1

Since the channel is assumed to be ideal, this is equal to the received signal r(t). This ideal transmitter is simulated in the first part of idsys.m.

idsys.m: (part 1) idealized transmission system - the transmitter

"/, encode text string as T-spaced PAM (+/-1, +/-3) sequence str='01234 I wish I were an Oscar Meyer wiener 56789'; m=letters2pam(str) ; N=length(m) ; "/, 4-level signal of length N "/, zero pad T-spaced symbol sequence to create upsampled T/M-spaced "/« sequence of scaled T-spaced pulses (with T = 1 time unit)

M=100; mup=zeros (1 ,N*M) ; mup (1 :H: end)=m; "/, oversampling factor

"/, Hamming pulse filter with T/H-spaced impulse response p=hamming(H) ; "/, blip pulse of width H

x=f ilter(p, 1 ,mup) ; "/, convolve pulse shape with data figure(l), plotspec (x, 1/H) "/, baseband signal spectrum

"/, am modulation t=l/M: 1/M: length(x) /M; '/. T/H-spaced time vector fc=20; "/, carrier frequency c=cos(2*pi*fc*t); "/, carrier r=c.*x; "/, modulate message with carrier

Since Matlab cannot deal directly with analog signals, the "analog" signal r(t) is sampled at M times the symbol rate, and r(t)\t=kTs (the signal r(t) sampled at times t = kTs) is the vector r in the Matlab code, r is also the input to the digital portion of the receiver. Thus the first sampling block in the receiver of Figure 9.1 is implicit in the way Matlab emulates the analog signal. To be specific, k can be represented as the sum of an integer multiple of M and some positive integer p smaller than M such that kTs = (iM + p)Ts.

Thus, the received signal sampled at t = kTs is n-1

r{t)\t=kTs = Y^ m[i]p(t - iT)cos(2TTfct)\t=kTs=iT+pTs i = 0 n-1

The receiver performs downconversion in the second part of idsys.m with a mixer that uses a synchronized cosine wave, followed by a low pass filter that removes out-of-band signals. A quantizer makes hard decisions that are then decoded back from symbols to the characters of the message. When all goes well, the reconstructed message is the same as the original.

idsys.m: (part 2) idealized transmission system - the receiver "/, am demodulation of received signal sequence r c2=cos (2*pi*f c*t) ; "/, synchronized cosine for mixing x2=r.*c2; "/, demod received signal f1=50; 1 LPF length fbe= [0 0.5 0.6 1]; damps=[l 10 0]; '/„ design of LPF parameters b=remez (fl ,fbe ,damps) ; "/, create LPF impulse response x3=2*f ilter(b, 1 ,x2) ; "/, LPF and scale downconverted signal

"/, extract upsampled pulses using correlation implemented as a convolving filter y=f ilter (f liplr (p) / (pow(p) *M) , 1 ,x3) ; "/, filter rec'd sig with pulse; normalize

"/, set delay to first symbol-sample and increment by H

z=y (0 . 5*f 1+M :M: end) ; "/, downsample to symbol rate figure(2), plot ( [1: length(z)] ,z, ' . ') "/, soft decisions

"/, decision device and symbol matching performance assessment mprime=quantalph(z, [-3 ,-1,1,3] ) ' ; "/, quantize to +/-1 and +/-3 alphabet cluster_variance= (mprime-z) * (mprime-z)'/length(mprime) , "/, cluster variance lmp=length(mprime);

percentage_symbol_errors=100*sum(abs (sign(mprime-m(l: Imp))))/Imp, "/, symb err "/, decode decision device output to text string reconstructed_message=pam21etters (mprime) "/, reconstruct message

This ideal system simulation is composed primarily of code recycled from previous chapters. The transformation from a character string to a 4-level T-spaced sequence to an upsampled (T/M-spaced) T-wide (Hamming) pulse shape filter output sequence mimics pulseshapeO .m from Section 8.2. This sequence of T/M-spaced pulse filter outputs and its magnitude spectrum are shown in Figure 9.2 (type plotspec(x, 1/M) after running idsys.m).

Each pulse is 1 time unit long, so successive pulses can be initiated without any overlap. The unit duration of the pulse could be a millisecond (for a pulse frequency of 1 kHz) or a microsecond (for a pulse frequency of 1 MHz). The magnitude spectrum in Figure 9.2 has little apparent energy outside bandwidth 2 (the meaning of 2 in Hz is dependent on the units of time).

100DC

aooo J 6000

frequency i

FIGURE 9.2: The transmitter creates the signal in the top plot, which has the magnitude spectrum shown in the bottom.

This oversampled waveform is upconvert.ed by multiplication with a sinusoid. This is familiar from AM.m of Section 5.2. The transmitted passband signal and its spectrum (created using plotspec(v, 1/M)) are shown in Figure 9.3. The default carrier frequency is fc=20. Nyquist sampling of the received signal occurs as long as the sample frequency 1 /(T/M) = M for T = 1 is twice the highest frequency in the received signal, which will be the carrier frequency plus the baseband signal bandwidth of approximately 2. Thus, M should be greater than 44 to prevent aliasing of the received signal. This allows reconstruction of the analog received signal at any desired point, which could prove valuable if the times at which the samples were taken was not synchronized with each received pulse.

|an)o 1000

|an)o 1000

-SO -40 -S> m III 0 1" 20 SO ill Ml fnsqiienry

FIGURE 9.3: The signal and its spectrum after upconversion.

The transmitted signal reaches the receiver portion of the ideal system in Figure 9.1. Downconversion is accomplished by multiplying the samples of the received signal by an oscillator that (miraculously) has the same frequency and phase as was used in the transmitter. This produces a signal with spectrum shown in Figure 9.4 (type plotspec(x2,1/M) after running idsys .m). This has substantial nonzero components (that must be removed) at about twice the carrier frequency.

To suppress the components centered around ±40 in Figure 9.4 and to pass the baseband component without alteration (except for possibly a delay), the low-pass filter is designed with a cutoff between 25 and 30. For M = 100, the Nyquist frequency is 50. (Section 7.2.2 details the use of remez for filter design.) The frequency response of the resulting FIR filter (from freqz(b)) is shown in Figure 9.5. To make sense of the horizontal axes, observe that the "1" in Figure 9.5 corresponds to the "50" in Figure 9.4. Thus the cutoff between normalized frequencies 0.5 to 0.6 corresponds to unnormalized frequencies of 25 and 30, as desired.

The output of the lowpass filter in the demodulator is a signal with spectrum shown in Figure 9.6 (drawn using plotspec(x3,1/M)). The spectrum in Figure 9.6 should compare quite closely to that of the transmitter baseband in Figure 9.2, as indeed it does. It is easy to check the effectiveness of the low pass filter design by attempting to use a variety of different lowpass filters, as suggested in Problem 9.4.

Recall the discussion in Section 8.3 of ways to locate "markers" in a sequence.

Viewing the pulse shape as a kind of marker, it is reasonable to correlate the pulse

~2I

1

il

i|||m

|mji

0 20 40 60 80 100 120 140 160 180 200 SöCölfcJS

4000 -3000 -2000 1000 -

1

. .

-SO -40 -Sí m 10 0 1" 20 SO ill Ml fnsqiienry

FIGURE 9.4: The received signal and spectrum after downconversion (mixing).

.........i.........i

IfVYYYYYYYYV^

FIGURE 9.5: Frequency response of the lowpass filter.

smgihJS

9000

J 6000

I 4000 2000

Ineqiienry

FIGURE 9.6: Signal and spectrum after the demodulation and low pass filtering. Compare to the baseband transmitted signal (and spectrum) in Figure 9.2.

shape with the received signal in order to locate the pulses. (More justification for this procedure is forthcoming in Chapter 11.) This appears in Figure 9.1 as the block labelled "pulse correlation filter" . The code in idsys .m implements this using the filter command to carry out the correlation (rather than the xcorr function) though this choice was a matter of convenience (refer to corrvsconv.m in Exercise 8.9 to see how the two functions are related).

The first AM samples of the resulting signal y are plotted in Figure 9.7 (via plot (y (1: 4*M))). The first three symbols of the message (i.e. m(l:3)) are —3, 3, and —3, and Figure 9.7 shows why it is best to take the samples at indices 125 + kM. The initial delay of 125 corresponds to half the length of the lowpass filter (0 . 5*f 1) plus half the length of the correlator filter (0 . 5*M) plus half a symbol period (0 . 5*M), which accounts for the delay from the start of each pulse to its peak. This delay and the associated downsampling are accomplished in the code z=y (0 . 5*f 1+M: M: end); 7, downsample to symbol rate in idsys.m which recovers the T-spaced samples z. With reference to Figure 9.1, the parameter I in the downsampling block is 125.

A revealing extension of Figure 9.7 is to plot the oversampled waveform y for the complete transmission in order to see if the subsequent peaks of the pulses occur at regular intervals precisely on source alphabet symbol values, as we would hope. However, even for small messages (such as the wiener jingle), squeezing such a figure onto one graph makes a detailed visual examination of the peaks fruitless. This is precisely why we plotted Figure 9.7: to see the detailed timing information for the first few symbols.

One idea is to plot the next four symbol periods on top of the first four by shifting the start of the second block to time zero. Continuing this throughout the data record mimics the behavior of a well-adjusted oscilloscope that triggers at the

smgihJS

best times to take samples

n Ts spaced samples

T spaced samples n Ts spaced samples

T spaced samples

FIGURE 9.7: The first four symbol periods (recall the oversampling factor was M = 100) of the signal at the receiver (after the demodulation, LPF, and pulse correlator filter). The first three symbol values are —3, +3, —3, which can be deciphered from the signal assuming the delay can be selected appropriately.

same point in each symbol group. This operation can be implemented in Matlab by first determining the maximum number of groups of 4*M samples that fit inside the vector y from the 1th sample on. Let ul=floor((length(y)-l-l)/(4*M));

Then the reshape command can be used to form a matrix with 4*M rows and ul columns. This is easily plotted using plot(reshape(y(1:ul*4*M+124),4*M,ul))

and the result is shown in Figure 9.8. This type of figure, called an eye diagram, is commonly used in the field as an aid in troubleshooting. Eye diagrams will also be used routinely in succeeding chapters.

Four is an interesting grouping size for this particular problem because four symbols are used to represent each character in the coding and decoding implemented in letters2pam and pam21etters. One idiosyncrasy is that each character starts off with a negative symbol. Another is that the second symbol in each character is never —1 in our chosen message. These are not generic effects: they are a consequence of the particular coding and message used in idsys.m. Had we chosen to implement a scrambling scheme (recall Problem 8.19) then the received signal would be whitened and these particular perculiarit.ies would not occur.

The vector z contains estimates of the decoded symbols, and the command plot ( [1: length(z)] ,z, ' . ') produces a time history of the output of the down-sampler, as shown in Figure 9.9. This is called the time history or a constellation diagram in which all the dots are meant to lie near the allowable symbol values. Indeed, the points in Figure 9.9 cluster tightly about the alphabet values ±1 and ±3. How tightly they cluster can be quantified using the cluster variance, which is

FIGURE 9.8: Repeatedly overlaying a time width of four symbols yields an eye diagram.

the difference between the decoded symbol values (the soft decisions) in z and the nearest member of the alphabet (the final hard. decisions).

The Matlab function quantalph. m is used in idsys . m to calculate the hard decisions, which are then converted back into a text character string using pam21etters If all goes well, this reproduces the original message. The only flaw is that the last symbol of the message has been lost due to the inherent delay of the lowpass filtering and the pulse shape correlation. Because 4 symbols are needed to decode a single character, the loss of the last symbol also results in the loss of the last character. The function pam21etters provides a friendly reminder in the Matlab command window that this has happened.

FIGURE 9.9: Reconstructed symbols, called the soft decisions, are plotted in this constellation diagram time history.

Here are a few more ways to explore the behavior of the ideal system. We leave these to you.

0 0

Post a comment

  • Receive news updates via email from this site