From 65fc129d883ced67d11cfb696cd94be6371b4930 Mon Sep 17 00:00:00 2001 From: Jens Ahrensfeld Date: Sun, 19 Apr 2015 20:06:40 +0000 Subject: [PATCH] - TX: process data at symbol rate - RX: removed kdown stuff (hardcode to 4), fixed redundant down sampling for base band processing git-svn-id: http://moon:8086/svn/matlab/trunk@37 801c6759-fa7c-4059-a304-17956f83a07c --- ofdm/ofdm_rx.m | 19 +++++++++---------- ofdm/ofdm_tx.m | 12 ++++++++---- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/ofdm/ofdm_rx.m b/ofdm/ofdm_rx.m index 0206746..cebea2a 100644 --- a/ofdm/ofdm_rx.m +++ b/ofdm/ofdm_rx.m @@ -5,25 +5,22 @@ function [x] = ofdm_rx(filename, foff, knoise_dB, with_cir) % ofdm_rx('xv.wav', 0, -400, 0) % or ofdm_rx('yv.wav', 0, -400, 0) +close all; + drm_mode = 'B'; drm_bw = '10k'; [ofdm_drm_params, ofdm_spec_occ] = drm_params(drm_mode, drm_bw); -close all; pre_mix = 0; -Kdown = 4; -fs = 48000/Kdown; -fc = fs/4; -N = 1024/Kdown; -Ng = 256/Kdown; +fs = 12000; +N = 256; +Ng = 64; [carrier_pilot, phi_pilot, mag_pilot] = getRefFreq(drm_mode); [carrier_time, phi_time, mag_time] = getRefTime(drm_mode); h_cir = [0 0 .1 -.2 .5 .2 -.1 0 0 ]; -close all; - % Generate signal [xwav fs_ nbits] = wavread(filename); @@ -37,10 +34,12 @@ elseif (ndim == 1) x = xwav.*exp(-j*(2*pi*(0.25-foff/fs_)*(0:len-1)')); hlp = FIRCalcLowpass(12000/fs_, 33); x = filter(hlp, 1, x); + + % Downsample + x = x(1:4:length(x)); else error('Cannot read file!'); end -x = x(1:Kdown:length(x)); if with_cir x = filter(h_cir, 1, x); @@ -53,7 +52,7 @@ wavwrite(xout,fs,nbits,'ofdm_rx.wav'); x = x + sqrt(0.5)*10^(knoise_dB/20)*(randn(size(x)) + j*randn(size(x))); -K = fix((length(x)-Ng)/(N+Ng)); +K = fix((length(x))/(N+Ng))-1; % Timing coarse cp_off_ = []; diff --git a/ofdm/ofdm_tx.m b/ofdm/ofdm_tx.m index cb838d0..45df8d4 100644 --- a/ofdm/ofdm_tx.m +++ b/ofdm/ofdm_tx.m @@ -15,8 +15,8 @@ M_QAM = 64; RCWIN_ROLLOFF = 0.125; % Params -fa = 48000; -T = 4/fa; +fa = 12000; +T = 1/fa; [ofdm_params, ofdm_spec_occ] = drm_params(mode, bandwidth); @@ -107,12 +107,16 @@ grid; plot(wng); grid; % Modulate on carrier -yc = exp(j*2*pi.*(0:length(xv)-1)*0.25) .* xv; +xup = upsample(xv, 4); +hlp = FIRCalcLowpass(0.25, 129); +xup = filter(hlp, 1, xup); + +yc = exp(j*2*pi.*(0:length(xup)-1)*0.25) .* xup; yv = real(yc) + imag(yc); xv = conj(xv')./abs(max(xv)); yv = yv'./max(yv); -wavwrite(0.9*yv,fa,16,'yv.wav') +wavwrite(0.9*yv,4*fa,16,'yv.wav') wavwrite(0.9*[real(xv) imag(xv)],fa,16,'xv.wav')