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);
% 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;
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 = [];
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
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;
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
% 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
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++;
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);