From: drowe67 Date: Wed, 3 May 2017 03:55:16 +0000 (+0000) Subject: aquisition working with freq offsets up to +/-20Hz. A bit slow, but gd enough for... X-Git-Url: http://git.whiteaudio.com/gitweb/?a=commitdiff_plain;h=4e6de41d896a8cef59bd59832e546fa1c0164eaf;p=freetel-svn-tracking.git aquisition working with freq offsets up to +/-20Hz. A bit slow, but gd enough for initial OTA tests. Will speed up later. git-svn-id: https://svn.code.sf.net/p/freetel/code@3119 01035d8c-6547-0410-b346-abe4f91aad63 --- diff --git a/codec2-dev/octave/ofdm_lib.m b/codec2-dev/octave/ofdm_lib.m index 3cdfa3c8..ebc3f289 100644 --- a/codec2-dev/octave/ofdm_lib.m +++ b/codec2-dev/octave/ofdm_lib.m @@ -1,10 +1,14 @@ % ofdm_lib.m % David Rowe Mar 2017 -% -% Library of functions that implement a BPSK/QPSK OFDM modem. Rate Fs -% verison of ofdm_rs.m with OFDM based up and down conversion, and all -% those nasty real-world details like fine freq, timing. +#{ + Library of functions that implement a BPSK/QPSK OFDM modem. Rate Fs + verison of ofdm_rs.m with OFDM based up and down conversion, and all + those nasty real-world details like fine freq, timing. + + +#} + 1; @@ -36,6 +40,22 @@ endfunction % Also determines frequency offset at maximimum correlation. Can be % used for acquisition (coarse timing a freq offset), and fine timing +#{ + TODO: + [ ] attempt to speed up sync + + tis rather stateless, this current demod, which is nice + [ ] 0.5Hz grid and measure BER + + so run demod a bunch of times at different offsets + + Hmm cld also try +/- 20Hz multiples as it's aliased? + + might to use + + need metric for sync, could be callback. + [ ] or refine freq offset using pilots + [ ] different error measure that 10% maybe soft dec + + 10% very high BER + [ ] simpler CPU/DFT for freq offset estimation + + more suitable for real time implementation +#} + function [t_est foff_est] = coarse_sync(states, rx, rate_fs_pilot_samples) Nsamperframe = states.Nsamperframe; Fs = states.Fs; Npsam = length(rate_fs_pilot_samples); diff --git a/codec2-dev/octave/ofdm_rx.m b/codec2-dev/octave/ofdm_rx.m index e9c9b3d7..dd275ff0 100644 --- a/codec2-dev/octave/ofdm_rx.m +++ b/codec2-dev/octave/ofdm_rx.m @@ -65,7 +65,7 @@ function ofdm_rx(filename) next_state = state; if strcmp(state,'searching') - if Nerrs/Nbitsperframe < 0.1 + if Nerrs/Nbitsperframe < 0.15 next_state = 'synced'; end end @@ -88,7 +88,7 @@ function ofdm_rx(filename) % reset modem states states.sample_point = states.timing_est = 1; - states.foff_est_hz = 0; + states.foff_est_hz = foff_est; else @@ -130,7 +130,8 @@ function ofdm_rx(filename) figure(4); clf; plot(foff_est_hz_log) - axis([1 max(Nframes,2) -3 3]); + mx = max(abs(foff_est_hz_log)); + axis([1 max(Nframes,2) -mx mx]); title('Fine Freq'); figure(5); clf; diff --git a/codec2-dev/octave/ofdm_tx.m b/codec2-dev/octave/ofdm_tx.m index 903c7c8d..7fd6acb5 100644 --- a/codec2-dev/octave/ofdm_tx.m +++ b/codec2-dev/octave/ofdm_tx.m @@ -4,6 +4,14 @@ % File based ofdm tx. Generate a file of ofdm samples, inclduing % optional channel simulation. +#{ + TODO: + [ ] Optional LDPC code + [ ] measure and report raw and coded BER + [ ] maybe 10s worth of frames, sync up to any one automatically + + or start with maybe 10 frames + + measure BER match on each one +#} function ofdm_tx(filename, Nsec, EbNodB=100, channel='awgn', freq_offset_Hz=0) ofdm_lib; @@ -38,7 +46,7 @@ function ofdm_tx(filename, Nsec, EbNodB=100, channel='awgn', freq_offset_Hz=0) % mumble not understood very well mumble magic number. SNRdB = EbNodB + 10*log10(bps*Rs*Nc/Fs) + 3; - printf("EbNo: %3.1f SNR(3k): %3.1f foff: %3.1f\n", EbNodB, SNRdB, freq_offset_Hz); + printf("EbNo: %3.1f dB SNR(3k): %3.1f dB foff: %3.1fHz\n", EbNodB, SNRdB, freq_offset_Hz); % set up HF model --------------------------------------------------------------- @@ -75,12 +83,13 @@ function ofdm_tx(filename, Nsec, EbNodB=100, channel='awgn', freq_offset_Hz=0) rx = rx .* exp(j*woffset*(1:Nsam)); - % note variance/2 as we are using real() operator + % note variance/2 as we are using real() operator, mumble, + % reflection of -ve freq to +ve, mumble, hand wave - noise = sqrt(variance/2)*(0.5*randn(1,Nsam) + j*0.5*randn(1,Nsam)); - rx += noise; - 10*log10(var(tx)/var(noise)) + noise = sqrt(variance/2)*0.5*randn(1,Nsam); + rx = real(rx) + noise; + printf("measured SNR: %3.2f dB\n", 10*log10(var(real(tx))/var(noise))); Ascale = 4E5; - frx=fopen(filename,"wb"); fwrite(frx, Ascale*real(rx), "short"); fclose(frx); + frx=fopen(filename,"wb"); fwrite(frx, Ascale*rx, "short"); fclose(frx); endfunction