diff --git a/lib/q65_decode.f90 b/lib/q65_decode.f90 index 7ed685da5..e7f8c23a3 100644 --- a/lib/q65_decode.f90 +++ b/lib/q65_decode.f90 @@ -97,13 +97,12 @@ contains call timer('sync_q65',0) call q65_sync(nutc,iwave,ntrperiod,mode65,codewords,ncw,nsps, & nfqso,ntol,ndepth,lclearave,emedelay,xdt,f0,snr1,width,dat4, & - snr2,id1) + snr2,idec) call timer('sync_q65',1) - - if(id1.eq.1 .or. id1.ge.12) then + if(idec.ge.0) then xdt1=xdt !We have a list-decode result f1=f0 -! go to 100 !### TEMPORARILY REMOVED ### + go to 100 endif if(snr1.lt.2.8) then @@ -154,19 +153,20 @@ contains call timer('q65loops',0) call q65_loops(c00,npts/2,nsps/2,mode65,nsubmode,ndepth,jpk0, & - xdt,f0,width,iaptype,xdt1,f1,snr2,dat4,id2) + xdt,f0,width,iaptype,xdt1,f1,snr2,dat4,idec) call timer('q65loops',1) if(id2.gt.0) exit !Exit main loop after a successful decode enddo ! No single-transmission decode. -! if(iand(ndepth,16).eq.16) call q65_avg2 -! print*,'AAA: try for avg',navg + if(iand(ndepth,16).eq.16) then + call q65_avg2(nutc,ntrperiod,LL,ntol,lclearave, & + baud,nsubmode,ibwa,ibwb,codewords,ncw,xdt,f0,snr1,s3,dat4,idec) + endif 100 decoded=' ' - if(id1.gt.0 .or. id2.gt.0) then + if(idec.gt.0) then ! Unpack decoded message for display to user - idec=id1+id2 write(c77,1000) dat4(1:12),dat4(13)/2 1000 format(12b6.6,b5.5) call unpack77(c77,0,decoded,unpk77_success) !Unpack to get msgsent diff --git a/lib/qra/q65/q65_avg.f90 b/lib/qra/q65/q65_avg.f90 index 6a06a36f7..7ff7724be 100644 --- a/lib/qra/q65/q65_avg.f90 +++ b/lib/qra/q65/q65_avg.f90 @@ -1,5 +1,5 @@ -subroutine q65_avg(nutc,ntrperiod,LL,ntol,lclearave, & - baud,nsubmode,ibwa,ibwb,codewords,ncw,xdt,f0,snr1,s3) +subroutine q65_avg(nutc,ntrperiod,LL,ntol,lclearave,baud,nsubmode, & + ibwa,ibwb,codewords,ncw,xdt,f0,snr1,s3) ! Accumulate Q65 spectra s3(LL,63) and associated parameters for ! message averaging. @@ -63,9 +63,14 @@ subroutine q65_avg(nutc,ntrperiod,LL,ntol,lclearave, & f0save(nsave)=f0 !f0 s3save(:,:,nsave)=s3(:,:) !Symbol spectra -10 continue +10 return -!10 if(nsave.lt.2) go to 900 + entry q65_avg2(nutc,ntrperiod,LL,ntol,lclearave,baud,nsubmode, & + ibwa,ibwb,codewords,ncw,xdt,f0,snr1,s3,dat4,idec) + + mode_q65=2**nsubmode + ibwa=1.8*log(baud*mode_q65) + 2 + ibwb=min(10,ibwa+4) snr1sum=0. xdtsum=0. fsum=0. @@ -77,12 +82,8 @@ subroutine q65_avg(nutc,ntrperiod,LL,ntol,lclearave, & cused(i)='.' !Flag for "not used" if(iutc(i).lt.0) cycle if(iseq(i).ne.iseq(nsave)) cycle !Sequence must match -! write(*,3000) i,iseq(i),nutc,iutc(i),xdt-xdtsave(i),f0-f0save(i) -!3000 format(2i2,2i5,2f7.2) if(abs(xdt-xdtsave(i)).gt.dtdiff) cycle !DT must be close if(abs(f0-f0save(i)).gt.float(ntol)) cycle !Freq must match -! write(*,3001) 'a',i,nsave,iseq(i),snr1,xdt,f0 -!3001 format(a1,3i4,3f8.2) cused(i)='$' !Flag for "use this one" s3avg=s3avg + s3save(:,:,i) !Add this spectrum snr1sum=snr1sum + snr1save(i) @@ -92,15 +93,16 @@ subroutine q65_avg(nutc,ntrperiod,LL,ntol,lclearave, & iused(navg)=i enddo if(navg.lt.MAXAVE) iused(navg+1)=0 - + if(navg.lt.2) go to 900 + ! Find averages of snr1, xdt, and f0 used in this decoding attempt. snr1ave=0. xdtave=0. - fave=0. + f0ave=0. if(navg.gt.0) then snr1ave=snr1sum/navg xdtave=xdtsum/navg - fave=fsum/navg + f0ave=fsum/navg endif ! Write parameters for display to User in the Message Averaging (F7) window. @@ -119,28 +121,30 @@ subroutine q65_avg(nutc,ntrperiod,LL,ntol,lclearave, & do ibw=ibwa,ibwb b90=1.72**ibw b90ts=b90/baud - call q65_dec1(s3,nsubmode,b90ts,codewords,ncw,esnodb,irc,dat4,avemsg) + call q65_dec1(s3avg,nsubmode,b90ts,codewords,ncw,esnodb,irc,dat4,avemsg) +! irc=-99 !### TEMPORARY ### if(irc.ge.0 .and. plog.ge.PLOG_MIN) then snr2=esnodb - db(2500.0/baud) + 3.0 !Empirical adjustment - id1=1 !### -! print*,'B dec1 ',ibw,irc,avemsg - exit + idec=10+navg !### +! print*,'C dec1 ',ibw,irc,idec,avemsg + go to 900 endif enddo - APmask=0 - APsymbols=0 +! Should loop here over full range of available AP +! APmask=0 +! APsymbols=0 do ibw=ibwa,ibwb b90=1.72**ibw b90ts=b90/baud - call q65_dec2(s3,nsubmode,b90ts,esnodb,irc,dat4,avemsg) + call q65_dec2(s3avg,nsubmode,b90ts,esnodb,irc,dat4,avemsg) if(irc.ge.0) then - id2=iaptype+2 -! print*,'C dec2 ',ibw,irc,avemsg - exit + idec=10*(iaptype+2) + navg +! print*,'D dec2 ',ibw,irc,avemsg + go to 900 endif enddo ! ibw (b90 loop) - return +900 return end subroutine q65_avg diff --git a/lib/qra/q65/q65_loops.f90 b/lib/qra/q65/q65_loops.f90 index 2fec7891f..d734af305 100644 --- a/lib/qra/q65/q65_loops.f90 +++ b/lib/qra/q65/q65_loops.f90 @@ -77,9 +77,10 @@ subroutine q65_loops(c00,npts2,nsps,mode_q65,nsubmode,ndepth,jpk0, & ! -1 = invalid params ! -2 = decode failed ! -3 = CRC mismatch +! irc=-99 !### TEMPORARY ### if(irc.ge.0) then id2=iaptype+2 -! print*,'D dec2 ',ibw,irc,id2,decoded +! print*,'B dec2 ',ibw,irc,id2,decoded go to 100 endif enddo ! ibw (b90 loop) diff --git a/lib/qra/q65/q65_sync.f90 b/lib/qra/q65/q65_sync.f90 index afe36bf50..a27962c3a 100644 --- a/lib/qra/q65/q65_sync.f90 +++ b/lib/qra/q65/q65_sync.f90 @@ -1,5 +1,5 @@ subroutine q65_sync(nutc,iwave,ntrperiod,mode_q65,codewords,ncw,nsps, & - nfqso,ntol,ndepth,lclearave,emedelay,xdt,f0,snr1,width,dat4,snr2,id1) + nfqso,ntol,ndepth,lclearave,emedelay,xdt,f0,snr1,width,dat4,snr2,idec) ! Detect and align with the Q65 sync vector, returning time and frequency ! offsets and SNR estimate. @@ -35,8 +35,8 @@ subroutine q65_sync(nutc,iwave,ntrperiod,mode_q65,codewords,ncw,nsps, & data sync(1)/99.0/ save sync + idec=-1 snr1=0. - id1=0 dat4=0 LL=64*(2+mode_q65) nfft=nsps @@ -182,15 +182,14 @@ subroutine q65_sync(nutc,iwave,ntrperiod,mode_q65,codewords,ncw,nsps, & call q65_dec1(s3,nsubmode,b90ts,codewords,ncw,esnodb,irc,dat4,decoded) ! irc=-99 !### TEMPORARY ### if(irc.ge.0) then -! print*,'A dec1 ',ibw,irc,decoded +! print*,'A dec1 ',ibw,irc,esnodb,baud,trim(decoded) snr2=esnodb - db(2500.0/baud) + 3.0 !Empirical adjustment - id1=1 + idec=1 ic=ia2/4; base=(sum(ccf1(-ia2:-ia2+ic)) + sum(ccf1(ia2-ic:ia2)))/(2.0+2.0*ic); ccf1=ccf1-base smax=maxval(ccf1) if(smax.gt.10.0) ccf1=10.0*ccf1/smax -! go to 100 !### TEMPORARY ### go to 200 endif enddo @@ -257,7 +256,6 @@ subroutine q65_sync(nutc,iwave,ntrperiod,mode_q65,codewords,ncw,nsps, & endif 200 smax=maxval(ccf1) -! if(lavg) id1=10+navg !If this is an average decode i1=-9999 i2=-9999 do i=-ia,ia