Wireless PHY: Modulation and Demodulation Y. Richard Yang 09/11/2012
Outline Admin and recap Amplitude demodulation Digital modulation 2
Admin Assignment 1 posted 3
Recap: Modulation Objective o Frequency assignment Basic concepts o the information source (also called baseband) o carrier o modulated signal baseband carrier Modulator Modulated signal 4
Recap: Amplitude Modulation (AM) Block diagram x(t) m x + x AM (t)=a c [1+mx(t)]cos c t Time domain me Domain A c cos c t Frequency Domain domain X(f) X AM (f) sideba -f m f m f -f c f c f 5
Recap: Demod of AM Design option 1: multiply modulated signal by e -jfct, and then LPF Design option 2: quadrature sampling 6
Example: Scanner Setting: a scanner scans 128KHz blocks of AM radio and saves each block to a file. For the example file During scan, fc = 710K LPF = 128K (one each side) 7
Exercise: Scanner Requirements Scan the block in a saved file to find radio stations and tune to each station (each AM station has 10 KHz) Audio device requires 48K sample rate for playback 8
Remaining Hole: How to Design LPF Frequency domain view -B B freq -B B freq 9
Design Option 1 compute freq -B B freq compute lower-pass time signal zeroing out outband freq This is essentially how image compression works. -B B freq Problem(s) of Design Option 1? 10
Design Option 2: Impulse Response Filters GNU software radio implements filtering using Finite Impulse Response (FIR) filters Infinite Impulse Response (IIR) Filters FIR filters are more commonly used FIR/IIR is essentially online, streaming algorithms They are used in networks/ communications/vision/robotics 11
FIR Filter An N-th order FIR filter h is defined by an array of N+1 numbers: h = [h 0, h 2,..., h N ] They are often stored backward (flipped) h N h 2 h 1 h 0 Assume input data stream is x0, x1,, 12
FIR Filter x n-3 x n-2 x n-1 x n x n+1 3 rd -Order Filter * * * * h 3 h 2 h 1 h 0 compute y[n]: y n = x n h 0 + x n 1 h 1 +... + x n N h N N = x n i h i 13
FIR Filter x n-3 x n-2 x n-1 x n x n+1 * * * * h 3 h 2 h 1 h 0 compute y[n+1] 14
FIR Filter y n = x n h 0 + x n 1 h 1 +... + x n N h N is also called convolution between x (as a vector) and h (as a vector), denoted as y n = x n * h n 15
Key Question Using h to Implement LPF Q: How to determine h? Approach: Understand the effects of y=g*h in the frequency domain 16
g*h in the Continuous Time Domain Remember that we consider x as samples of time domain function g(t) on [0, 1] and (repeat in other intervals) We also consider h as samples of time domain function h(t) on [0, 1] (and repeat in other intervals) for (i = 0; i< N; i++) y[t] += h[i] * g[t-i]; y(t) = 1 0 h(τ )g(t τ )dτ 17
Visualizing g*h g(t) time h(t) 0 T T 0 18
Visualizing g*h g(t) g(t) t time h(0) 0 T 0 T 19
Fourier Series of y=g*h y(t) = 1 0 h(τ )g(t τ )dτ Y[k] = 1 0 y(t)e j2πkt dt = 1# 1 h(τ )g(t & τ )dτ $% 0 '( e j2πkt dt 0 = 1# 1 h(τ )g(t τ )e $% j2πkt & dτ 0 '( dt 0 20
Fubini s Theorem In English, you can integrate first along y and then along x first along x and then along y at (x, y) grid They give the same result See http://en.wikipedia.org/wiki/fubini's_theorem 21
Fourier Series of y=g*h y(t) = 1 0 h(τ )g(t τ )dτ Y[k] = 1# 1 h(τ )g(t τ )e $% j2πkt & dτ 0 '( dt 0 = 1# 1 h(τ )g(t τ )e j2πkt dt & $% 0 '( dτ 0 = 1 h(τ ) # 1 g(t τ )e j2πkt dt & $% 0 '( dτ 0 = 1 h(τ )e j2πkτ # 1 g(t τ )e j2πk(t τ ) dt & $% 0 '( dτ 0 = h(τ )e j2πkτ G[k]dτ 0 1 = G[k]H[k] 22
Summary of Progress So Far y = g * h => Y[k] = G[k] H[k] In the case of Fourier Transform, y = g * h => Y[f] = G[f] H[f] is called the Convolution Theorem, an important theorem. 23
Applying Convolution Theorem to Design LPF Choose h() so that H() is close to a rectangle shape 1-1/2 1/2 f h() has a low order (why?) 24
Sinc Function The h() is often related with the sinc(t)=sin(t)/t function sin(πt) e j2π ft = rect( f ) πt -1/2 1 1/2 f 25
FIR Design in Practice Compute h MATLAB or other design software GNU Software radio: optfir (optimal filter design) GNU Software radio: firdes (using a method called windowing method) Implement filter with given h freq_xlating_fir_filter_ccf or fir_filter_ccf 26
LPF Design Example Design a LPF to pass signal at 1 KHz and block at 2 KHz 27
LPF Design Example #create the channel filter # coefficients chan_taps = optfir.low_pass( 1.0, #Filter gain 48000, #Sample Rate 1500, #one sided mod BW (passband edge) 1800, #one sided channel BW (stopband edge) 0.1, #Passband ripple 60) #Stopband Attenuation in db print "Channel filter taps:", len(chan_taps) #creates the channel filter with the coef found chan = gr.freq_xlating_fir_filter_ccf( 1, # Decimation rate chan_taps, #coefficients 0, #Offset frequency - could be used to shift 48e3) #incoming sample rate 28
Outline Recap Amplitude demodulation frequency shifting low pass filter Digital modulation 29
Modulation Modulation of digital signals also known as Shift Keying 1 0 1 Amplitude Shift Keying (ASK): vary carrier amp. according to data t Frequency Shift Keying (FSK) o vary carrier freq. according to bit value 1 0 1 t 1 0 1 Phase Shift Keying (PSK) o vary carrier freq. according to data t 30
Phase Shift Keying: BPSK BPSK (Binary Phase Shift Keying): bit value 1: cosine wave cos(2πf c t) bit value 0: inverted cosine wave cos(2πf c t+π) Q very simple PSK Properties 0 1 I robust, used e.g. in satellite systems one bit time T one bit time T 1 0 31
Phase Shift Keying: QPSK QPSK (Quadrature Phase Shift Keying): 2 bits coded at a time we call the two bits as one symbol symbol determines shift of cosine wave often also transmission of relative, not absolute phase shift: DQPSK - Differential QPSK 10 00 Q 11 I 01 32
Quadrature Amplitude Modulation Quadrature Amplitude Modulation (QAM): combines amplitude and phase modulation It is possible to code n bits using one symbol 2 n discrete levels Q 0010 0011 a φ 0001 0000 1000 I Example: 16-QAM (4 bits = 1 symbol) Symbols 0011 and 0001 have the same phase φ, but different amplitude a. 0000 and 1000 have same amplitude but different phase 33
Generic Representation of Digital Keying (Modulation) Sender sends symbols one-by-one M signaling functions g 1 (t), g 2 (t),, g M (t), each has a duration of symbol time T Each value of a symbol has a signaling function 34
Exercise: g i () for BPSK 1: Q g 1 (t) = cos(2πf c t) t in [0, T] 0: g 0 (t) = -cos(2πf c t) t in [0, T] 0 1 I Are the two signaling functions independent? Hint: think of the samples forming a vector, if it helps, in linear algebra Ans: No. g 1 (t) = -g 0 (t) g 0 (t) g 1 (t) -1 1 cos(2πf c t)[0, T] 35
Exercise: Signaling Functions g i () for QPSK 11: cos(2πf c t + π/4) t in [0, T] 10 Q 11 10: 00: 01: cos(2πf c t + 3π/4) t in [0, T] cos(2πf c t - 3π/4) t in [0, T] cos(2πf c t - π/4) t in [0, T] 00 I 01 Are the four signaling functions independent? Ans: No. They are all linear combinations of sin(2πf c t) and cos(2πf c t). 36
QPSK Signaling Functions as Sum of cos(2πf c t), sin(2πf c t) 11: cos(π/4 + 2πf c t) t in [0, T] -> cos(π/4) cos(2πf c t) + -sin(π/4) sin(2πf c t) 10: cos(3π/4 + 2πf c t) t in [0, T] -> cos(3π/4) cos(2πf c t) + -sin(3π/4) sin(2πf c t) 00: cos(- 3π/4 + 2πf c t) t in [0, T] -> cos(3π/4) cos(2πf c t) + sin(3π/4) sin(2πf c t) 01: cos(- π/4 + 2πf c t) t in [0, T] -> cos(π/4) cos(2πf c t) + sin(π/4) sin(2πf c t) 00 [cos(3π/4), sin(3π/4)] [cos(3π/4), -sin(3π/4)] 10 We call sin(2πf c t) and cos(2πf c t) the bases. sin(2πf c t) 01 [cos(π/4), sin(π/4)] cos(2πf c t) [-sin(π/4), cos(π/4)] 11 37
Outline Recap Amplitude demodulation frequency shifting low pass filter Digital modulation modulation demodulation 38
Key Question: How does the Receiver Detect Which g i () is Sent? Assume synchronized (i.e., the receiver knows the symbol boundary). 39
Starting Point Considered a simple setting: sender uses a single signaling function g(), and can have two actions send g() or nothing (send 0) How does receiver use the received sequence x(t) in [0, T] to detect if sends g() or nothing? 40
Design Option 1 Sample at a few time points (features) to check Issue Not use all data points, and less robust to noise 41
Design Option 2 Streaming algorithm, using all data points in [0, T] As each sample x i comes in, multiply it by a factor h T-i-1 and accumulate to a sum y x 0 x 1 x 2 x T * * * * h T h 2 h 1 h 0 At time T, makes a decision based on the accumulated sum at time T: y[t] 42
Example Streaming (Convolution/Correlation): Assume incoming x is a rectangular pulse (in baseband) and h is also a rectangular pulse A gif animation: redline g(): the sliding filter h(t) blue line f(): the input x() Source: http://en.wikipedia.org/wiki/file:convolution_of_box_signal_with_itself2.gif 43
Determining the Best h y = (g + w)* h = g*h + w * h = g o + n where w is noise, g o (t) = g*h n = w * h Design objective: maximize peak pulse signalto-noise ratio 44
Determining the Best h g o (t) = g*h Assume Gaussian noise, one can derive E[n 2 (T )] = N 0 2 H( f ) 2 df Using Fourier Transform and Convolution Theorem: g o (T ) = G 0 ( f )e j2π ft df = G( f )H( f )e j2π ft df η = G( f )H( f )e j2π ft df N 0 2 H( f ) 2 df 2 45
Determining the Best h Apply Schwartz inequality η = G( f )H( f )e j2π ft df N 0 2 H( f ) 2 df 2 x( f )y( f )df x( f ) 2 df 2 y( f ) 2 df equal iff x( f ) = ky *( f ) By considering x( f ) = H( f ) y( f ) = G( f )e j2πtf H opt ( f ) = k[g( f )e j2π ft ]* j2π ft = kg *( f )e 46
Determining the Best h j2π ft H opt ( f ) = kg *( f )e η = G( f )H( f )e j2π ft df N 0 2 H( f ) 2 df 2 f = h opt (t) = H opt ( f )e j2π ft = kg *( f )e j2π ft e h opt (t) = kg(t t) f = f = f = f = = kg( f )e j2π ft e = kg( f )e = kg( f )e j2π f (T t) j2π f (T t) j2π ft j2π ft 47
Determining Best h to Use x 0 x 1 x 2 x T x 0 x 1 x 2 x T * * * * h T h 2 h 1 h 0 * * * * g 0 g 1 g 2 g T h opt (t) = kg(t t) 48
Matched Filter Decision is called Matched filter. Example h opt (t) = kg(t t) h opt (t) = kg(t t) decision time 49
Backup Slides 50
Modulation 51