[sim_out rx states] = run_sim(sim_in);
- states.verbose = 2;
+ states.verbose = 0;
% set up acquistion
- Nsamperframe = states.Nsamperframe;
+ Nsamperframe = states.Nsamperframe; M = states.M; Ncp = states.Ncp;
rate_fs_pilot_samples = states.rate_fs_pilot_samples;
% test fine or acquisition over test signal
delta_ct = []; delta_foff = [];
+ % a fine simulation is a bit like what ofsd_demod() does, just searches a few samples
+ % either side of current coarse est
+
if fine_en
window_width = 5; % search +/-2 samples from current timing instant
delta_t = [delta_ft ft_est - ceil(window_width/2)];
end
else
- % for coarse simulation we just use contant window shifts
+ % for coarse simulation we just use constant window shifts
st = 0.5*Nsamperframe;
- en = 2.5*Nsamperframe - 1;
- ct_target = Nsamperframe/2;
+ en = 2.5*Nsamperframe - 1; % note this gives Nsamperframe possibilities for coarse timing
+ ct_target = Nsamperframe/2; % actual known position of correct coarse timing
for w=1:Nsamperframe:length(rx)-4*Nsamperframe
- %st = w+0.5*Nsamperframe; en = st+2*Nsamperframe-1;
- %[ct_est foff_est] = coarse_sync(states, rx(st:en), rate_fs_pilot_samples);
+ %for w=1:M+Ncp:length(rx)-4*Nsamperframe
[ct_est foff_est] = coarse_sync(states, rx(w+st:w+en), rate_fs_pilot_samples);
if states.verbose
printf("w: %d ct_est: %4d foff_est: %3.1f\n", w, ct_est, foff_est);
init_cml('/home/david/Desktop/cml/');
-%run_single
+run_single
%run_curves
%run_curves_estimators
%acquisition_histograms(0, 0)
-acquisition_test(10, 4, 5)
+%acquisition_test(10, 4, 5)
% update timing estimate --------------------------------------------------
- delta_t = coarse_foff_est_hz = 0;
+ delta_t = coarse_foff_est_hz = timing_valid = timing_mx = 0;
if timing_en
% update timing at start of every frame
% load real samples from file
- Ascale= 2E5*1.1491;
- frx=fopen(filename,"rb"); rx = 2*fread(frx, Inf, "short")/4E5; fclose(frx);
+ Ascale= 2E5*1.1491/2;
+ frx=fopen(filename,"rb"); rx = fread(frx, Inf, "short")/Ascale; fclose(frx);
Nsam = length(rx); Nframes = floor(Nsam/Nsamperframe);
+ Nframes = 5;
prx = 1;
% OK re-generate tx frame for BER calcs
prx = 1;
nin = Nsamperframe+2*(M+Ncp);
- states.rxbuf(Nrxbuf-nin+1:Nrxbuf) = rx(prx:nin);
- prx += nin;
+ %states.rxbuf(Nrxbuf-nin+1:Nrxbuf) = rx(prx:nin);
+ %prx += nin;
state = 'searching'; frame_count = 0;
end
prx += states.nin;
+ printf(" states.nin: %d\n", states.nin);
[rx_bits states aphase_est_pilot_log arx_np arx_amp] = ofdm_demod(states, rxbuf_in);
errors = xor(tx_bits, rx_bits);
st = M+Ncp + Nsamperframe + 1; en = st + 2*Nsamperframe;
[ct_est foff_est] = coarse_sync(states, states.rxbuf(st:en), states.rate_fs_pilot_samples);
if states.verbose
- printf(" Nerrs: %d ct_est: %4d foff_est: %3.1f\n", Nerrs, ct_est, foff_est);
+ printf(" Nerrs: %d ct_est: %4d foff_est: %3.1f\n", Nerrs, ct_est, foff_est);
end
% calculate number of samples we need on next buffer to get into sync
states.nin = Nsamperframe + ct_est - 1;
-
+
% reset modem states
states.sample_point = states.timing_est = 1;
figure(1); clf;
plot(rx_np_log,'+');
- mx = max(abs(rx_np_log));
- %axis([-mx mx -mx mx]);
+ mx = 2*max(abs(rx_np_log));
+ axis([-mx mx -mx mx]);
title('Scatter');
figure(2); clf;