DSP-CIS Chapter-3: Acoustic Modem Project Marc Moonen Dept. E.E./ESAT, KU Leuven marc.moonen@esat.kuleuven.be www.esat.kuleuven.be/scd/ Introduction • Will consider digital communications over acoustic channel: Discrete-time transmit signal Discrete-time receiver signal (sampling rate Fs, e.g. 10kHz) (sampling rate Fs, e.g. 10kHz) Tx D-to-A +filtering +amplif. Digital Picture (IN) DSP-CIS / Chapter-3: Acoustic Modem Project / Version 2012-2013 A-to-D Rx +filtering +… Digital Picture (OUT) p. 2 Introduction • Will consider digital communications over acoustic channel: Discrete-time transmit signal Discrete-time receiver signal (sampling rate Fs, e.g. 10kHz) (sampling rate Fs, e.g. 10kHz) Tx D-to-A +filtering +amplif. A-to-D Rx +filtering +… This will be the easy part… DSP-CIS / Chapter-3: Acoustic Modem Project / Version 2012-2013 p. 3 Introduction • Will consider digital communications over acoustic channel: …straightforwardly realized (in Matlab/Simulink with `Real-Time Workshop’, see below) Discrete-time transmit signal Discrete-time receiver signal (sampling rate Fs, e.g. 10kHz) (sampling rate Fs, e.g. 10kHz) Tx D-to-A +filtering +amplif. A-to-D Rx +filtering +… means we do not have to deal with hardware issues, components, etc. DSP-CIS / Chapter-3: Acoustic Modem Project / Version 2012-2013 p. 4 Introduction • Will consider digital communications over acoustic channel: …and will be modeled by a linear Discrete-time discrete-time transfer function Discrete-time transmit signal (see below) (sampling rate Fs, e.g. 10kHz) (sampling rate Fs, e.g. 10kHz) Tx D-to-A +filtering +amplif. receiver signal H(z) DSP-CIS / Chapter-3: Acoustic Modem Project / Version 2012-2013 A-to-D Rx +filtering +… p. 5 Introduction • Will consider digital communications over acoustic channel: Discrete-time transmit signal Discrete-time receiver signal (sampling rate Fs, e.g. 10kHz) (sampling rate Fs, e.g. 10kHz) Tx D-to-A +filtering +amplif. A-to-D Rx +filtering +… This is the interesting part… (where we will spend most of the time) DSP-CIS / Chapter-3: Acoustic Modem Project / Version 2012-2013 p. 6 • Introduction Will use OFDM as a modulation format Orthogonal frequency-division multiplexing From Wikipedia, the free encyclopedia Orthogonal frequency-division multiplexing (OFDM), essentially identical to (…) discrete multi-tone modulation (DMT), is a frequency-division multiplexing (FDM) scheme used as a digital multi-carrier modulation method. A large number of closelyspaced orthogonal sub-carriers are used to carry data. The data is divided into several parallel data streams or channels, one for each sub-carrier. Each sub-carrier is modulated with a conventional modulation scheme (such as quadrature amplitude modulation or phase-shift keying) at a low symbol rate, maintaining total data rates similar to conventional single-carrier modulation schemes in the same bandwidth. OFDM has developed into a popular scheme for wideband digital communication, whether wireless or over copper wires, used in applications such as digital television and audio broadcasting, wireless networking and broadband internet access. - OFDM/DMT is used in ADSL/VDSL, WiFi, DAB, DVB … OFDM heavily relies on DSP functionalities (FFT/IFFT, …) DSP-CIS / Chapter-3: Acoustic Modem Project / Version 2012-2013 p. 7 Channel Modeling & Evaluation Transmission channel consist of – – – – – Tx `front end’: filtering/amplification/Digital-to-Analog conv. Loudspeaker (ps: cheap loudspeakers mostly have a non-linear characteristic ) Acoustic channel Microphone Rx `front end’: filtering/Analog-to-Digital conv. Discrete-time transmit signal Discrete-time receiver signal (sampling rate Fs, e.g. 10kHz) (sampling rate Fs, e.g. 10kHz) Tx D-to-A +filtering +amplif. DSP-CIS / Chapter-3: Acoustic Modem Project / Version 2012-2013 A-to-D Rx +filtering +… p. 8 Channel Modeling & Evaluation Acoustic channel (`room acoustics’): Acoustic path between loudspeaker and microphone is represented by the acoustic impulse response (which can be recorded/measured) –first there is a dead time –then come the direct path impulse and some early reflections, which depend on the geometry of the room –finally there is an exponentially decaying tail called reverberation, corresponding to multiple reflections on walls, objects,... DSP-CIS / Chapter-3: Acoustic Modem Project / Version 2012-2013 p. 9 Channel Modeling & Evaluation -1 -2 H(z) = h0 + h1.z + h2.z +... + hL .z -L – Pragmatic & good-enough approximation – Model order L depends on sampling rate (e.g. L=100…1000…) Tx D-to-A +filtering +amplif. H(z) DSP-CIS / Chapter-3: Acoustic Modem Project / Version 2012-2013 A-to-D +filtering +… Rx PS: will use shorthand notation here, i.e. hk, xk, yk , instead of h[k], x[k], y[k] Complete transmission channel will be modeled by a discrete-time (FIR `finite impulse response’) transfer function p. 10 Channel Modeling & Evaluation When a discrete-time (Tx) signal xk is sent over a channel… H(z) = h0 + h1.z-1 + h2.z-2 +... + hL .z-L ..then channel output signal (=Rx input signal) yk is é ê ê ê ê ê ê ê ê ê ê ë yk yk+1 yk+2 yk+3 yk+4 yk+K ù é ú ê ú ê ú ê ú ê ú=ê ú ê ú ê ú ê ú ê ú û ê ë xk xk-1 xk-2 xk-L xk+1 xk xk-1 xk+1-L xk+2 xk+1 xk xk+2-L xk+3 xk+2 xk+1 xk+3-L xk+4 xk+3 xk+2 xk+4-L xk+K xk+K -1 xk+K -2 xk+K -L ù ú úé úê úê ú. ê úê úê úê ë úê ú û h0 ù ú h1 ú ú h2 ú ú ú hL ú û =`convolution’ DSP-CIS / Chapter-3: Acoustic Modem Project / Version 2012-2013 p. 11 Channel Modeling & Evaluation Can now run parameter estimation experiment: 1. Transmit `well-chosen’ signal xk 2. Record corresponding signal yk yk xk Tx D-to-A H(z) +filtering +amplif. DSP-CIS / Chapter-3: Acoustic Modem Project / Version 2012-2013 A-to-D Rx +filtering +… p. 12 Channel Modeling & Evaluation 3. Least squares estimation yk yk+1 yk+2 yk+3 yk+4 yk+K ù é ú ê ú ê ú ê ú ê ú-ê ú ê ú ê ú ê ú ê úû êë xk xk-1 xk-2 xk-L xk+1 xk xk-1 xk+1-L xk+2 xk+1 xk xk+2-L xk+3 xk+2 xk+1 xk+2-L xk+4 xk+3 xk+2 xk+4-L xk+K xk+K -1 xk+K -2 xk+K -L ù ú úé úê úê ú. ê úê úê úê ú êë úû h0 ù ú h1 ú ú h2 ú ú ú hL ú û 2 (i.e. one line of Matlab code ) DSP-CIS / Chapter-3: Acoustic Modem Project / Version 2012-2013 p. 13 Carl Friedrich Gauss (1777 – 1855) min h0 ,h1,h2 ,...,hL é ê ê ê ê ê ê ê ê ê êë 2 Channel Modeling & Evaluation Estimated transmission channel can then be analysed… • Frequency response • Information theoretic capacity f max C ( bits/sec ) log f min 2 (1 S( f ) ) df N(f ) ps: noise spectrum? DSP-CIS / Chapter-3: Acoustic Modem Project / Version 2012-2013Claude Shannon 1916-2001 p. 14 OFDM modulation DMT – Discrete Multitone Modulation OFDM – Orthogonal Frequency Division Multiplexing Basic idea is to (QAM-)modulate (many) different carriers with low-rate bit streams. The modulated carriers are summed and then transmitted. A high-rate bit stream is thus carried by dividing it into hundreds of low-rate streams. Modulation/demodulation is performed by FFT/IFFT (see below) Now 14 pages of (simple) maths/theory… DSP-CIS / Chapter-3: Acoustic Modem Project / Version 2012-2013 p. 15 OFDM Modulation 1/14 Consider the modulation of a complex exponential carrier (with period N) ck = (e j 2 p /N )k for k = 0,1,... carrier ck by a `symbol sequence’ (see p.21) Xk for k = 0,1,... defined as xk = ck .X k Xk xk x ê k ú symbol for k = 0,1,... and k = ê ú sequence ëNû (i.e. “1 symbol per N samples of the carrier”) • PS: remember that modulation of sines and cosines is similar/related to modulation of complex exponentials (see also p.20, 2nd ‘PS’) DSP-CIS / Chapter-3: Acoustic Modem Project / Version 2012-2013 p. 16 OFDM Modulation xk = ck .X k êkú for k = 0,1,... and k = ê ú ëNû carrier ck This corresponds to… é xk ê ê xk+1 ê ê xk+2 ê xk+3 ê ê xk+4 ê ê xk+N -1 ê ë 2/14 ù é (e j 2 p / N )0 ú ê j 2p /N 1 ) ú ê (e ê ú j 2p /N 2 (e ) ê ú ú = ê (e j 2 p / N )3 ú ê j 2p /N 4 ) ú ê (e ú ê ú ê ê (e j 2 p / N ) N -1 ú û ê ë ù ú ú ú ú ú.X k ú ú ú ú ú ú û Xk xk x symbol sequence time-domain signal segment DSP-CIS / Chapter-3: Acoustic Modem Project / Version 2012-2013 p. 17 OFDM Modulation 3/14 Now consider the modulation of N such complex exponential carriers x … ck(n) = (e j 2 p n/ N )k for k = 0,1,... and n = 0,1,.., N -1 by `symbol sequences’ Xk(n) for k = 0,1,... and n = 0,1,.., N -1 defined as (n) k (n) k X (n ) k x (kn ) x … x = c .X (n) k ) c (n k êkú for k = 0,1,... and k = ê ú ëNû + N -1 xk = å x (kn ) n=0 DSP-CIS / Chapter-3: Acoustic Modem Project / Version 2012-2013 x p. 18 OFDM Modulation 4/14 This corresponds to… é ê ê é x ù ê k ê ú ê ê xk+1 ú ê ê ú ê x ê k+2 ú ê ê xk+3 ú = ê ê ú ê x ê k+4 ú ê ê ú ê ê ú ê x êë k+N -1 úû ê ê time-domain ê signal segment ê ë (e (e (e (e (e (e j. 2p N 0 j. 2p N 0 j. 2p N 0 j. 2p N 0 j. 2p N 0 j. 2p N 0 ) ) ) ) ) ) (e (e (e (e (e (e j. j. 2p N 0 ) j. 2p N 1 ) j. 2p N 2 j. 2p N 3 j. 2p N ) ) 2p N ) ) 4 N-1 (e (e (e (e (e (e j. j. 2p N 0 j. 2p N 2 j. 2p N 4 j. 2p N 6 j. 2p N 8 ) ) ) ) ) 2p N 2( N-1) ) (e (e (e (e (e (e j. j. 2p N 0 j. 2p N 3 j. 2p N 6 j. 2p N 9 j. ) ) ) ) 2p N 12 (e (e (e (e ) (e 2p N 3( N -1) j. ) (e j. 2p N 0 j. 2p N j. 2p N 8 ) ) 4 ) j. 2p N 12 j. 2p N 16 ) 2p N ) ) 4( N -1) … … … … … … j. (e (e (e (e (e j. 2p N 0 ) 2p N ) N -1 j. 2p N 2( N-1) j. 2p N 3( N -1) j. 2p N ) ) (e j. )4( N-1) 2p N ... ) ù ú ú é ú ê ú ê ú ê ú ê ú ê ú .ê ú ê ú ê ú ê ú ê ú ê ú êë ú ú û ù X k(0) ú X k(1) ú ú (2) ú Xk ú (3) Xk ú ú X k(4) ú ú ú ( N -1) ú Xk úû = (N ) * IDFT -matrix ..and so can be realized by means of an N-point `Inverse Discrete Fourier Transform’ (IDFT) !!! DSP-CIS / Chapter-3: Acoustic Modem Project / Version 2012-2013 p. 19 OFDM Modulation 5/14 (0) X • PS: Note that k modulates a DC signal (hence often set to zero) • PS: To ensure time-domain signal is real-valued, have to choose * ( N-2) (2) * X(kN-1) = (X(1) ) , X = (X ) , ... k k k • PS: The IDFT matrix is a cool matrix: – For any chosen dimension N, an IDFT matrix can be constructed as given on the previous slide. – Its inverse is the DFT matrix (symbol `F’). DFT and IDFT matrices are unitary (up to a scalar), i.e. F = (IDFT - matrix)-1 = N.(IDFT - matrix)H – The structure of the IDFT matrix allows for a cheap (complexity N.logN instead of N.N) algorithm to compute the matrix-vector product on the previous slide (=IFFT =inverse fast Fourier transform) DSP-CIS / Chapter-3: Acoustic Modem Project / Version 2012-2013 p. 20 OFDM Modulation 6/14 So this will be the basic modulation operation at the Tx : Example: ‘16-QAM’ – The X’s are (QAM-symbols) defined by the input bit stream Imag(X) Real(X) – The time-domain signal segments xk , xk+1, xk+2,..., xk+N-1 are obtained by IDFT/IFFT and then transmitted over the channel, one after the other. At the Rx, demodulation is done with an inverse operation (i.e. DFT/FFT=fast Fourier transform). DSP-CIS / Chapter-3: Acoustic Modem Project / Version 2012-2013 p. 21 OFDM Modulation 7/14 Sounds simple, but forgot one thing: channel H(z) !! OFDM has an ingenious way of dealing with the channel effect, namely through the insertion of a so-called `cyclic prefix’ at the Tx : If the channel is FIR with order L (see p.10), then per segment, instead of transmitting N samples, N+L sampes are transmitted (assuming L<<N), where the last L samples are copied and put up front… L x k N L ,..., x k N 1 N xk , xk+1, xk+2, xk+3,..., xk+N-L ,..., xk+N-1 DSP-CIS / Chapter-3: Acoustic Modem Project / Version 2012-2013 p. 22 OFDM Modulation 8/14 At the Rx, throw away L samples corresponding to cyclic prefix, keep the other N samples, which correspond to é yk ê ê yk+1 ê ê yk+2 ê yk+3 ê ê yk+4 ê ê êë yk+N -1 ù é ú ê ú ê ú ê ú ê ú=ê ú ê ú ê ú ê ú ê úû êë hL hL-1 … h1 h0 0 0 0 … 0 0 hL … h2 h1 h0 0 0 … 0 0 0 … h3 h2 h1 h0 0 … 0 0 0 … h4 h3 h2 h1 h0 … 0 0 0 … h5 h4 h3 h2 h1 … 0 0 0 … 0 0 0 0 0 … h0 é x k+N -L ê ù ê xk+N -L+1 úê úê ú ê xk+N -1 úê xk ú. ê úê xk+1 úê xk+2 úê úê xk+3 úû ê ê ê x k+N -1 ë ù ú ú ú ú ú ú ú ú ú ú ú ú ú ú û N+L N prefix This is equivalent to … DSP-CIS / Chapter-3: Acoustic Modem Project / Version 2012-2013 p. 23 OFDM Modulation N é yk ê ê yk+1 ê ê yk+2 ê yk+3 ê ê yk+4 ê ê y ê ë k+N -1 ù ú ú ú ú ú= ú ú ú ú ú û é ê ê ê ê ê ê ê ê ê ê ë 0 ù ú 0 ú ú 0 úé 0 | I LxL 0 ú. ê I NxN úê 0 úë ú ú h0 ú û hL hL-1 … h1 h0 0 0 0 … 0 hL … h2 h1 h0 0 0 … 0 0 … h3 h2 h1 h0 0 … 0 0 … h4 h3 h2 h1 h0 … 0 0 … h5 h4 h3 h2 h1 … 0 0 … 0 0 0 0 0 … h0 0 0 0 0 … h3 h2 h1 h0 0 0 0 … h4 h3 h2 h1 h0 0 0 … h3 h2 h1 h0 0 … h4 h3 h2 h1 h0 … 0 0 0 0 0 … é ê ê ê ê ê ê ê ê ê ê ë h4 h2 h1 9/14 ù ú ú û é xk ê ê xk+1 ê ê xk+2 . ê xk+3 ê ê xk+4 ê ê x ê ë k+N -1 h1 ù ú h2 ú ú h3 ú h4 ú ú ú ú ú h0 ú û ù ú ú ú ú ú ú ú ú ú ú û N (*) The matrix (call it `H’) is now an NxN `circulant matrix’ =every row is the previous row up to a ‘cyclic shift’ DSP-CIS / Chapter-3: Acoustic Modem Project / Version 2012-2013 p. 24 OFDM Modulation 10/14 • PS: Cyclic prefix converts a (linear) convolution (see p.23) into a so-called ‘circular convolution’ (see p.24) • Circulant matrices are cool matrices… A weird property (proof by Matlab!) is that when a circulant matrix H is pre-/post-multiplied by the DFT/IDFT matrix, a diagonal matrix is always obtained: FH.F-1 = [diagonal matrix] Hence, a circulant matrix can always be written as (=eigenvalue decomposition!) é H 0 … 0 0 ê 0 H1 … 0 -1 ê H = F .ê ê 0 … H N -1 êë 0 DSP-CIS / Chapter-3: Acoustic Modem Project / Version 2012-2013 ù ú ú ú.F ú úû p. 25 OFDM Modulation 11/14 Combine previous formulas, to obtain… é yk ê yk+1 ê ê yk+2 ê ê yk+3 ê yk+4 ê ê ê yk+N -1 ê ë é yk ê yk+1 ê ê yk+2 ê F. ê yk+3 ê yk+4 ê ê ê yk+N -1 ê ë ù ú ú é H ú 0 ê ú ú = F -1. ê 0 ê ú ê ú ê ë 0 ú ú ú û ù ú ú é H ú 0 ê ú ê 0 ú= ê ú ê ú ê ë 0 ú ú ú û 0 … 0 H1 … 0 0 … H N -1 0 … 0 H1 … 0 0 … H N -1 DSP-CIS / Chapter-3: Acoustic Modem Project / Version 2012-2013 é xk ê xk+1 ê ù ê ú xk+2 ê ú ê xk+3 ú.F. ê ú xk+4 ê ú û ê ê xk+N -1 ê ë é xk ê xk+1 ê ù ê ú xk+2 ê ú ê xk+3 ú.F. ê ú xk+4 ê ú û ê ê xk+N -1 ê ë ù ú ú ú ú ú ú ú ú ú ú û ù ú ú ú ú ú ú ú ú ú ú û p. 26 OFDM Modulation 12/14 In other words… é (0 ) Y k ê ê Y (1) k ê ê Y (2 ) k ê ê Yk(3) ê ( 4) ê Yk ê ê ê Yk( N -1) êë ù é ú yk ê ú ê yk+1 ú ê ú yk+2 úD ê ú = F. ê yk+3 ê ú ê yk+4 ú ê ú ê ú êë yk+N -1 ú úû ù é H 0 ú ê ú ê 0 ú ê ú ê 0 ú=ê 0 ú ê ú ê 0 ú ê ú ê úû êë 0 0 0 0 0 0 H1 0 0 0 0 0 H2 0 0 0 0 0 H3 0 0 0 0 0 H4 0 0 0 0 0 H N -1 é (0 ) ù ê Xk ú ê X (1) k úê ú ê X (2 ) k úê ú. ê X (3) k úê ú ê X k( 4) úê úê úû ê X ( N -1) k êë ù ú ú ú ú ú ú ú ú ú ú ú úû This means that after removing the prefix part and performing a DFT in the Rx, the obtained samples Y are equal to the transmitted symbols X, up to (scalar) channel attenuations Hn (!!) Y (n) k DSP-CIS / Chapter-3: Acoustic Modem Project / Version 2012-2013 = Hn. X (n) k p. 27 OFDM Modulation 13/14 • PS: It can be shown (check first column of F.H = [diagonal matrix].F ) that Hn is the channel frequency response evaluated at the n-th carrier ! é H 0 ê ê H1 ê ê H2 ê H3 ê ê ê H N -1 ë é h 0 ù ê ú ê h1 ú ê ú ê ú = F. (1st column of H) = F. ê hL ú ê ú ê 0 ú ê ú ê 0 û ë ù ú ú ú ú ú ú ú ú ú û Þ H n = H (z) z=e j 2 p n/ N (p.27 then represents ‘frequency domain version’ of circular convolution, i.e. ‘component-wise multiplication in the frequency domain’) `Channel equalization’ may then be performed after the DFT (=in by component-wise division (divide by Hn for carriern). This is referred to as `1-tap FEQ’ (Frequency-domain EQualization) the frequency domain), (n) (n) (n) -1 (n ) YDSP-CIS = H . X Þ estimate{X } = (H ) .Y / Chapter-3: n Acoustic n p. k 28 k k Modem Project / Version 2012-2013 k OFDM Modulation 14/14 • Conclusion: DMT-modulation with cyclic prefix leads to a simple (trivial) channel equalization problem (!!) CP insertion CP removal 0 IFFT P / S Discrete equivalent channel DSP-CIS / Chapter-3: Acoustic Modem Project / Version 2012-2013 S / P FFT FEQ p. 29 Target Design efficient OFDM based modem (Tx/Rx) for transmission over acoustic channel Tx D-to-A A-to-D Rx Specifications: Data rate (e.g. 1kbits/sec), bit error rate (e.g. 0.5%), channel tracking speed, synchronisation, … DSP-CIS / Chapter-3: Acoustic Modem Project / Version 2012-2013 p. 30