A Simple Communication System Design Lab #2 with MATLAB Simulink
1. - 1/40 -
Instructor : Jaewook Kang
At CSNL-GIST
E-mail: jwkkang@gist.ac.kr
2011, Mar. 25th
A Simple Communication System Design
Lab with MATLAB Simulink
- Lab #2: - How to use S-function bulider
- Concept of upsampling and downsampling
- PSF implementation
2. - 2/40 -
SchedulesSchedules
Place: IC203
Weeks Time Hour Instructor
1 week
Lab. #0
3.11
(13:00~
16:00)
3
- Overview of Development with Simulink
- QPSK Model with AWGN Channel/ Rayleigh Fading
Channel
- Development Example: Interference Cancellation for Satellite Communi
Junil Ahn
2 weeks
Lab. #1
3.18
(13:00~
14:20)
1.5 - Basic OFDM Junil Ahn
3.18
(14:30~
16:00)
1.5
- Introduction
- How to use Simulink with interleaver
implementation
Jaewook Kang
3 weeks
Lab. #2
3.25
(13:00~
16:00)
3
- How to use S-function builder
- PSF and Matched filter design
- Concept of upsampling and downsampling
Jaewook Kang
4 weeks
Lab. #3
4.1
(13:00~
16:00)
3
- Phase splitter
- Up conversion and down conversion
Jaewook Kang
5 weeks
Lab. #4
4.8
(13:00~
16:00)
3 - How to make subsystem Jaewook Kang
3. - 3/40 -
Today’s main pointsToday’s main points
Know how to use S-function builder
Learn about what PSF is
Implement PSF with up/down-sampling using simulink.
4. - 4/40 -
Lab #1: Convolutional interleaver block implementationLab #1: Convolutional interleaver block implementation
Why do we employ interleaver ?
Error usually occurs in burst manner.
Conventionally, channel coder is designed against a random and independent
error.
Interleaver is introduced to scatter the burst or packetized data in a time domain.
Deinterleaved data show almost random and independent errors.
Channel Decoder can handle such error.
Two type of interleanver
Block interleaver:
Simple concept, easy to implement.
Needs more memory, and cause a large latency
Convolutional interleaver:
Require half memory of block interleaver, causing a small memory.
Most communication system employs this for its attractive features.
5. - 5/40 -
Lab #1: Convolutional interleaver block implementationLab #1: Convolutional interleaver block implementation
Why do we employ interleaver ?
Error usually occurs in burst manner.
Conventionally, channel coder is designed against a random and independent
error.
Interleaver is introduced to scatter the burst or packetized data in a time domain.
Deinterleaved data show almost random and independent errors.
Channel Decoder can handle such error.
Two type of interleanver
Block interleaver:
Simple concept, easy to implement.
Needs more memory, and cause a large latency
Convolutional interleaver:
Require half memory of block interleaver, causing a small memory.
Most communication system employs this for its attractive features.
7. - 7/40 -
Lab #1: Convolutional interleaver block implementationLab #1: Convolutional interleaver block implementation
Specification of Conv.-interleaver
The Number of row : R
Interleaver length: L
The latency through inter and de-interleaver:
The required memory for each block :
L=2
R=4
< Interleaver side > < De-interleaver side >
2
( )R R L− ×
2
( )
2
R R L− ×
9. - 9/40 -
Lab #1: Convolutional interleaver block implementationLab #1: Convolutional interleaver block implementation
S-function builder block
Let’s make R=4, L=1 convolutional interleaver.
The size of the required buffer:
2
( ) (16 4) 2
6
2 2
R R L− × − ×
= =
The Size of the memory
And the initial condition
10. - 10/40 -
Lab #1: Convolutional interleaver block implementationLab #1: Convolutional interleaver block implementation
S-function builder block
Date properties
R
L
11. - 11/40 -
Lab #1: Convolutional interleaver block implementationLab #1: Convolutional interleaver block implementation
S-function builder block
Output – specify what the current output data is in C language
12. - 12/40 -
Lab #1: Convolutional interleaver block implementationLab #1: Convolutional interleaver block implementation
S-function builder block
Discrete Update – Describe operation for memory inside the block, such as
buffer shift at each time instance.
Array wrt. the memory denoted by xD[]
13. - 13/40 -
Lab #1: Convolutional interleaver block implementationLab #1: Convolutional interleaver block implementation
Simulation
Check your block using interleaving block given by MATLAB simulink.
14. - 14/40 -
Lab #1: Convolutional interleaver block implementationLab #1: Convolutional interleaver block implementation
What about de-interleaver block ?
Implementation of de-inleaver block is assignment of this week.
I’ll provide the code at next lecture.
It’s very similar with conv-inverleaver block.
Make it by yourself !!!
Does it work correctly ? Check by yourself like the below figure.
15. - 15/40 -
Our target systemOur target system
Tx part
Rx part
Tx Source Interleaver
QAM
Mapper
PSF X
NCO
↑4
Phase
Splitter
Matched
filter
QAM
DemapperX
NCO
↓4
De-
Interleaver
Rx Source
:Real
:Complex
16. - 16/40 -
Up/Down-samplingUp/Down-sampling
Resampling of Discrete signal
Basically,
Now, we re-sample the signal with L=2
, :The discrete randian frequency (rad/sample).d dw wπ≥
( ) cos( )dx n w n=
0 5 10 15
-1
-0.8
-0.6
-0.4
-0.2
0
0.2
0.4
0.6
0.8
1
time index n
0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2
0
2
4
6
8
10
12
14
16
rad < pi >
0 5 10 15
-1
-0.8
-0.6
-0.4
-0.2
0
0.2
0.4
0.6
0.8
1
time index n
0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2
0
1
2
3
4
5
6
7
8
rad < pi >
Q) Why 16 ?
17. - 17/40 -
Up/Down-samplingUp/Down-sampling
Resampling of Discrete signal
With L=4
With L=8
( ) cos( )dx n w n=
0 5 10 15
-1
-0.8
-0.6
-0.4
-0.2
0
0.2
0.4
0.6
0.8
1
time index n
0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2
0
1
2
3
4
5
6
7
8
rad < pi >
0 5 10 15
-1
-0.8
-0.6
-0.4
-0.2
0
0.2
0.4
0.6
0.8
1
time index n
0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2
0
1
2
3
4
5
6
7
8
rad < pi >
Looks like D-waveform
rather than D-sequence !!
18. - 18/40 -
Up/Down-samplingUp/Down-sampling
Resampling of Discrete signal
The resampling represented like below
How to implement the resampling process
( ) cos( )dx n w n=
_
( ) cos( )
Let n= , :
( ) cos( ) cos( )
d
d d up
x n w n
m
L resampling factor
L
m
x m w w m
L
=
= =
Sample up
L LPF
0 5 10 15
-1
-0.8
-0.6
-0.4
-0.2
0
0.2
0.4
0.6
0.8
1
time index n
0 5 10 15 20 25 30 35
-1
-0.8
-0.6
-0.4
-0.2
0
0.2
0.4
0.6
0.8
1
time index n
0 5 10 15
-1
-0.8
-0.6
-0.4
-0.2
0
0.2
0.4
0.6
0.8
1
time index n
( )x n
( )upx m ( )rex m
Q) What about freq.
response of xup(m) ?
19. - 19/40 -
Up/Down-samplingUp/Down-sampling
Up-sampling
Padding L-1 zeros between two adjacent symbols
Down-sampling
Decimating samples between two adjacent symbol time.
Sample up
L
0 5 10 15
-1
-0.8
-0.6
-0.4
-0.2
0
0.2
0.4
0.6
0.8
1
time index n
0 5 10 15 20 25 30 35
-1
-0.8
-0.6
-0.4
-0.2
0
0.2
0.4
0.6
0.8
1
time index n
( )x n ( )upx m
Sample
down
D
0 5 10 15
-1
-0.8
-0.6
-0.4
-0.2
0
0.2
0.4
0.6
0.8
1
time index n
( )rex m ( )x n
0 5 10 15
-1
-0.8
-0.6
-0.4
-0.2
0
0.2
0.4
0.6
0.8
1
time index n
20. - 20/40 -
Pulse shaping filterPulse shaping filter
Why PSF?
Reason I: Channel Bandwidth is limited !!
From Fourier’s theorem, bandwidth of discrete signal is from –inf
to inf.
x(n) in time domain X(m) frequency domain
21. - 21/40 -
Pulse shaping filterPulse shaping filter
Why PSF?
Reason I: Channel Bandwidth is limited !!
Since the given channel is bandlimited, we cannot transmit such
discrete signals appropriately.
We should reshape the bandwidth of the signals while preserving the
information.
Consider rectangular shaped bandwidth first.
The BW of
the original discrete signal
The limited
rectangular BW
IFT
The bandlimited signal
in time domain
22. - 22/40 -
Pulse shaping filterPulse shaping filter
Why PSF?
Reason I: Channel Bandwidth is limited !!
Rectangular in freq. domain sinc. function in time domain.
The range of sinc. function is .
Multiplication in freq. domain is convolution in time domain such that the
PSF signal is
The BW of
the original discrete signal
The limited
rectangular BW
IFT
The bandlimited signal
in time domain
t−∞ < < ∞
( ) ( ) ( ) ( ) ( ( ))PSF
k
x nT x nT h nT h kT x T n k= ∗ = −∑
23. - 23/40 -
Pulse shaping filterPulse shaping filter
Why PSF?
Reason I: Channel Bandwidth is limited !!
PSF transforms discrete sequences to discrete waveforms with
limited bandwidth.
PSF cut out frequency components to make the input sequnces
compact.
24. - 24/40 -
Pulse shaping filterPulse shaping filter
Why PSF?
Reason II: PSF mitigates ISI effect.
Why ISI?
Since tail of sinc. function of previous symbols coincides with the
current symbol, such a fact can corrupt the current symbols info.
when symbol timing is not matched.
25. - 25/40 -
Pulse shaping filterPulse shaping filter
Why PSF?
Reason II: PSF mitigates ISI effect.
The signal have ISI due to timing mismatched The signal with perfectly timing matched
26. - 26/40 -
Pulse shaping filterPulse shaping filter
Why PSF?
Reason II: PSF mitigates ISI effect.
Well-designed PSFs effectively mitigate the ISI effect according
to roll-off factor.
Smaller amplitude of the
tail mitigates ISI effect
with higher rolloff-factor.
However, it require wider
bandwidth.
27. - 27/40 -
Pulse shaping filterPulse shaping filter
How to design PSF
Step I: system setup
Rsym=1 sym/sec Tsym= 1 sec
Step II: Upsampling
Step III: Nyquist bandwidth constraint
Step IV: Determine number of tap for PSF. (Odd tap)
Tapnum = 2*(Numof zero-crossing in the half side )* L+1
The longer tail, the shaper filter.
Tapnum=65 with L=4 and Numof zero-crossing in the half side =8
_
( / sec)
/ , 4
( / )
1/ 4
sym up sym
sample
R R L let L
L sample sym
= = =
×
=
_
1
2 (1 ) ( ) 0
2 4
sym upW r R rad with r
π
π≥ × + = =
_ 4sym upT =
28. - 28/40 -
Pulse shaping filterPulse shaping filter
How to design PSF
Draw the sinc function using rcosine function with ‘sqrt’ in MATLAB
Note that the sinc. Function is squared root raise cosine function.
Consider symbol energy to be normalized to 1 after PSF
-40 -30 -20 -10 0 10 20 30 40
-0.4
-0.2
0
0.2
0.4
0.6
0.8
1
Time index n
h(n)
0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2
0
0.5
1
1.5
2
2.5
3
3.5
4
4.5
X= 0.24615
Y= 2.4698
w (pi) rad
|H(w)|
29. - 29/40 -
0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2
0
0.2
0.4
0.6
0.8
1
1.2
1.4
w (pi) rad
|H(w)|
Pulse shaping filterPulse shaping filter
Matched filter
Use the same filter as PSF without scale
Divide the filter coefficient by L to keep the symbol energy 1.
-40 -30 -20 -10 0 10 20 30 40
-0.1
-0.05
0
0.05
0.1
0.15
0.2
0.25
Time index n
h(n)
30. - 30/40 -
Pulse shaping filterPulse shaping filter
%--------------------------------------------------------------------------
% This m-file is to generate raised cosine for Pulse Shaping
filter
% 11.3.24 kang jae wook
%--------------------------------------------------------------
% r : roll-off factor of this filter
% L : up-Sampling rate of input signal (sample/sym)
% DESIGNTYPE : you can select 'normal' that makes normal
raised..
% cosine filter.
% tol: The number of zero-crossing point in the half side.
%--------------------------------------------------------------------------
% b=rcosine(1,L,'TYPE'.rolloff,tol)
% Tap = [2 * tol * L] + 1
%------------------------------------------------------------------
% L:4 sample/sym
% Tapnum :65
% roll off :0.5
% --squared root raised cosine filter
%------------------------------------------------
L=4;
r=0;
tol=8;
Tap=2 * tol * fs_up+1
b=rcosine(1,fs_up,'sqrt',r,tol)*2.0;
%c=rcosine(1,4,'normal',0,3);
n=-(Tap-1)/2:(Tap-1)/2
figure (3);
stem(n,b);
xlabel('Time index n','fontsize',12);
ylabel('h(n)','fontsize',12);
w=0:2/Tap:2-2/Tap;
a=abs(fft(b));
figure (4);
stem(w,a);
xlabel('w (pi) rad','fontsize',12);
ylabel('|H(w)| ','fontsize',12);
31. - 31/40 -
Symbol energy EsymSymbol energy Esym
Tx part
Can you indicate energy of symbol at each point of
the Tx block diagram ?
Tx Source Interleaver
QAM
Mapper
PSF X
NCO
↑4
:Real
:Complex
32. - 32/40 -
Our target systemOur target system
Rx part
What about the receiver side ?
Phase
Splitter
Matched
filter
QAM
DemapperX
NCO
↓4
De-
Interleaver
Rx Source
:Real
:Complex
33. - 33/40 -
PSF and MAT with SimulinkPSF and MAT with Simulink
PSF implementation using FIR filter
Add up/down-sampling block
Implement PSF and MAT filter using FIR filter block pair.
Make ctrl – m file with previously given codes.
34. - 34/40 -
PSF and MAT with SimulinkPSF and MAT with Simulink
Tx side
Rx side
upsampling PSF
After MAT
filter
Down-
sampling
35. - 35/40 -
PSF and MAT with SimulinkPSF and MAT with Simulink
PSF, MAT filter using FIR filter via S-function builder
36. - 36/40 -
PSF and MAT with SimulinkPSF and MAT with Simulink
PSF with S-function
Initialization and Data properties
You must put 65 zeros
Generate rcosine coeff. Using m-file
37. - 37/40 -
PSF and MAT with SimulinkPSF and MAT with Simulink
PSF with S-function
C-codes for output
In this place, just put code with respect to the current output.
38. - 38/40 -
PSF and MAT with SimulinkPSF and MAT with Simulink
PSF with S-function
C-codes for update inner-buffer
Dynamic operation, such as buffer shift, should be described here.
39. - 39/40 -
PSF and MAT with SimulinkPSF and MAT with Simulink
PSF with S-function
Implement PSF and Matched filter
Does it properly work like given figures ?
Calculate delay properly to evaluate BER.
You should consider inter de/lnterleaver delay as well as PSF and MAT
delay.
Check symbol energy at all points.
Think why the symbol energy have changed like that
40. - 40/40 -
Next time…Next time…
Place: IC203
Weeks Time Hour Instructor
1 week
Lab. #0
3.11
(13:00~
16:00)
3
- Overview of Development with Simulink
- QPSK Model with AWGN Channel/ Rayleigh Fading
Channel
- Development Example: Interference Cancellation for Satellite Communi
Junil Ahn
2 weeks
Lab. #1
3.18
(13:00~
14:20)
1.5 - Basic OFDM Junil Ahn
3.18
(14:30~
16:00)
1.5
- Introduction
- How to use Simulink with interleaver
implementation
Jaewook Kang
3 weeks
Lab. #2
3.25
(13:00~
16:00)
3
- How to use S-function builder
- PSF and Matched filter design
- Concept of upsampling and downsampling
Jaewook Kang
4 weeks
Lab. #3
4.1
(13:00~
16:00)
3
- Phase splitter
- Up conversion and down conversion
Jaewook Kang
5 weeks
Lab. #4
4.8
(13:00~
16:00)
3
- How to make subsystem
- Channel implementation using
Jaewook Kang