From: drowe67 Date: Fri, 20 Apr 2012 01:48:54 +0000 (+0000) Subject: typos and minor tweaks X-Git-Url: http://git.whiteaudio.com/gitweb/?a=commitdiff_plain;h=0c7de118acc259df25199386eacd07fcc44f9af7;p=freetel-svn-tracking.git typos and minor tweaks git-svn-id: https://svn.code.sf.net/p/freetel/code@372 01035d8c-6547-0410-b346-abe4f91aad63 --- diff --git a/codec2-dev/octave/fdmdv.m b/codec2-dev/octave/fdmdv.m index c295d7db..afa5d186 100644 --- a/codec2-dev/octave/fdmdv.m +++ b/codec2-dev/octave/fdmdv.m @@ -251,8 +251,11 @@ function foff = rx_est_freq_offset(rx_fdm, pilot, pilot_prev, nin) global pilot_lpf1; global pilot_lpf2; - % down convert latest M samples of pilot by multiplying by - % ideal BPSK pilot signal we have generated locally + % down convert latest nin samples of pilot by multiplying by + % ideal BPSK pilot signal we have generated locally. This + % peak of the resulting signal is sensitive to the time shift between + % the received and local version of the pilot, so we do it twice at + % different time shifts and choose the maximum. pilot_baseband1(1:Npilotbaseband-nin) = pilot_baseband1(nin+1:Npilotbaseband); pilot_baseband2(1:Npilotbaseband-nin) = pilot_baseband2(nin+1:Npilotbaseband); @@ -535,7 +538,7 @@ endfunction % Generate a 4M sample vector of DBPSK pilot signal. As the pilot signal % is periodic in 4M samples we can then use this vector as a look up table -% for pilot signsl generation at the demod. +% for pilot signal generation in the demod. function pilot_lut = generate_pilot_lut() global Nc; @@ -550,7 +553,7 @@ function pilot_lut = generate_pilot_lut() pilot_freq = freq(Nc+1); pilot_phase = 1; pilot_filter_mem = zeros(1, Nfilter); - prev_pilot = zeros(M,1); + %prev_pilot = zeros(M,1); pilot_lut = []; @@ -558,7 +561,7 @@ function pilot_lut = generate_pilot_lut() for f=1:F [pilot pilot_rx_bit pilot_symbol pilot_filter_mem pilot_phase] = generate_pilot_fdm(pilot_rx_bit, pilot_symbol, pilot_filter_mem, pilot_phase, pilot_freq); - prev_pilot = pilot; + %prev_pilot = pilot; pilot_lut = [pilot_lut pilot]; end @@ -742,6 +745,23 @@ function rn_file(filename) endfunction +% Saves 200Hz LPF filter coeffs to a text file in the form of a C array + +function pilot_coeff_file(filename) + global pilot_coeff; + global Nfilter; + + f=fopen(filename,"wt"); + fprintf(f,"/* Generated by pilot_coeff_file() Octave function */\n\n"); + fprintf(f,"const float pilot_coeff[]={\n"); + for m=1:Npilotcoeff-1 + fprintf(f," %g,\n", pilot_coeff(m)); + endfor + fprintf(f," %g\n};\n", pilot_coeff(Npilotcoeff)); + fclose(f); +endfunction + + % Initialise ---------------------------------------------------- global pilot_bit; @@ -757,11 +777,11 @@ rx_filter_memory = zeros(Nc+1, Nfilter); global freq; freq = zeros(Nc+1,1); for c=1:Nc/2 - carrier_freq = (-Nc/2 - 1 + c)*Fsep + Fcentre + carrier_freq = (-Nc/2 - 1 + c)*Fsep + Fcentre; freq(c) = exp(j*2*pi*carrier_freq/Fs); end for c=Nc/2+1:Nc - carrier_freq = (-Nc/2 + c)*Fsep + Fcentre + carrier_freq = (-Nc/2 + c)*Fsep + Fcentre; freq(c) = exp(j*2*pi*carrier_freq/Fs); end diff --git a/codec2-dev/octave/tfdmdv.m b/codec2-dev/octave/tfdmdv.m index 2d63d147..ad606d2a 100644 --- a/codec2-dev/octave/tfdmdv.m +++ b/codec2-dev/octave/tfdmdv.m @@ -1,6 +1,8 @@ % tfdmdv.m % -% Octave script that evaluates the output of tfdmdv.c Unit Test program for FDMDV modem. +% Octave script that tests the C port of the FDMDV modem. This script loads +% the output of unittest/tfdmdv.c and compares it to the output of the +% reference versions of the same functions written in Octave. % % Copyright David Rowe 2012 % This program is distributed under the terms of the GNU General Public License @@ -84,6 +86,21 @@ plot(imag(tx_fdm_log - tx_fdm_log_c),'g'); hold off; title('tx fdm imag') +figure(4) +clf +subplot(211) +plot(real(pilot_lut_c)); +hold on; +plot(real(pilot_lut - pilot_lut_c),'g'); +hold off; +title('pilot lut real') +subplot(212) +plot(imag(pilot_lut_c)); +hold on; +plot(imag(pilot_lut - pilot_lut_c),'g'); +hold off; +title('pilot lut imag') + if sum(tx_bits_log - tx_bits_log_c) == 0 printf("fdmdv_get_test_bits..: OK\n"); passes++; @@ -108,4 +125,20 @@ else; fails++; end +if sum(tx_fdm_log - tx_fdm_log_c) < 1E-3 + printf("tx_fdm...............: OK\n"); + passes++; +else; + printf("tx_fdm...............: FAIL\n"); + fails++; +end + +if sum(pilot_lut - pilot_lut_c) < 1E-3 + printf("pilot_lut............: OK\n"); + passes++; +else; + printf("pilot_lut............: FAIL\n"); + fails++; +end + printf("\npasses: %d fails: %d\n", passes, fails);