From f8a673077b8f2a2c2d0eb4fa603644f7c6fcb13c Mon Sep 17 00:00:00 2001 From: Steven Franke Date: Wed, 31 May 2017 14:08:54 +0000 Subject: [PATCH] Change wspr5d frequency dither to a search over a list of the top npeak peaks in squared-signal spectrum. git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx@7699 ab8295b8-cf94-4d9e-aec4-7959e3be5d79 --- lib/fsk4hf/getfc1w.f90 | 2 -- lib/fsk4hf/getfc2w.f90 | 33 ++++++++++++++++++++++++++++++--- lib/fsk4hf/ldpcsim300.f90 | 2 +- lib/fsk4hf/wspr5d.f90 | 26 ++++++++++++-------------- lib/fsk4hf/wspr5d_exp.f90 | 15 ++++++++++----- 5 files changed, 53 insertions(+), 25 deletions(-) diff --git a/lib/fsk4hf/getfc1w.f90 b/lib/fsk4hf/getfc1w.f90 index 878422fec..532b9837d 100644 --- a/lib/fsk4hf/getfc1w.f90 +++ b/lib/fsk4hf/getfc1w.f90 @@ -1,11 +1,9 @@ subroutine getfc1w(c,fs,fa,fb,fc1,xsnr) include 'wsprlf_params.f90' - complex c(0:NZ-1) !Complex waveform complex c2(0:NFFT1-1) !Short spectra real s(-NH1+1:NH1) !Coarse spectrum - nspec=NZ/NFFT1 df1=fs/NFFT1 s=0. diff --git a/lib/fsk4hf/getfc2w.f90 b/lib/fsk4hf/getfc2w.f90 index af404c8ed..fb7a199bb 100644 --- a/lib/fsk4hf/getfc2w.f90 +++ b/lib/fsk4hf/getfc2w.f90 @@ -1,4 +1,4 @@ -subroutine getfc2w(c,csync,fs,fc1,fc2,fc3) +subroutine getfc2w(c,csync,npeaks,fs,fc1,fpks) include 'wsprlf_params.f90' @@ -6,6 +6,8 @@ subroutine getfc2w(c,csync,fs,fc1,fc2,fc3) complex cs(0:NZ-1) !For computing spectrum complex csync(0:NZ-1) !Sync symbols only, from cbb real a(5) + real freqs(413),sp2(413),fpks(npeaks) + integer pkloc(1) df=fs/NZ baud=fs/NSPS @@ -15,18 +17,28 @@ subroutine getfc2w(c,csync,fs,fc1,fc2,fc3) ! Filter, square, then FFT to get refined carrier frequency fc2. call four2a(cs,NZ,1,-1,1) !To freq domain + ia=nint(0.75*baud/df) cs(ia:NZ-1-ia)=0. !Save only freqs around fc1 +! do i=1,NZ/2 +! filt=1/(1+((i*df)**2/(0.50*baud)**2)**8) +! cs(i)=cs(i)*filt +! cs(NZ+1-i)=cs(NZ+1-i)*filt +! enddo call four2a(cs,NZ,1,1,1) !Back to time domain cs=cs/NZ +!do i=0,NZ-1 +!write(51,*) i,real(cs(i)),imag(cs(i)) +!enddo cs=cs*cs !Square the data call four2a(cs,NZ,1,-1,1) !Compute squared spectrum ! Find two peaks separated by baud pmax=0. fc2=0. - ic=nint(baud/df) - ja=nint(0.5*baud/df) + ja=nint(0.3*baud/df) +! ja=nint(0.5*baud/df) + k=1 do j=-ja,ja f2=j*df ia=nint((f2-0.5*baud)/df) @@ -38,10 +50,25 @@ subroutine getfc2w(c,csync,fs,fc1,fc2,fc3) pmax=p fc2=0.5*f2 endif + freqs(k)=0.5*f2 + sp2(k)=p + k=k+1 ! write(52,1200) f2,p,db(p) !1200 format(f10.3,2f15.3) enddo + do i=1,npeaks + pkloc=maxloc(sp2) + ipk=pkloc(1) + fpks(i)=freqs(ipk) + ipk0=max(1,ipk-1) + ipk1=min(413,ipk+1) +! ipk0=ipk +! ipk1=ipk + sp2(ipk0:ipk1)=0.0 +!write(*,*) i,fpks(i),fc2 + enddo + a(1)=-fc1 a(2:5)=0. call twkfreq1(c,NZ,fs,a,cs) !Mix down by fc1 diff --git a/lib/fsk4hf/ldpcsim300.f90 b/lib/fsk4hf/ldpcsim300.f90 index a4b5beaa4..d8a177592 100644 --- a/lib/fsk4hf/ldpcsim300.f90 +++ b/lib/fsk4hf/ldpcsim300.f90 @@ -170,7 +170,7 @@ do idb = 20,-16,-1 ! max_iterations is max number of belief propagation iterations call bpdecode300(llr, apmask, max_iterations, decoded, niterations, cw) if( niterations .lt. 0 ) then - norder=4 + norder=3 call osd300(llr, norder, decoded, niterations, cw) endif n2err=0 diff --git a/lib/fsk4hf/wspr5d.f90 b/lib/fsk4hf/wspr5d.f90 index 7eb776487..3d18dd629 100644 --- a/lib/fsk4hf/wspr5d.f90 +++ b/lib/fsk4hf/wspr5d.f90 @@ -30,6 +30,7 @@ program wspr5d real pp(2*NSPS) !Shaped pulse for OQPSK real a(5) !For twkfreq1 real aa(20),bb(20) !Fitted polyco's + real fpks(20) integer id(NS+ND) !NRZ values (+/-1) for Sync and Data integer ierror(NS+ND) integer isync(48) !Long sync vector @@ -124,10 +125,10 @@ program wspr5d fa=102.0 fb=150.0 call getfc1w(c,fs,fa,fb,fc1,xsnr) !First approx for freq - call getfc2w(c,csync,fs,fc1,fc2,fc3) !Refined freq +npeaks=20 + call getfc2w(c,csync,npeaks,fs,fc1,fpks) !Refined freq -!NB: Measured performance is about equally good using fc2 or fc3 here: - a(1)=-(fc1+fc2) + a(1)=-fc1 a(2:5)=0. call twkfreq1(c,NZ,fs,a,c) !Mix c down by fc1+fc2 @@ -157,23 +158,19 @@ program wspr5d endif enddo xdt=jpk/fs +xdt=1.0 +jpk=fs*xdt do i=0,NZ-1 j=i+jpk if(j.ge.0 .and. j.lt.NZ) c1(i)=c(j) enddo -! print*,fc1,fc1+fc2,xdt,amax -!----------------------------------------------------------------- nterms=maxn -! c1=c -! do itry=1,1000 - do itry=1,20 - idf=itry/2 - if(mod(itry,2).eq.0) idf=-idf + do itry=1,npeaks nhard0=0 nhardsync0=0 ifer=1 - a(1)=idf*0.00085 + a(1)=-fpks(itry) a(2:5)=0. call twkfreq1(c1,NZ,fs,a,c) !Mix c1 into c call cpolyfitw(c,pp,id,maxn,aa,bb,zz,nhs) @@ -204,12 +201,13 @@ program wspr5d idat(7)=ishft(idat(7),6) call wqdecode(idat,message,itype) nsnr=nint(xsnr) - freq=fMHz + 1.d-6*(fc1+fc2) +! freq=fMHz + 1.d-6*(fc1+fc2) + freq=fMHz + 1.d-6*(fc1+fpks(itry)) nfdot=0 write(13,1110) datetime,0,nsnr,xdt,freq,message,nfdot 1110 format(a11,2i4,f6.2,f12.7,2x,a22,i3) - write(*,1112) datetime(8:11),nsnr,xdt,freq,nfdot,message -1112 format(a4,i4,f5.1,f11.6,i3,2x,a22) + write(*,1112) datetime(8:11),nsnr,xdt,freq,nfdot,message,itry +1112 format(a4,i4,f5.1,f11.6,i3,2x,a22,i4) endif enddo ! ifile loop write(*,1120) diff --git a/lib/fsk4hf/wspr5d_exp.f90 b/lib/fsk4hf/wspr5d_exp.f90 index b92ae8a57..781ee17ec 100644 --- a/lib/fsk4hf/wspr5d_exp.f90 +++ b/lib/fsk4hf/wspr5d_exp.f90 @@ -19,6 +19,7 @@ program wspr5d real rxdata(ND),llr(ND) !Soft symbols real pp(32) !Shaped pulse for OQPSK real ps(0:7),sbits(412) + real fpks(20) integer id(NS+ND) !NRZ values (+/-1) for Sync and Data integer isync(48) !Long sync vector integer ib13(13) !Barker 13 code @@ -114,12 +115,15 @@ program wspr5d fa=100.0 fb=170.0 call getfc1w(c,fs,fa,fb,fc1,xsnr) !First approx for freq - call getfc2w(c,csync,fs,fc1,fc2,fc3) !Refined freq +! call getfc2w(c,csync,fs,fc1,fc2,fc3) !Refined freq + npeaks=5 + call getfc2w(c,csync,npeaks,fs,fc1,fpks) !Refined freq !write(*,*) fc1+fc2 - call downsample(c,fc1+fc2,cd) +do ipks=1,npeaks + call downsample(c,fc1+fpks(ipks),cd) - do ncoh=1,0,-1 + do ncoh=1,1,-1 do is=0,9 idt=is/2 if( mod(is,2).eq. 1 ) idt=-is/2 @@ -178,12 +182,13 @@ program wspr5d nfdot=0 write(13,1210) datetime,0,nsnr,xdt,freq,message,nfdot 1210 format(a11,2i4,f6.2,f12.7,2x,a22,i3) - write(*,1212) datetime(8:11),nsnr,xdt,freq,nfdot,message,'*' -1212 format(a4,i4,f5.1,f11.6,i3,2x,a22,a1) + write(*,1212) datetime(8:11),nsnr,xdt,freq,nfdot,message,'*',ipks +1212 format(a4,i4,f5.1,f11.6,i3,2x,a22,a1,i4) goto 888 endif enddo enddo +enddo ! fpeaks loop 888 enddo write(*,1120)