Sie sind auf Seite 1von 15

c Y

Here I will provide all the code that I am developing. I will start in ascending

order, that is, from the first program written onwards. I hope that the

explanations will be sufficient. All the code will be in HTML format, just copy

and paste into the MATLAB editor and you will be good to go.Y
YY
VersionY Short DescriptionY DateY
YY YY YY
0.10 Y Standard MCM communications systemY 09.10.04Y

0.11 Y * Incomplete *Y 09.11.04Y

0.12 Y Generic OFDM with Cyclic Prefixing Y 09.12.04Y

0.13 Y Added Channel equalization & AWGN noise effectsY 09.20.04Y


YY YY YY
YY
  
  Y
Y

1.Y do_paddingY

Takes the serial input data and the user specified block size, then checks

the serial data if it can be completely divided into an integer number of

blocks. If not, it will add zeros to the end of the stream until an integer

number of blocks can be created.Y

  
 Y

Version 0.10 is basically a trial run to get back into the mode of things. This is

a simple MCM communications system. The code is pretty self-explanatory.Y


YY
Y

See the code Y ofdm_010 Y

YY
·esults of running this script:Y
YY

Fig. 1. Random input data samplesY


Y

YY

Fig. 2. QPSK signal constellation of the input dataY


Y

YY
Fig. 3. Real part of the OFDM signal that is transmittedY
Y

YY

Fig. 4. Complex part of the OFDM signal that is transmittedY


Y

YY
Fig. 5. Received data samples Y
Y

YY
YY
X
X  
  
X      
       
X 
X    !
X 
X " #   $%&$  '   
#
  
 (  # 

X    #  
 % # )  
 #    *  
X   &    '    *        

X
X &+,! +    )        - # ) ' *  
X .......................................................................
X
X 
X %! + 
 ,
X 
X  /   
   *   
 0$%&$ *    1
X  - #

  0-2 . 3-2 # *1
X 4      
X  5+
X 6 -     

X  /   
 . 7
8#88  . 97
 .  08#88  !17
# ' 01

0 17 '  7 ) 0::17  0:%
  :17  0:5:1

X   

'8) . (
0  17
  0
'8)17
X 4    -  
  8
8 .  0
'8);;17

X  9  5+
#
8
' . ##0  8
817

X 6 -     
#
8
'8) .  0#
8
' 917
# ' 041
0 0#
8
'8)117 '  7  0:$    #   ':1
# ' 01
0
'0#
8
'8)117 '  7  0:5
'     #   ':1

X 
X <! $ = ,
X 

X     -  
#
8
'8 ) .  0#
8
'8) ;;17

X  9  +

'8 ) . ##0#
8
'8 )17

X 4 -     

'8 )8 .  0


'8 )  917

X  
 

'8
 . (
0
'8 )8  17
# ' 061

0
'8
17 '  7  0::1

X
X  
    >>> 5
  >>>>
X      
       
X
X ?? & *     ??
X  %   
       #  
 
X  5

    # ) 0-1  X # 
  '  =   9
X      ;   
 '       -  
X    

X 4 5  
 )     
   '
X
X  ' @  # + 
  #  

X  /   
X  
X     -  
X    - # ) 0-1
X  % -   
X # 5+
X ' -     
X .......................................................................
X
X 
X %!  #   
X 
 . 7 X  . # 3-2
 
