From d09f8c08924f011c44e85cedf7ab586c8de6ee86 Mon Sep 17 00:00:00 2001 From: Joe Taylor Date: Tue, 4 Sep 2012 20:11:26 +0000 Subject: [PATCH] More progress toward a working decoder for B2, C2 modes. git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/map65@2556 ab8295b8-cf94-4d9e-aec4-7959e3be5d79 --- libm65/afc65b.f | 12 ++++++------ libm65/ccf65.f90 | 8 ++++---- libm65/decode1a.f | 24 +++++++++++++++--------- libm65/fchisq.f | 17 +++++++++-------- libm65/filbig.f | 22 ++++++++++++++++------ libm65/ftnquit.f90 | 2 +- libm65/m65.f90 | 6 +++--- libm65/map65a.f90 | 14 ++++++++------ libm65/symspec.f90 | 2 +- mainwindow.cpp | 2 +- 10 files changed, 64 insertions(+), 45 deletions(-) diff --git a/libm65/afc65b.f b/libm65/afc65b.f index 7bf9c1d31..1b294a3cf 100644 --- a/libm65/afc65b.f +++ b/libm65/afc65b.f @@ -1,5 +1,5 @@ - subroutine afc65b(cx,cy,npts,fsample,nflip,ipol,xpol,ndphi,iloop, - + a,ccfbest,dtbest) + subroutine afc65b(cx,cy,npts,nfast,fsample,nflip,ipol,xpol, + + ndphi,iloop,a,ccfbest,dtbest) logical xpol complex cx(npts) @@ -26,11 +26,11 @@ chisqr0=1.e6 do iter=1,3 !One iteration is enough? do j=1,nterms - chisq1=fchisq(cx,cy,npts,fsample,nflip,a,ccfmax,dtmax) + chisq1=fchisq(cx,cy,npts,nfast,fsample,nflip,a,ccfmax,dtmax) fn=0. delta=deltaa(j) 10 a(j)=a(j)+delta - chisq2=fchisq(cx,cy,npts,fsample,nflip,a,ccfmax,dtmax) + chisq2=fchisq(cx,cy,npts,nfast,fsample,nflip,a,ccfmax,dtmax) if(chisq2.eq.chisq1) go to 10 if(chisq2.gt.chisq1) then delta=-delta !Reverse direction @@ -41,7 +41,7 @@ endif 20 fn=fn+1.0 a(j)=a(j)+delta - chisq3=fchisq(cx,cy,npts,fsample,nflip,a,ccfmax,dtmax) + chisq3=fchisq(cx,cy,npts,nfast,fsample,nflip,a,ccfmax,dtmax) if(chisq3.lt.chisq2) then chisq1=chisq2 chisq2=chisq3 @@ -53,7 +53,7 @@ C Find minimum of parabola defined by last three points a(j)=a(j)-delta deltaa(j)=deltaa(j)*fn/3. enddo - chisqr=fchisq(cx,cy,npts,fsample,nflip,a,ccfmax,dtmax) + chisqr=fchisq(cx,cy,npts,nfast,fsample,nflip,a,ccfmax,dtmax) if(chisqr/chisqr0.gt.0.9999) go to 30 chisqr0=chisqr enddo diff --git a/libm65/ccf65.f90 b/libm65/ccf65.f90 index 455b919c9..75a552f3c 100644 --- a/libm65/ccf65.f90 +++ b/libm65/ccf65.f90 @@ -1,5 +1,5 @@ -subroutine ccf65(ss,nhsym,ssmax,sync1,ipol1,jpz,dt1,flipk,syncshort, & - snr2,ipol2,dt2) +subroutine ccf65(ss,nhsym,nfast,ssmax,sync1,ipol1,jpz,dt1,flipk, & + syncshort,snr2,ipol2,dt2) parameter (NFFT=512,NH=NFFT/2) real ss(4,322) !Input: half-symbol powers, 4 pol'ns @@ -103,7 +103,7 @@ subroutine ccf65(ss,nhsym,ssmax,sync1,ipol1,jpz,dt1,flipk,syncshort, & enddo rms=sqrt(sq/49.0) sync1=ccfbest/rms - 4.0 - dt1=2.5 + lagpk*(2048.0/11025.0) + dt1=(2.5 + lagpk*(2048.0/11025.0))/nfast ! Find base level for normalizing snr2. do i=1,nhsym @@ -112,7 +112,7 @@ subroutine ccf65(ss,nhsym,ssmax,sync1,ipol1,jpz,dt1,flipk,syncshort, & call pctile(tmp1,tmp2,nhsym,40,base) snr2=0.398107*ccfbest2/base !### empirical syncshort=0.5*ccfbest2/rms - 4.0 !### better normalizer than rms? - dt2=2.5 + lagpk2*(2048.0/11025.0) + dt2=(2.5 + lagpk2*(2048.0/11025.0))/nfast return end subroutine ccf65 diff --git a/libm65/decode1a.f b/libm65/decode1a.f index 8f62e81d6..7e7e64a1e 100644 --- a/libm65/decode1a.f +++ b/libm65/decode1a.f @@ -1,4 +1,4 @@ - subroutine decode1a(dd,newdat,f0,nflip,mode65,nfsample,xpol, + subroutine decode1a(dd,newdat,f0,nflip,mode65,nfast,nfsample,xpol, + mycall,hiscall,hisgrid,neme,ndepth,nqd,dphi,ndphi,iloop, + nutc,nkhz,ndf,ipol,ntol,sync2,a,dt,pol,nkv,nhist,nsum,nsave, + qual,decoded) @@ -24,7 +24,7 @@ ! Mix sync tone to baseband, low-pass filter, downsample to 1378.125 Hz dt00=dt call timer('filbig ',0) - call filbig(dd,NMAX,f0,newdat,nfsample,xpol,cx,cy,n5) + call filbig(dd,NMAX,nfast,f0,newdat,nfsample,xpol,cx,cy,n5) ! NB: cx, cy have sample rate 96000*77125/5376000 = 1378.125 Hz call timer('filbig ',1) joff=0 @@ -32,17 +32,19 @@ sqb=0. do i=1,n5 sqa=sqa + real(cx(i))**2 + aimag(cx(i))**2 - sqb=sqb + real(cy(i))**2 + aimag(cy(i))**2 + if(xpol) sqb=sqb + real(cy(i))**2 + aimag(cy(i))**2 enddo sqa=sqa/n5 sqb=sqb/n5 ! Find best DF, f1, f2, DT, and pol. Start by downsampling to 344.53125 Hz - z=cmplx(cos(dphi),sin(dphi)) - cy(:n5)=z*cy(:n5) !Adjust for cable length difference + if(xpol) then + z=cmplx(cos(dphi),sin(dphi)) + cy(:n5)=z*cy(:n5) !Adjust for cable length difference + endif call timer('fil6521 ',0) call fil6521(cx,n5,c5x,n6) - call fil6521(cy,n5,c5y,n6) + if(xpol) call fil6521(cy,n5,c5y,n6) call timer('fil6521 ',1) ! Add some zeros at start of c5 arrays -- empirical fix for negative DT's @@ -53,8 +55,10 @@ c5tmp(1:nadd)=0. c5tmp(1+nadd:n6+nadd)=c5x(1:n6) c5x(1:n6+nadd)=c5tmp(1:n6+nadd) - c5tmp(1+nadd:n6+nadd)=c5y(1:n6) - c5y(1:n6+nadd)=c5tmp(1:n6+nadd) + if(xpol) then + c5tmp(1+nadd:n6+nadd)=c5y(1:n6) + c5y(1:n6+nadd)=c5tmp(1:n6+nadd) + endif n6=n6+nadd fsample=1378.125/4. @@ -71,7 +75,7 @@ ! factor of 1/8, say? Should be a significant execution speed-up. call timer('afc65b ',0) ! Best fit for DF, f1, f2, pol - call afc65b(c5x(i0),c5y(i0),nz,fsample,nflip,ipol,xpol, + call afc65b(c5x(i0),c5y(i0),nz,nfast,fsample,nflip,ipol,xpol, + ndphi,iloop,a,ccfbest,dtbest) call timer('afc65b ',1) @@ -81,6 +85,8 @@ sq0=aa*aa*sqa + bb*bb*sqb sync2=3.7*ccfbest/sq0 +! print*,n6,dt00,i0,nz,a(1),sync2 + ! Apply AFC corrections to the time-domain signal ! Now we are back to using the 1378.125 Hz sample rate, enough to ! accommodate the full JT65C bandwidth. diff --git a/libm65/fchisq.f b/libm65/fchisq.f index f4c17d79c..3bb56d3d8 100644 --- a/libm65/fchisq.f +++ b/libm65/fchisq.f @@ -1,4 +1,5 @@ - real function fchisq(cx,cy,npts,fsample,nflip,a,ccfmax,dtmax) + real function fchisq(cx,cy,npts,nfast,fsample,nflip,a, + + ccfmax,dtmax) parameter (NMAX=60*96000) !Samples per 60 s complex cx(npts),cy(npts) @@ -10,7 +11,13 @@ save call timer('fchisq ',0) - baud=11025.0/4096.0 + baud=nfast*11025.0/4096.0 + nsps=nint(fsample/baud) !Samples per symbol + nsph=nsps/2 !Samples per half-symbol + ndiv=16 !Output ss() steps per symbol + nout=ndiv*npts/nsps + dtstep=1.0/(ndiv*baud) !Time per output step + if(a(1).ne.a1 .or. a(2).ne.a2 .or. a(3).ne.a3) then a1=a(1) a2=a(2) @@ -42,12 +49,6 @@ C Compute 1/2-symbol powers at 1/16-symbol steps. pol=a(4)/57.2957795 aa=cos(pol) bb=sin(pol) - nsps=nint(fsample/baud) !Samples per symbol - nsph=nsps/2 !Samples per half-symbol - - ndiv=16 !Output ss() steps per symbol - nout=ndiv*npts/nsps - dtstep=1.0/(ndiv*baud) !Time per output step do i=1,nout j=i*nsps/ndiv diff --git a/libm65/filbig.f b/libm65/filbig.f index 60206ddce..12a240fc2 100644 --- a/libm65/filbig.f +++ b/libm65/filbig.f @@ -1,4 +1,5 @@ - subroutine filbig(dd,nmax,f0,newdat,nfsample,xpol,c4a,c4b,n4) + subroutine filbig(dd,nmax,nfast,f0,newdat,nfsample,xpol, + + c4a,c4b,n4) C Filter and downsample complex data stored in array dd(4,nmax). C Output is downsampled from 96000 Hz to 1375.125 Hz. @@ -20,11 +21,20 @@ C Output is downsampled from 96000 Hz to 1375.125 Hz. + 5.89886379,1.59355187,-2.49138308,0.60910773,-0.04248129/ save - nfft1=MAXFFT1 - nfft2=MAXFFT2 - if(nfsample.eq.95238) then - nfft1=5120000 - nfft2=74088 + if(nfast.eq.1) then + nfft1=MAXFFT1 + nfft2=MAXFFT2 + if(nfsample.eq.95238) then + nfft1=5120000 + nfft2=74088 + endif + else + nfft1=2621440 + nfft2=37632 + if(nfsample.eq.95238) then + nfft1=2560000 + nfft2=37044 + endif endif if(nmax.lt.0) go to 900 if(first) then diff --git a/libm65/ftnquit.f90 b/libm65/ftnquit.f90 index f209d1b4b..edab1bb2d 100644 --- a/libm65/ftnquit.f90 +++ b/libm65/ftnquit.f90 @@ -2,7 +2,7 @@ subroutine ftnquit ! Destroy the FFTW plans call four2a(a,-1,1,1,1) - call filbig(id,-1,f0,newdat,nfsample,c4a,c4b,n4) + call filbig(id,-1,1,f0,newdat,nfsample,c4a,c4b,n4) stop return diff --git a/libm65/m65.f90 b/libm65/m65.f90 index c8f508ee9..3cf6c95f7 100644 --- a/libm65/m65.f90 +++ b/libm65/m65.f90 @@ -106,9 +106,9 @@ program m65 gainy=1.0265 phasex=0.01426 phasey=-0.01195 - call symspec(k,nxpol,ndiskdat,nb,nbslider,idphi,nfsample,fgreen, & - iqadjust,iqapply,gainx,gainy,phasex,phasey,rejectx,rejecty, & - pxdb,pydb,ssz5a,nkhz,ihsym,nzap,slimit,lstrong) + call symspec(k,nfast,nxpol,ndiskdat,nb,nbslider,idphi,nfsample, & + fgreen,iqadjust,iqapply,gainx,gainy,phasex,phasey,rejectx, & + rejecty,pxdb,pydb,ssz5a,nkhz,ihsym,nzap,slimit,lstrong) call timer('symspec ',1) nhsym0=nhsym if(ihsym.ge.278) go to 10 diff --git a/libm65/map65a.f90 b/libm65/map65a.f90 index 7e54e0bb7..a5b1c981b 100644 --- a/libm65/map65a.f90 +++ b/libm65/map65a.f90 @@ -56,6 +56,7 @@ subroutine map65a(dd,ss,savg,newdat,nutc,fcenter,ntol,idphi,nfa,nfb, & 2 if(ndphi.eq.1) dphi=30*iloop/57.2957795 do nqd=1,0,-1 +! do nqd=1,1,-1 if(nqd.eq.1) then !Quick decode, at fQSO fa=1000.0*(fqso+0.001*mousedf) - ntol fb=1000.0*(fqso+0.001*mousedf) + ntol + 4*53.8330078 @@ -114,8 +115,8 @@ subroutine map65a(dd,ss,savg,newdat,nutc,fcenter,ntol,idphi,nfa,nfb, & call timer('ccf65 ',0) ! ssmax=4.0*(rmsdd/22.5)**2 ssmax=savg(jpmax,i) - call ccf65(ss(1,1,i),nhsym,ssmax,sync1,ipol,jpz,dt,flipk, & - syncshort,snr2,ipol2,dt2) + call ccf65(ss(1,1,i),nhsym,nfast,ssmax,sync1,ipol,jpz,dt, & + flipk,syncshort,snr2,ipol2,dt2) call timer('ccf65 ',1) ! ########################### Search for Shorthand Messages ################# @@ -204,10 +205,11 @@ subroutine map65a(dd,ss,savg,newdat,nutc,fcenter,ntol,idphi,nfa,nfb, & ifreq=i ikHz=nint(freq+0.5*(nfa+nfb)-foffset)-nfshift idf=nint(1000.0*(freq+0.5*(nfa+nfb)-foffset-(ikHz+nfshift))) - call decode1a(dd,newdat,f00,nflip,mode65,nfsample,xpol, & - mycall,hiscall,hisgrid,neme,ndepth,nqd,dphi,ndphi, & - iloop,nutc,ikHz,idf,ipol,ntol,sync2,a,dt,pol,nkv, & - nhist,nsum,nsave,qual,decoded) +! print*,ikhz,idf,dt,sync1,dt + call decode1a(dd,newdat,f00,nflip,mode65,nfast,nfsample, & + xpol,mycall,hiscall,hisgrid,neme,ndepth,nqd,dphi, & + ndphi,iloop,nutc,ikHz,idf,ipol,ntol,sync2,a,dt, & + pol,nkv,nhist,nsum,nsave,qual,decoded) dt=dt+0.8 !### empirical tweak call timer('decode1a',1) diff --git a/libm65/symspec.f90 b/libm65/symspec.f90 index 8bd26be87..e35ab15db 100644 --- a/libm65/symspec.f90 +++ b/libm65/symspec.f90 @@ -1,4 +1,4 @@ -subroutine symspec(k,nfast, nxpol,ndiskdat,nb,nbslider,idphi,nfsample, & +subroutine symspec(k,nfast,nxpol,ndiskdat,nb,nbslider,idphi,nfsample, & fgreen,iqadjust,iqapply,gainx,gainy,phasex,phasey,rejectx,rejecty, & pxdb,pydb,ssz5a,nkhz,ihsym,nzap,slimit,lstrong) diff --git a/mainwindow.cpp b/mainwindow.cpp index acc8b985a..37d58b018 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -1,4 +1,4 @@ -//-------------------------------------------------------------- MainWindow +//--------------------------------------------------------------- MainWindow #include "mainwindow.h" #include "ui_mainwindow.h" #include "devsetup.h"