Matlab exercises 2015 ELEC-E5410 Signal processing for communications
Matlab exercises Matlab exercises in ELEC-E5410 Signal Processing for Communications min 50% of exercises required to be returned See deadlines of the exercises in MyCourses
Possible issues Ensure you observe the Mikes signal. If the received signal is just noise, the performance is difficult/ impossible to assess Do not compensate carrier frequency offset when receiving the Mikes signal until otherwise specified The offset (sinusoidal) signal is used to test the algorithms Show the output of the algorithm when the input is Mikes i.e. don t just design filters but filter as well Return the.pdf made by Matlab s publish() Not.html or some other awkward format 3
4 Matlab exercise 1 setup
Exercise 1 1. Make Matlab and RTL-SDR work - Get a dongle and install Matlab RTL-SDR toolbox on your computer. Requires Aalto e-mail address and Mathworks user account - Or get a dongle and go to F402. Three computers in the front row have RTL-SDR toolbox in the hidden folder C: \ProgramData\MATLAB\SupportPackages\R2015a - Or tune to 130.233.150.19:1234 using tcpip() function in Matlab 2. Run frequency offset calibration example in RTL-SDR toolbox and tune it to 25 MHz carrier frequency Check you see a signal close to 25 MHz 3. Find out minimum and maximum sampling rates the driver can support and the estimated carrier frequency offset (CFO) - Frequency offset stabilizes once warmed up - In comparison, LTE specification allows max. 0.1 ppm CFO. Dongles may go up to 100 ppm 4. Report max/min sampling rates and CFO and location where you made the measurements (no GPS accuracy required) in MyCourses page
Signal source in the TCP port Antenna is located by the window in G413 Server command: rtl_tcp f 25000000 a 130.233.150.19 s 250000 This signal can be used if you don t get your dongle working, are not able to receive Mikes signal etc. For Matlab code to read the signal, see the message board in MyCourses 6
Known issues in installation Admin rights needed to install driver On Windows, installation of the toolbox changes the rights of Matlab to admin and the path to toolbox is hidden from regular users Always use the same USB port on Windows Mac requires Xcode, which takes 7GB of disk space 7
8 Matlab exercise 2.1 AGC
AGC with RTL-SDR 1. Turn off AGC in comm.sdrrtlreceiver object and use a fixed gain 2. Implement linear AGC for the received signal You may compare the performance to that of comm.agc() Cover the antenna by hand and check that the algorithm works Plot the received signal multiplied by the output of your AGC 3. Experiment with step size. When is the algorithm stable and when unstable given the step size 4. Return your Matlab code (.m) and a pdf made by Matlab s publish function that shows the operation of the algorithm
Example of AGC Input signal is 25 MHz Mikes without compensation of carrier frequency offset 1.5 I out Q out I in Q in 1 0.5 amplitude 0-0.5-1 -1.5-2 500 1000 1500 2000 2500 time 10
11 Matlab exercise 2.2 sigma-delta
Sigma-delta quantization with RTL 1. Take the real (or imaginary) part of the received signal 2. Implement sigma-delta quantization and low-pass filter For low-pass filter design, see firpmord() and firpm() 3. Compare the input and output 4. Return your Matlab code (.m) and a pdf made by Matlab s publish function
Example of sigma-delta quantization sigma-delta quantization of sinusoid sigma-delta quantization of sinusoid 1 input '-" output 1 input '-" output 0.5 0.5 Amplitude 0 Amplitude 0-0.5-0.5-1 -1 1850 1900 1950 2000 2050 2100 Time 1940 1950 1960 1970 1980 1990 2000 2010 Time No oversampling/downsampling (M=1) Output depends on the cut-off of the low-pass filter 13
Matlab exercise 3 14
Decimating using interpolated FIR filter Downsample the Mikes signal and listen to it with dsp.audioplayer(). You should hear the time signal beeping but the signal is very noisy Design an interpolated FIR (IFIR) filter using firpmord() and firpm() Filter the Mikes signal with filter() or with dsp.firfilter object and downsample using your IFIR design dsp.firfilter object preserves filter stage between different function calls while this has to be done explicitly when using filter() Input signal to dsp.firfilter must be a column vector Design a one-stage decimator filter and use it to decimate the Mikes signal Compare the number of required multiplications in direct and IFIR implementations Return your Matlab code (.m) and the output of publish()
IFIR design example Image suppression filter with don t care bands Cascade of the periodic filter and image suppression filter 16
Direct design One-stage filter Image suppression filter without don t care bands 17
Matlab exercise 4 18
Fractional delay by Lagrange filtering Decimate the Mikes signal until you to get a reasonable sampling grid Delay the in-phase (I) or quadrature (Q) branch so that I and Q signal align Use combination of integer-valued delay and a fractional delay, where the latter is implemented by (time-invariant) Lagrange filter Design the Lagrange filter yourself, don t use any Matlab function Explain the result by checking the impulse, magnitude, phase, and group delay response of the Lagrange filter Return your Matlab code (.m) and the output of publish()
Fractional delay by Lagrange filtering Before After
Fractional delay by Lagrange filtering 21
Matlab exercise 5 22
Fractional delay by up-sampling and filtering The problem setting is the same as in Exercise 4, but now the I or Q signal is aligned by 1) up-sampling the signal by factor of L, 2) lowpass filtering the up-sampled signal by H(z) and 3) down-sampling the filtered signal with 1 < offset < L, which corresponds to the fractional delay This is the same as reading the output from one of the polyphase components of H(z) Tips Gain of the up-sampling filter in pass-band is L Compensate first the group delay caused by H(z) in the filtered signal and add then the integer value delay (which you know from Exercise 4) multiplied by L Return your Matlab code (.m) and the output of publish()
Matlab exercise 6 24
Carrier frequency estimation 1. Low-pass filter the received Mikes signal 2. Implement FFT+max. peak, Kay s, Fitz s and Luise s and Regiannini s algorithms Which one is the best, can you notice any differences in performance? 3. Compensate the carrier frequency offset (CFO) of the received signal in Matlab by the CFO estimate by one of the algorithms. Display the compensated signal in time and frequency domains 4. Compare the performance of a) signal compensation in Matlab as above to b) specifying CFO in comm.sdrrtlreceiver. Are there any differences? 5. Return your Matlab code (.m) and the output of publish()
Example of Kay s algorithm Uniform weighting simply calculates the mean of the angles Kay s weighting is more stable w.r.t. the number of samples than the uniform weighting Sign of CFO is inverted, because the estimator used z(k)z*(k+1) instead of z(k)z*(k-1) CFO 2394 2393.5 2393 2392.5 2392 2391.5 2391 2390.5 2390 Kay's weights Uniform weights 2389.5 2000 3000 4000 5000 6000 7000 8000 #samples 26
Example of Fitz and L&R -2380-2380 -2382-2382 -2384-2384 CFO -2386 CFO -2386-2388 -2388-2390 -2390-2392 0 5 10 15 20 25 30 35 40 45 #lags Fitz -2392 0 10 20 30 40 50 60 70 80 90 #lags Luise&Regiannini 27
Example of CFO compensation The video shows low-pass filtered signal without CFO compensation and CFO compensated signal CFO compensation is (arbitrarily) chosen as Fitz with 3 lags 28
Example of CFO compensation Low-pass filtered and compensated signal Original signal 29
Matlab exercise 7 30
Phase offset estimation 1. Use the signal you obtained in Exercise 6, step 3 as the input signal 2. Implement a) The feedforward phase estimator for some window length b) First-order phase-locked loop (PLL) when S-curve is approximated as S(.) A(.) where A is some fixed gain. Select the parameters such that the loop filter is low-pass. c) Second-order PLL, S-curve approximated as above 3. Implement 2.c) as IIR filter and use filter() to calculate phase offset. You should get the same result in both ways 4. Compensate the phase offset using 2.a)-c) and display the compensated signal in time domain. Which algorithm is the best, can you notice any differences in performance? 5. Return your Matlab code and the output of publish()
Example of the signal after CFO compensation Some frequency offset still remains, because the compensated signal shows a trend 32
Signal after compensation of CFO and phase offset 33
Matlab exercise 8 34
Timing estimation Use a similar signal as in Exercise 4 and 5 as input signal Take the I or Q branch of the sinusoidal-looking signal Use early-late detector to generate the error signal a) Adjust sampling time such that you sample at the peak of the sinusoid. This is synchronous sampling in the slides b) Use Lagrange filter you designed in Exercise 4 to interpolate the value of the sinusoid based on the error signal. This is nonsynchronous sampling in the slides Depict the result in time domain Return your Matlab code (.m) and the output of publish()
Example of timing estimation Step size too small Step size better 36
Example of timing estimation In both cases (synch./nonsynch.) early-late detector 0.4 0.3 may lock to minimum (180 0.2 deg phase offset) with these kind of input signals 0.1 0-0.1 1140 1160 1180 1200 1220 1240 1260 1280 Non-synchronous sampling 37
38 Matlab exercise 9 Grande Finale
Decoding of Mikes signal Record Mikes signal Process the signal to facilitate estimation Estimate symbol timing by correlator Decode the bits in at least one 1-minute message, extract the current time and compare it to datetime( now ) Return your Matlab code (.m) and the output of publish() 39
Signal format Format of the time signal according to Wikipedia In Mikes signal, bit 0 is 0.1slong 1KHz sinusoid, and bit 1 is 0.2s-long 1KHz sinusoid in the beginning of 1s-long symbol DCF77 time code Weight Weight Weight Bit Meaning Bit Meaning Bit Meaning PM AM PM AM PM AM :00 1 M Start of minute. Always 0. :20 S :01 1 :21 1 Start of encoded time. Always 1. :03 1 :23 4 :43 2 Minutes :04 1 Civil warning bits, [18] :24 8 :44 4 provided 00 59 :05 1 by the :25 10 :45 1 :06 :07 1 1 Bundesamt für Bevölkerungsschutz und Katastrophenwarnung :26 :27 20 40 :46 :47 2 4 :08 1 (Federal Office Even parity over :28 P1 of Civil protection and Disaster minute bits 21 28. :48 8 :09 1 Relief). :29 1 :49 10 Also contains weather :10 0 broadcasts. [17][19] :30 2 :50 1 :11 0 :31 4 Hours :51 2 :12 0 :32 8 0 23 :52 4 :40 10 Day of month :41 20 (continued) :02 1 :22 2 :42 1 Day of :13 0 :33 10 :53 8 :14 0 :34 20 :54 10 :15 R :16 A1 :17 Z1 :18 Z2 :19 A2 Call bit: abnormal transmitter operation. [17] Previously: backup antenna in use. Summer time announcement. Set during hour before change. Set to 1 when CEST is in effect. Set to 1 when CET is in effect. Leap second announcement. Set during hour before leap second. :35 P2 :36 1 Even parity over hour bits 29 35. :55 20 :56 40 :37 2 :57 80 Day of month. 01 31 :38 4 :58 P3 :39 8 :59 0 week Monday=1, Sunday=7 Month number 01 12 Year within century 00 99 Even parity over date bits 36 58. Minute mark: no amplitude modulation. 40
Example of signal detection 0.035 Absolute value of the output of the correlator when the 0.03 1200s of the Mikes signal 0.025 are divided into 0.1s slots 0.02 0.015 0.01 0.005 0 0 200 400 600 800 1000 1200 41
42 Matlab exercise + Additional exercise for those who fell below 50% threshold in the clicker exam
More carrier frequency estimation 1. Low-pass filter the received Mikes signal 2. Implement one of the algorithms: Xiao, Kim, Leung, Brown Names refer to the first author of the paper, and the papers are in the Materials section in MyCourses 3. Compensate the carrier frequency offset (CFO) of the received signal in Matlab by the CFO estimate of the selected algorithm. Display the compensated signal in time and frequency domains 4. Compare the performance of the algorithm to one of the algorithms: FFT+max. peak, Kay s, Fitz s, or Luise s and Regiannini s. Make sure you get similar results 5. Return your Matlab code (.m) and the output of publish()