From: drowe67 Date: Sat, 27 Aug 2016 06:14:56 +0000 (+0000) Subject: removed commented out globals X-Git-Url: http://git.whiteaudio.com/gitweb/?a=commitdiff_plain;h=f1e36af3e367d662291c0f5936b22d3b19c2e5ae;p=freetel-svn-tracking.git removed commented out globals git-svn-id: https://svn.code.sf.net/p/freetel/code@2846 01035d8c-6547-0410-b346-abe4f91aad63 --- diff --git a/codec2-dev/octave/fdmdv.m b/codec2-dev/octave/fdmdv.m index a3fcbbdd..a7965b33 100644 --- a/codec2-dev/octave/fdmdv.m +++ b/codec2-dev/octave/fdmdv.m @@ -8,9 +8,9 @@ % Version 2 % % TODO: -% [ ] refactor with states -% [ ] remove commented out globals -% [ ] tfdmdv works +% [X] refactor with states +% [X] remove commented out globals +% [X] tfdmdv works % [ ] fdmdv_ut works % reqd to make sure we get same random bits at mod and demod @@ -18,108 +18,6 @@ rand('state',1); randn('state',1); -#{ - -% Constants - - -global Fs = 8000; % sample rate in Hz -global T = 1/Fs; % sample period in seconds -global Rs; - Rs = 50; % symbol rate in Hz -global Nc; % number of carriers -if exist("NumCarriers") == 0 - Nc = 14; -else - Nc = NumCarriers; -end -global Nb; - Nb = 2; % Bits/symbol for PSK modulation -global Rb; - Rb = Nc*Rs*Nb; % bit rate -global M = Fs/Rs; % oversampling factor -global Nsym = 6; % number of symbols to filter over -global Fsep; - Fsep = 75; % Separation between carriers (Hz) -global Fcentre = 1500; % Centre frequency, Nc/2 carriers below this, N/c carriers above (Hz) -global Nt = 5; % number of symbols we estimate timing over -global P = 4; % oversample factor used for rx symbol filtering -global Nfilter = Nsym*M; -global Nfiltertiming = M+Nfilter+M; -alpha = 0.5; -global snr_coeff; - snr_coeff = 0.9;% SNR est averaging filter coeff -global Nph; - Nph = 9; % number of symbols to estimate phase over - % must be odd number as we take centre symbol -global Nsync_mem = 6 -global sync_uw = [1 -1 1 -1 1 -1]; - -% root raised cosine (Root Nyquist) filter - -global gt_alpha5_root; -gt_alpha5_root = gen_rn_coeffs(alpha, T, Rs, Nsym, M); - -% rx decimation filter - -global Nrxdec; - Nrxdec=31; -global rxdec_coeff; - rxdec_coeff = fir1(Nrxdec-1, 0.25); - -if 0 - % tmp code to plot freq resp. 20dB attn of any aliases should be fine - % not real sensitive to in-band attn, e.g. outer tones a dB down should be OK - % in terms of BER - figure(1) - [h,f]=freqz(rxdec,1,4000); - hdB=20*log10(abs(h)); - plot(hdB(1:1200)) - grid -end - -% Converts gray code to natural binary - -global m4_gray_to_binary = [ - bin2dec("00") - bin2dec("01") - bin2dec("11") - bin2dec("10") - ]; -global m8_gray_to_binary = [ - bin2dec("000") - bin2dec("001") - bin2dec("011") - bin2dec("010") - bin2dec("111") - bin2dec("110") - bin2dec("100") - bin2dec("101") - ]; - -% Convert natural binary to gray code - -global m4_binary_to_gray = [ - bin2dec("00") - bin2dec("01") - bin2dec("11") - bin2dec("10") - ]; - -global m8_binary_to_gray = [ - bin2dec("000") - bin2dec("001") - bin2dec("011") - bin2dec("010") - bin2dec("110") - bin2dec("111") - bin2dec("101") - bin2dec("100") - ]; - -% temp logging stuff -#} - % Functions ---------------------------------------------------- @@ -1264,124 +1162,3 @@ function dump_bits(rx_bits) endfunction -if 0 -% Initialise ---------------------------------------------------- - -global pilot_bit; -pilot_bit = 0; % current value of pilot bit - -global tx_filter_memory; -tx_filter_memory = zeros(Nc+1, Nfilter); -global rx_filter_memory; -rx_filter_memory = zeros(Nc+1, Nfilter); - -global rx_fdm_mem; - rx_fdm_mem = zeros(1,Nfilter+M); - -% phasors used for up and down converters - -global freq; - freq = zeros(Nc+1,1); -global freq_pol; - freq_pol = zeros(Nc+1,1); -for c=1:Nc/2 - %carrier_freq = (-Nc/2 - 1 + c)*Fsep + Fcentre; - carrier_freq = (-Nc/2 - 1 + c)*Fsep; - freq_pol(c) = 2*pi*carrier_freq/Fs; - freq(c) = exp(j*freq_pol(c)); -end -for c=floor(Nc/2)+1:Nc - %carrier_freq = (-Nc/2 + c)*Fsep + Fcentre; - carrier_freq = (-Nc/2 + c)*Fsep; - freq_pol(c) = 2*pi*carrier_freq/Fs; - freq(c) = exp(j*freq_pol(c)); -end - -%freq_pol(Nc+1) = 2*pi*Fcentre/Fs; -freq_pol(Nc+1) = 2*pi*0/Fs; -freq(Nc+1) = exp(j*freq_pol(Nc+1)); - -global fbb_rect; - fbb_rect = exp(j*2*pi*Fcentre/Fs); -global fbb_phase_tx; - fbb_phase_tx = 1; -global fbb_phase_rx; - fbb_phase_rx = 1; -global rxdec_lpf_mem; - rxdec_lpf_mem = zeros(1,Nrxdec-1+M); -global Q=M/4; - -% Spread initial FDM carrier phase out as far as possible. This -% helped PAPR for a few dB. We don't need to adjust rx phase as DQPSK -% takes care of that. - -global phase_tx; -phase_tx = ones(Nc+1,1); -phase_tx = exp(j*2*pi*(0:Nc)/(Nc+1)); -%phase_tx = exp(j*2*pi*(0:Nc)/4); -%phase_tx(Nc+1) = -1; -global phase_rx; -phase_rx = ones(Nc+1,1); - -% Freq offset estimator constants - -global Mpilotfft = 256; - -global Npilotcoeff; % number of pilot LPF coeffs - Npilotcoeff = 30; -global pilot_coeff; - pilot_coeff = fir1(Npilotcoeff-1, 200/(Fs/2))';% 200Hz LPF -global Npilotbaseband = Npilotcoeff + M + M/P; % number of pilot baseband samples reqd for pilot LPF -global Npilotlpf; % number of symbols we DFT pilot over, pilot est window - Npilotlpf = 4*M; - -% pilot LUT, used for copy of pilot at rx - -global pilot_lut; -pilot_lut = generate_pilot_lut(); -global pilot_lut_index; - pilot_lut_index = 1; -global prev_pilot_lut_index; - prev_pilot_lut_index = 3*M+1; - -% Freq offset estimator states - -global pilot_baseband1; -global pilot_baseband2; -pilot_baseband1 = zeros(1, Npilotbaseband); % pilot baseband samples -pilot_baseband2 = zeros(1, Npilotbaseband); % pilot baseband samples -global pilot_lpf1 -global pilot_lpf2 -pilot_lpf1 = zeros(1, Npilotlpf); % LPF pilot samples -pilot_lpf2 = zeros(1, Npilotlpf); % LPF pilot samples - -% Timing estimator states - -global rx_filter_mem_timing; -rx_filter_mem_timing = zeros(Nc+1, Nt*P); -global rx_baseband_mem_timing; -rx_baseband_mem_timing = zeros(Nc+1, Nfiltertiming); - -% Test bit stream constants - -global Ntest_bits; - Ntest_bits = Nc*Nb*4; % length of test sequence -global test_bits; - test_bits = rand(1,Ntest_bits) > 0.5; - -% Test bit stream state variables - -global current_test_bit = 1; -current_test_bit = 1; -global rx_test_bits_mem; -rx_test_bits_mem = zeros(1,Ntest_bits); - -% Experimental phase estimator states ---------------------- - -global rx_symbols_mem; -rx_symbols_mem = zeros(Nc+1, Nph); -global prev_phase_offsets; -prev_phase_offsets = zeros(Nc+1, 1); -global phase_amb; -phase_amb = zeros(Nc+1, 1); -end