% load real samples from file
- Ascale= 2E5*1.1491/2.0;
- frx=fopen(filename,"rb"); rx = fread(frx, Inf, "short")/Ascale; fclose(frx);
+ Ascale= states.amp_scale/2.0; % /2 as real signal has half amplitude
+ frx=fopen(filename,"rb"); rx = 0.1*fread(frx, Inf, "short")/Ascale; fclose(frx);
Nsam = length(rx); Nframes = floor(Nsam/Nsamperframe);
prx = 1;
% OK generate tx frame for BER calcs
% We just use a single test frame of bits as it makes interleaver sync
- % easier than using a test fram eof bits that spans the entire interleaver
+ % easier than using a test frame of bits that spans the entire interleaver
% frame. Doesn't affect operation with the speech codec operation.
rand('seed', 1);
states.tx_uw = [1 0 0 1 0 1 0 0 1 0];
assert(length(states.tx_uw) == states.Nuwbits);
+ % use this to scale tx output to 16 bit short. Adjusted by experiment
+ % to have same RMS power as FDMDV waveform
+
+ states.amp_scale = 2E5*1.1491/1.06;
+
% generate same pilots each time
rand('seed',1);
% load real samples from file
- Ascale= 2E5*1.1491/2;
+ Ascale = states.amp_scale/2; % as input is a real valued signal
frx=fopen(filename,"rb"); rx = fread(frx, Inf, "short")/Ascale; fclose(frx);
Nsam = length(rx); Nframes = floor(Nsam/Nsamperframe);
prx = 1;
rx_bits = []; rx_np_log = []; timing_est_log = []; delta_t_log = []; foff_est_hz_log = [];
phase_est_pilot_log = [];
- Terrs = Tbits = Terrs_coded = Tbits_coded = Tpackets = Tpacketerrs = 0;
+ Terrs = Tbits = Terrs_coded = Tbits_coded = Tpackets = Tpacketerrs = frame_count = 0;
Nbitspervocframe = 28;
Nerrs_coded_log = Nerrs_log = [];
error_positions = [];
end
prx += states.nin;
- if strcmp(states.sync_state,'searching')
+ if strcmp(states.sync_state,'search')
[timing_valid states] = ofdm_sync_search(states, rxbuf_in);
end
- if strcmp(states.sync_state,'synced') || strcmp(states.sync_state,'trial_sync')
+ if strcmp(states.sync_state,'synced') || strcmp(states.sync_state,'trial')
[rx_bits states aphase_est_pilot_log arx_np arx_amp] = ofdm_demod(states, rxbuf_in);
rx_uw = rx_bits(1:states.Nuwbits);
end
end
- printf("\nBER..: %5.4f Tbits: %5d Terrs: %5d\n", Terrs/Tbits, Tbits, Terrs);
+ printf("\nBER..: %5.4f Tbits: %5d Terrs: %5d\n", Terrs/(Tbits+1E-12), Tbits, Terrs);
% If we have enough frames, calc BER discarding first few frames where freq
% offset is adjusting
title('Errors/modem frame')
axis([1 length(Nerrs_log) 0 Nbitsperframe*rate/2]);
- if nargin == 3
+ if nargin == 2
fep = fopen(error_pattern_filename, "wb");
fwrite(fep, error_positions, "short");
fclose(fep);