From 68951558d4048cb1843f75896692a10c1303d70b Mon Sep 17 00:00:00 2001 From: Steven Franke Date: Sun, 25 Sep 2016 00:16:29 +0000 Subject: [PATCH] MSK144: 1. Clean up mskrtd to remove unused variables. 2. Re-instate Rx frequency spinbox in MSK144 mode to allow decoding of off-frequency signals with small FTol. Make changes needed to pass Rx Freq in to fortran routines. 3. Enable realtime decoder for testing. Auto sequence does not yet work when realtime decoding is enabled. There are probably other bugs as well. git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx@7109 ab8295b8-cf94-4d9e-aec4-7959e3be5d79 --- Configuration.ui | 2 +- lib/hspec.f90 | 4 ++-- lib/msk144d2.f90 | 10 +++++--- lib/mskrtd.f90 | 59 ++++++++++++++---------------------------------- mainwindow.cpp | 8 ++++--- mainwindow.h | 1 + 6 files changed, 33 insertions(+), 51 deletions(-) diff --git a/Configuration.ui b/Configuration.ui index d9c801554..5d4bd8213 100644 --- a/Configuration.ui +++ b/Configuration.ui @@ -2280,7 +2280,7 @@ Right click for insert and delete options. - false + true <html><head/><body><p>Decode on-the-fly rather than at end of Rx sequence.</p></body></html> diff --git a/lib/hspec.f90 b/lib/hspec.f90 index 5020147b5..b70a24460 100644 --- a/lib/hspec.f90 +++ b/lib/hspec.f90 @@ -1,4 +1,4 @@ -subroutine hspec(id2,k,nutc0,ntrperiod,ntol,bmsk144,ingain,green,s,jh,line1) +subroutine hspec(id2,k,nutc0,ntrperiod,nrxfreq,ntol,bmsk144,ingain,green,s,jh,line1) ! Input: ! k pointer to the most recent new data @@ -68,7 +68,7 @@ subroutine hspec(id2,k,nutc0,ntrperiod,ntol,bmsk144,ingain,green,s,jh,line1) if(bmsk144) then if(k.ge.7168) then tsec=(k-7168)/12000.0 - call mskrtd(id2(k-7168+1:k),nutc0,tsec,ntol,line1) + call mskrtd(id2(k-7168+1:k),nutc0,tsec,ntol,nrxfreq,line1) endif endif !### diff --git a/lib/msk144d2.f90 b/lib/msk144d2.f90 index 24640c485..8b6507bda 100644 --- a/lib/msk144d2.f90 +++ b/lib/msk144d2.f90 @@ -18,9 +18,10 @@ program msk144d2 character*12 mycall,hiscall character(len=500) optarg - type (option) :: long_options(6) = [ & + type (option) :: long_options(7) = [ & option ('dxcall',.true.,'d','hiscall',''), & option ('evemode',.true.,'e','',''), & + option ('frequency',.true.,'f','rxfreq',''), & option ('help',.false.,'h','Display this help message',''), & option ('mycall',.true.,'m','mycall',''), & option ('nftol',.true.,'n','nftol',''), & @@ -28,12 +29,13 @@ program msk144d2 ] t0=0.0 ntol=100 + nrxfreq=1500 mycall='' hiscall='' bShMsgs=.false. do - call getopt('d:ehm:n:s',long_options,c,optarg,narglen,nstat,noffset,nremain,.true.) + call getopt('d:ef:hm:n:s',long_options,c,optarg,narglen,nstat,noffset,nremain,.true.) if( nstat .ne. 0 ) then exit end if @@ -42,6 +44,8 @@ program msk144d2 read (optarg(:narglen), *) hiscall case ('e') t0=1e-4 + case ('f') + read (optarg(:narglen), *) nrxfreq case ('h') display_help = .true. case ('m') @@ -85,7 +89,7 @@ program msk144d2 do i=1,npts,7*512 ichunk=id2(i:i+7*1024-1) tsec=(i-1)/12000.0 - call mskrtd(ichunk,nutc,tsec,ntol,line) + call mskrtd(ichunk,nutc,tsec,ntol,nrxfreq,line) if( index(line,"^") .ne. 0 .or. index(line,"&") .ne. 0 ) then write(*,*) line endif diff --git a/lib/mskrtd.f90 b/lib/mskrtd.f90 index f5911ee54..123fe834a 100644 --- a/lib/mskrtd.f90 +++ b/lib/mskrtd.f90 @@ -1,4 +1,4 @@ -subroutine mskrtd(id2,nutc0,tsec,ntol,line) +subroutine mskrtd(id2,nutc0,tsec,ntol,nrxfreq,line) ! Real-time decoder for MSK144. ! Analysis block size = NZ = 7168 samples, t_block = 0.597333 s @@ -7,8 +7,6 @@ subroutine mskrtd(id2,nutc0,tsec,ntol,line) parameter (NZ=7168) !Block size parameter (NSPM=864) !Number of samples per message frame parameter (NFFT1=8192) !FFT size for making analytic signal - parameter (NAVGMAX=7) !Coherently average up to 7 frames - parameter (NPTSMAX=7*NSPM) !Max points analyzed at once parameter (NPATTERNS=4) !Number of frame averaging patterns to try character*3 decsym !"&" for mskspd or "^" for long averages @@ -19,24 +17,18 @@ subroutine mskrtd(id2,nutc0,tsec,ntol,line) complex cdat(NFFT1) !Analytic signal complex c(NSPM) !Coherently averaged complex data complex ct(NSPM) - complex cb(42) !Complex waveform for sync word -! integer*8 count0,count1,count2,count3,clkfreq integer*2 id2(NZ) !Raw 16-bit data integer iavmask(8) integer iavpatterns(8,NPATTERNS) - integer s8(8) integer npkloc(10) integer nav(6) - real cbi(42),cbq(42) real d(NFFT1) - real pp(12) !Half-sine pulse shape - real pow(7) + real pow(8) real xmc(NPATTERNS) logical first data first/.true./ - data s8/0,1,1,1,0,0,1,0/ data nav/1,2,3,5,7,9/ data iavpatterns/ & 1,1,1,1,0,0,0,0, & @@ -45,40 +37,17 @@ subroutine mskrtd(id2,nutc0,tsec,ntol,line) 1,1,1,1,1,1,1,0/ data xmc/2.0,4.5,2.5,3.5/ !Used to label decode with time at center of averaging mask - save first,cb,fs,pi,twopi,dt,s8,pp,t03,t12,nutc00,pnoise,nsnrlast,msglast + save first,t03,t12,nutc00,pnoise,nsnrlast,msglast -! call system_clock(count0,clkfreq) if(first) then - pi=4.0*atan(1.0) - twopi=8.0*atan(1.0) - fs=12000.0 - dt=1.0/fs - - do i=1,12 !Define half-sine pulse - angle=(i-1)*pi/12.0 - pp(i)=sin(angle) - enddo - -! Define the sync word waveforms - s8=2*s8-1 - cbq(1:6)=pp(7:12)*s8(1) - cbq(7:18)=pp*s8(3) - cbq(19:30)=pp*s8(5) - cbq(31:42)=pp*s8(7) - cbi(1:12)=pp*s8(2) - cbi(13:24)=pp*s8(4) - cbi(25:36)=pp*s8(6) - cbi(37:42)=pp(1:6)*s8(8) - cb=cmplx(cbi,cbq) - - first=.false. t03=0.0 t12=0.0 nutc00=nutc0 pnoise=-1.0 + first=.false. endif - fc=1500.0 !!! This will eventually come from the Rx Freq GUI box. + fc=nrxfreq !!! Dupe checking should probaby be moved to mainwindow.cpp if( nutc00 .ne. nutc0 ) then ! reset dupe checker @@ -100,8 +69,11 @@ subroutine mskrtd(id2,nutc0,tsec,ntol,line) d(NZ+1:NFFT1)=0. call analytic(d,NZ,NFFT1,cdat) !Convert to analytic signal and filter +! Calculate average power for each frame and for the entire block. +! If decode is successful, largest power will be taken as signal+noise. +! If no decode, entire-block average will be used to update noise estimate. pmax=-99 - do i=1,7 + do i=1,8 ib=(i-1)*NSPM+1 ie=ib+NSPM-1 pow(i)=dot_product(cdat(ib:ie),cdat(ib:ie))*rms**2 @@ -109,18 +81,21 @@ subroutine mskrtd(id2,nutc0,tsec,ntol,line) pmax=pow(i) endif enddo - pavg=sum(pow)/7.0 - + pavg=sum(pow)/8.0 + +! Short ping decoder uses squared-signal spectrum to determine where to +! center a 3-frame analysis window and attempts to decode each of the +! 3 frames along with 2- and 3-frame averages. np=8*NSPM - call msk144spd(cdat,np,ntol,nsuccess,msgreceived,fc,fest,tdec) - if( nsuccess .eq. 1 ) then tdec=tsec+tdec decsym=' & ' goto 999 endif - + +! If short ping decoder doesn't find a decode, then 4-, 5-, and 7-frame averages +! spanning the first 7 frames of the block. do iavg=1,NPATTERNS iavmask=iavpatterns(1:8,iavg) navg=sum(iavmask) diff --git a/mainwindow.cpp b/mainwindow.cpp index 445b77083..b9742697a 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -67,7 +67,7 @@ extern "C" { void symspec_(struct dec_data *, int* k, int* ntrperiod, int* nsps, int* ingain, int* minw, float* px, float s[], float* df3, int* nhsym, int* npts8); - void hspec_(short int d2[], int* k, int* nutc0, int* ntrperiod, int* ntol, + void hspec_(short int d2[], int* k, int* nutc0, int* ntrperiod, int* nrxfreq, int* ntol, bool* bmsk144, int* ingain, float green[], float s[], int* jh, char line[], int len1); @@ -1273,7 +1273,9 @@ void MainWindow::fastSink(qint64 frames) bool bmsk144=((m_mode=="MSK144") and (m_monitoring or m_diskData)); bmsk144=bmsk144 && m_config.realTimeDecode(); line[0]=0; - hspec_(dec_data.d2,&k,&nutc0,&m_TRperiod, &m_Ftol, &bmsk144,&m_inGain,fast_green, +//### Is this OK? + m_RxFreq=ui->RxFreqSpinBox->value (); + hspec_(dec_data.d2,&k,&nutc0,&m_TRperiod,&m_RxFreq,&m_Ftol,&bmsk144,&m_inGain,fast_green, fast_s,&fast_jh, &line[0],80); float px = fast_green[fast_jh]; QString t; @@ -4324,7 +4326,7 @@ void MainWindow::switch_mode (Mode mode) ui->rptSpinBox->setMaximum(49); ui->sbFtol->setMinimum(21); ui->sbFtol->setMaximum(27); - ui->RxFreqSpinBox->setVisible(m_mode!="MSK144"); +// ui->RxFreqSpinBox->setVisible(m_mode!="MSK144"); } void MainWindow::WSPR_config(bool b) diff --git a/mainwindow.h b/mainwindow.h index 7dc076402..2440a25c0 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -367,6 +367,7 @@ private: qint32 m_TRindex; qint32 m_FtolIndex; qint32 m_Ftol; + qint32 m_RxFreq; qint32 m_TRperiodFast; qint32 m_nTx73; qint32 m_freqCQ;