8#88  . 97 X = 9   
8#8   . 8#88 A;7 X
(   
  (  ' ;

X  /    ) 9 =  # 
  
8 .  0 8#88  !17

X  - #
3-2
 
B(8
 8 . (
08  17

X 4      !  ;   0 *1   ' # ;


X 
     (  (  ; ) ;
 ) *    

X   ' # ;    # 
    

X ,C!  8 . D  4  6 9 E ;F =       *  (


X  (
X   8 .  6
X  9
X 4 E
X  ;
  8
8 .  0B(8
 8 8#8  ;17

X  %    
    #     ( &*   *
X
 ) *  =  )  * ,    *  =   
 
X  @   # # # 
X ,C! 5#   *     = )
   *  (  ( !
X
X   8 .  6
X  9
X 4 E
X  ;
X 
X  
X
 8 .  0;17
88  . D  8
87 8F

X 6      # ) (   ' X  #    


X   
 5     * = ;    *   ' # 
X     )  * *      

  
 Y

This is a more complete (well the first one anyway) OFDM system. It involves

all the necessary steps to generate an OFDM signal.Y


YY
Y

See the code Y ofdm_012 Y

YY
In this instance of the program, the user can specify how to do block

processing of the incoming signal. Here are the basic steps.Y


YY
Àransmitter End:Y

1.Y Define constants, such as block size, number of FFT/IFFT points, etc.Y

2.Y Call user written function 'do_padding'. This will take the length

(number) input data points and divide it by the block size. If the result is

an integer, then no padding is necessary. Otherwise, it will pad the

data stream with zeros so that there are an integer number of blocks.Y

Example: input = [1 2 3 4 5]; block_size = 4Y

after calling 'do_padding', input becomes [1 2 3 4 5 0 0 0]Y

3.Y Do modulation. In this case, I used the MATLAB function, 'pskmod' &

'pskdemod' pairs.Y

4.Y Do serial to parallel, i.e. reshape the serial 1 x N vector into a matrix

where the number of rows equal the block size. In this way, IFFT can

be performed columnwise and each column will represent one block of

data.Y

5.Y Do IFFT on each column of the data matrix.Y

6.Y Compute, generate and append the Cyclic Prefix to the data matrix in

4.Y

7.Y ·eshape the matrix back to a 1 x N + cyclic prefix length vector for

transmission.Y
YY
·eceiver End:Y

Just do the opposite to all of the above!Y


YY
·esults of running this script:Y
YY

Fig. 1. OFDM system without the effects of the channel or noise. Note that the red "x"
(received) perfectly matches up to the blue "o" (transmitted).Y
  

 X      # ' 
X
X  
  
X      
       
X
X ?? & *     ??
X + 

X     08 '1    ' #      
X  '
     ' 
 #  (
X     ( #    # 
    
 
 )
X #
* # 5+ G   - # ) ' 0-1    (
X *   
   (
X 4 % -  )   '  ( # 
X  = 
  ) #  ( #  G -     ' # +C
X
X $ =
X 6   $C   
    =  H#  H 


X 9 $
= -  + G 


X 
X %!  #   
X 
 . 7 X 3-2  '   
8#88  . 97 X = ;   
 (8 @ . ;7 X  @ #   #
 (
8  . 0? (8 @ 17 X  ' #    # )
8#8 ##8  .  (8 @ 7 X ;   #  +A5+
8#8##8  .  (8 @ 7
X 
X <! X IIIII +$%&5++,$ J,% ,& IIIII
X 
X  /    ) ; =  # 
  
8 .  0 8#88  !17
# ' 01

08 17 '  7 ) 0: - :17  0:%
  :1
  0:+ 
   HH:1

X   :8 ': #     ( #   ' 


 #  (
X   '    # 
 (8 @   #      5# 
X @    

(    
D 8 8#8 (F.8 '08   (8 @ 17

X 4 - #
3-2
 
B(8
 8 . (
0 8 17
  0B(8
 817  0:3-2  :1

X   5+     (
X (     

 ) *   
      
X  ( 0*A    # ) '1
X  !     
 # 
  *  )  #  '

8 . '0B(8
 81A (8 @ 7
 88
 ) .  0B(8
 8  (8 @  
8 17

X  !  

 )    5+: 
8  .  (8 @  8 7
8  .  (8 @ 7

X + !   
*  G  -
# .!
8 
##88
 )0! 1 .
##00 88
 )0! 118#8 ##8 17
X 
      - # )
# .! 8 
 8 0 1 . ##88
 )0I 8  17

X %   -   )  '  (        (
##80! 1 . =  0 8 0! 1 ##88
 )0! 117


X 6 =      
#  
 
D *8 ##8 8 ##8F. @ 0 ##817
 8#
8 . *8 ##8? 8 ##87

X %    '    


 
#
8 ' .  0 ##8   8#
817
# ' 041
0 0#
8 '117 ) 0:+
:17  0:%
  :17
  0:  ':17'  7

X 
X ! X IIIII J%&&,K IIIII
X 
X    
 )
   
XIII   . 0 (8 @ 1 I B 01? 0 (8 @ 17

X 
X ! X IIIII $,,5 ,$ +%5K ,& IIIII
X 
X
X  /   

 )  
XIII  . 0 8#
81 I B 01? 0 8#
817

X  -  #
 '  '   
XII# 8   . #  0    #
8 '17

X 4 %     '
XII =8 ' . # 8   I   7
=8 ' . #
8 '7

X  =    (  H  H #


  #
+
=8 '8
 ) .  0 =8 ' *8 ##8 8 ##817

X 6 $
= -
=8 '8
 )0! 8 !1.DF7

X 9 - #
+
# .! 8 ##8
X +
##88
 )0! 1 . ##0 =8 '8
 )0! 18#8##8 17


X E =      

=8 8 .  0##88


 ) 0 (8 @ ?
8 117

X ; 
  
B(8
 8 . (
0 =8 817

# ' 01

08 1
 

0B(8
 8: ):17
'  7) 0: - :17 0:%
  :17  0:$ =   HCH:1

  
 Y

I have further added a very simple Linear Equalizer to the code, where I

assume that the channel is perfectly known. Note that for equalization to work

here, the prefix length must be equal to or greater than the length of the

channel.Y
YY
Afterwards, I added some AWGN noise to the received data. The figures

below shows some of the results.Y


YY
Y

See the code Y ofdm_013 Y

YY
·esults of running this script:Y
YY

Fig. 1. Superposition of À (blue) & R (red) data after channel effects and equalizationY
Y

YY
Fig. 2. Same data stream with 0 dB AWGNY
Y

YY

Fig. 3. Notice that as the SNR increases the number of errors will decreaseY
Y
  

 X      # ' 
X
X  
  4
X      
       
X
X ?? & *    4 ??
X  %    ##        5$ # 
X  ,B @  #     ' 
 '     
X 4 5

  # %L/&   #   ## 
X 4    &
 # ,    <  ,  $

X 
X %!  #   
X 
 . 7 X 3-2  '   
8#88  . 97 X = ;   
 (8 @ . ;7 X  @ #   #
 (
8  . 0? (8 @ 17 X  ' #    # )
8#8 ##8  .  (8 @ 7 X ;   #  +A5+
8#8##8  .  (8 @ 7
X 
X <! X IIIII +$%&5++,$ J,% ,& IIIII
X 
X  /    ) ; =  # 
  
8 .  0 8#88  !17
X# ' 01
X
08 17 '  7 ) 0: - :17  0:%
  :1
X  0:+ 
   HH:1

X   :8 ': #     ( #   ' 


 #  (
X   '    # 
 (8 @   #      5# 
X @    

(    
D 8 8#8 (F.8 '08   (8 @ 17

X 4 - #
3-2
 
B(8
 8 . (
0 8 17
X  0B(8
 817  0:3-2  :1

X   5+     (
X (     

 ) *   
      
X  ( 0*A    # ) '1
X  !     
 # 
  *  )  #  '

8 . '0B(8
 81A (8 @ 7
 88
 ) .  0B(8
 8  (8 @  
8 17

X  !  

 )    5+: 
8  .  (8 @  8 7
8  .  (8 @ 7

X + !   
*  G  -
# .!
8 
##88
 )0! 1 .
##00 88
 )0! 118#8 ##8 17
X 
      - # )
# .! 8 
 8 0 1 . ##88
 )0I 8  17

X %   -   )  '  (        (
##80! 1 . =  0 8 0! 1 ##88
 )0! 117


X 6 =      
#  
 
D *8 ##8 8 ##8F. @ 0 ##817
 8#
8 . *8 ##8? 8 ##87

X %    '    


 
#
8 ' .  0 ##8   8#
817

X 9     ' *


 '8* . 0#
8 '17

X 
X ! X IIIII J%&&,K IIIII
X 
X     
 )
   
  . 01 I B 01? 017

X  -  #
 '  '   
# 8   . #  0    #
8 '17

X 
X ! X IIIII $,,5 ,$ +%5K ,& IIIII
X 
X
X 4 % & 
*'8  . *'0@ 0 '0# 8  1117
  8* . 0*'8  17

=8 ' . # 8  7 X L   


X =8 ' . *'8  I# 8  7 X L  %L/&  

X  =    (  H  H #


  #
+
=8 '8
 ) .  0 =8 ' *8 ##8 8 ##817

X 6 $
= -
=8 '8
 )0! 8 !1.DF7

X 9  ,B @ 
X +( + #    G    #      (
D8  F . 8 '0   (8 @ 17
8## . ##08  (8 @ 17
8## .  0 8## '0 8##117

D 8 =8 '8
 8 =8 '8
F. @ 0 =8 '8
 )17
# .! 8 =8 '8

=8 '8
 )0 !1. =8 '8
 )0 !1A 8##0 17


X E - #
+
# .! 8 ##8
X +
##88
 )0! 1 . ##0 =8 '8
 )0! 18#8##8 17


X ; =      

=8 8 .  0##88


 ) 0 (8 @ ?
8 117

X M 
  
B(8
 8 . (
0 =8 817

# ' 01

08 1
 

0B(8
 8: ):17
'  7) 0: - :17 0:%
  :17
  0:$ =   H)H *    ,## :1

X 
X ,! X IIIII %K"K%+, <5+ ,$$$ IIIII
X 
D8#8    F.  08 B(8
 81
)  '8 ( .

8#8   .

 .

;4