Updated decoder with better debug handling. Fixed issue with E mode crashing on some decodes

This commit is contained in:
Jordan Sherer 2019-12-07 15:53:41 -05:00
parent 04fa0f42ad
commit 3be107b348
13 changed files with 98 additions and 93 deletions

View File

@ -23,7 +23,7 @@
#define JS8_ENABLE_JS8A 1
#define JS8_ENABLE_JS8B 1
#define JS8_ENABLE_JS8C 1
#define JS8_ENABLE_JS8E 0
#define JS8_ENABLE_JS8E 1
#define JS8A_SYMBOL_SAMPLES 1920
#define JS8A_TX_SECONDS 15
@ -37,7 +37,7 @@
#define JS8C_TX_SECONDS 6
#define JS8C_START_DELAY_MS 100
#define JS8E_IS_ULTRA 1
#define JS8E_IS_ULTRA 0
#if JS8E_IS_ULTRA
#define JS8E_SYMBOL_SAMPLES 384
#define JS8E_TX_SECONDS 4

View File

@ -147,11 +147,6 @@ subroutine ft8b(dd0,newdat,nQSOProgress,nfqso,nftx,ndepth,lapon,lapcqonly, &
! hard sync sum - max is 21
nsync=is1+is2+is3
! debug
!open(99, file="./js8.log", status="old", position="append", action="write")
!write(99,*) ibest, nsync
!close(99)
if(nsync .le. 6) then ! bail out
call timer('badnsync', 0)
nbadcrc=1

View File

@ -100,10 +100,6 @@ contains
call sync8(dd,ifa,ifb,syncmin,nfqso,s,candidate,ncand,sbase)
call timer('sync8 ',1)
!open(99, file="./js8.log", status="old", position="append", action="write")
!write(99,*) ncand, "candidates"
!close(99)
do icand=1,ncand
sync=candidate(3,icand)
f1=candidate(1,icand)

View File

@ -81,13 +81,5 @@ subroutine genjs8(msg,mygrid,bcontest,i3bit,msgsent,msgbits,itone)
indx=codeword(i)*4 + codeword(i+1)*2 + codeword(i+2)
itone(k)=indx
enddo
if(NWRITELOG.eq.1) then
open(99, file="./js8.log", status="old", position="append", action="write")
write(99,*) 'tones', itone
write(99,*) '...', icos7a, '--->', NCOSTAS
close(99)
endif
return
end subroutine genjs8

View File

@ -23,6 +23,11 @@ subroutine js8_downsample(dd,newdat,f0,c1)
first=.false.
endif
if(newdat) then
if(NWRITELOG.eq.1) then
write(*,*) '<DecodeDebug> newdat', NMAX, NDFFT1
flush(6)
endif
! Data in dd have changed, recompute the long FFT
x(1:NMAX)=dd
x(NMAX+1:NDFFT1)=0. !Zero-pad the x array
@ -39,6 +44,12 @@ subroutine js8_downsample(dd,newdat,f0,c1)
ib=max(1,nint(fb/df))
k=0
c1=0.
if(NWRITELOG.eq.1) then
write(*,*) '<DecodeDebug> ds', df, baud, i0, ib, it
flush(6)
endif
do i=ib,it
c1(k)=cx(i)
k=k+1

View File

@ -95,6 +95,9 @@ subroutine js8dec(dd0,newdat,nQSOProgress,nfqso,nftx,ndepth,lapon,lapcqonly, &
delfbest=0.
ibest=0
write(*,*) '<DecodeDebug> downsampling', fs2, dt2
flush(6)
call timer('js8_down',0)
call js8_downsample(dd0,newdat,f1,cd0) !Mix f1 to baseband and downsample
call timer('js8_down',1)
@ -104,17 +107,15 @@ subroutine js8dec(dd0,newdat,nQSOProgress,nfqso,nftx,ndepth,lapon,lapcqonly, &
smax=0.0
if(NWRITELOG.eq.1) then
open(99, file="./js8.log", status="old", position="append", action="write")
write(99,*) 'initial dt guess', i0, xdt
close(99)
write(*,*) '<DecodeDebug> initial dt guess', i0, xdt
flush(6)
endif
do idt=i0-NQSYMBOL,i0+NQSYMBOL !Search over +/- one quarter symbol
call syncjs8d(cd0,idt,ctwk,0,sync)
if(NWRITELOG.eq.1) then
open(99, file="./js8.log", status="old", position="append", action="write")
write(99,*) 'idt', idt, 'sync', sync
close(99)
write(*,*) '<DecodeDebug> ', 'idt', idt, 'sync', sync
flush(6)
endif
if(sync.gt.smax) then
smax=sync
@ -124,9 +125,8 @@ subroutine js8dec(dd0,newdat,nQSOProgress,nfqso,nftx,ndepth,lapon,lapcqonly, &
xdt2=ibest*dt2 !Improved estimate for DT
if(NWRITELOG.eq.1) then
open(99, file="./js8.log", status="old", position="append", action="write")
write(99,*) 'xdt2', xdt2, ibest
close(99)
write(*,*) '<DecodeDebug> ', 'xdt2', xdt2, 'ibest', ibest
flush(6)
endif
! Now peak up in frequency
@ -143,9 +143,8 @@ subroutine js8dec(dd0,newdat,nQSOProgress,nfqso,nftx,ndepth,lapon,lapcqonly, &
enddo
call syncjs8d(cd0,i0,ctwk,1,sync)
if(NWRITELOG.eq.1) then
open(99, file="./js8.log", status="old", position="append", action="write")
write(99,*) 'df', delf, 'sync', sync
close(99)
write(*,*) '<DecodeDebug> ', 'df', delf, 'sync', sync
flush(6)
endif
if( sync .gt. smax ) then
smax=sync
@ -159,9 +158,8 @@ subroutine js8dec(dd0,newdat,nQSOProgress,nfqso,nftx,ndepth,lapon,lapcqonly, &
f1=f1+delfbest !Improved estimate of DF
if(NWRITELOG.eq.1) then
open(99, file="./js8.log", status="old", position="append", action="write")
write(99,*) 'twk', xdt, f1, smax
close(99)
write(*,*) '<DecodeDebug> ', 'twk', xdt, f1, smax
flush(6)
endif
call syncjs8d(cd0,i0,ctwk,2,sync)
@ -192,9 +190,8 @@ subroutine js8dec(dd0,newdat,nQSOProgress,nfqso,nftx,ndepth,lapon,lapcqonly, &
nsync=is1+is2+is3
if(NWRITELOG.eq.1) then
open(99, file="./js8.log", status="old", position="append", action="write")
write(99,*) 'sync', ibest, nsync
close(99)
write(*,*) '<DecodeDebug> sync', ibest, nsync
flush(6)
endif
if(nsync .le. 6) then ! bail out
@ -400,9 +397,8 @@ subroutine js8dec(dd0,newdat,nQSOProgress,nfqso,nftx,ndepth,lapon,lapcqonly, &
call timer('bpd174 ',1)
if(NWRITELOG.eq.1) then
open(99, file="./js8.log", status="old", position="append", action="write")
write(99,*) '> bpd174 ', ipass, nharderrors, dmin
close(99)
write(*,*) '<DecodeDebug> bpd174', ipass, nharderrors, dmin
flush(6)
endif
dmin=0.0
@ -425,9 +421,8 @@ subroutine js8dec(dd0,newdat,nQSOProgress,nfqso,nftx,ndepth,lapon,lapcqonly, &
xsnr=-99.0
if(NWRITELOG.eq.1) then
open(99, file="./js8.log", status="old", position="append", action="write")
write(99,*) '> osd174', ipass, nharderrors, dmin, nharderrors + dmin, sync
close(99)
write(*,*) '<DecodeDebug> osd174', ipass, nharderrors, dmin, nharderrors + dmin, sync
flush(6)
endif
if(count(cw.eq.0).eq.174) cycle !Reject the all-zero codeword
@ -439,12 +434,8 @@ subroutine js8dec(dd0,newdat,nQSOProgress,nfqso,nftx,ndepth,lapon,lapcqonly, &
call chkcrc12a(decoded,nbadcrc)
if(NWRITELOG.eq.1) then
open(99, file="./js8.log", status="old", position="append", action="write")
write(99,*) '> crc', decoded
if(nbadcrc.eq.1) then
write(99,*) '> crc failed'
endif
close(99)
write(*,*) '<DecodeDebug> crc', decoded, 'bad', nbadcrc
flush(6)
endif
else
nharderrors=-1
@ -459,7 +450,13 @@ subroutine js8dec(dd0,newdat,nQSOProgress,nfqso,nftx,ndepth,lapon,lapcqonly, &
message(1:12)=origmsg(1:12)
call genjs8(message,mygrid6,bcontest,i3bit,msgsent,msgbits,itone)
if(lsubtract) call subtractjs8(dd0,itone,f1,xdt2)
if(lsubtract) then
if(NWRITELOG.eq.1) then
write(*,*) '<DecodeDebug> subtract', f1, xdt2, itone
flush(6)
endif
call subtractjs8(dd0,itone,f1,xdt2)
endif
xsig=0.0
xnoi=0.0
do i=1,NN
@ -477,6 +474,11 @@ subroutine js8dec(dd0,newdat,nQSOProgress,nfqso,nftx,ndepth,lapon,lapcqonly, &
msg37=origmsg//' '
msg37(22:22) = char(48 + i3bit)
if(NWRITELOG.eq.1) then
write(*,*) '<DecodeDebug> msg', msg37, 'snr', xsnr
flush(6)
endif
return
endif

View File

@ -6,7 +6,7 @@
!parameter (JZ=62) !Sync Search Space over +/- 2.5s relative to 0.5s TX start time. 2.48 = 62/4/(12000/1920) ?
parameter (NSPS=384, NTXDUR=4, NDOWNSPS=12, NDD=125, JZ=250) ! 250 Hz 31.25 baud 60 wpm -18.0dB (1.0Eb/N0) 2.52s
! parameter (NSPS=384, NTXDUR=4, NDOWNSPS=12, NDD=125, JZ=250) ! 250 Hz 31.25 baud 60 wpm -18.0dB (1.0Eb/N0) 2.52s
! parameter (NSPS=384, NTXDUR=5, NDOWNSPS=12, NDD=125, JZ=116) ! 250 Hz 31.25 baud 48 wpm -18.0dB (1.0Eb/N0) 2.52s
! parameter (NSPS=480, NTXDUR=5, NDOWNSPS=12, NDD=125, JZ=116) ! 200 Hz 25 baud 48 wpm -19.0dB (1.0Eb/N0) 3.16s
! parameter (NSPS=480, NTXDUR=6, NDOWNSPS=20, NDD=150, JZ=116) ! 200 Hz 25 baud 40 wpm -19.0dB (1.0Eb/N0) 3.16s
@ -18,7 +18,7 @@
! parameter (NSPS=1200, NTXDUR=10, NDOWNSPS=20, NDD=100, JZ=116) ! 80 Hz 10 baud 24 wpm -23.0dB (1.0Eb/N0) 7.90s
! parameter (NSPS=1920, NTXDUR=15, NDOWNSPS=32, NDD=100, JZ=116) ! 50 Hz 6.250 baud 16 wpm -25.0dB (1.0Eb/N0) 12.64s
! parameter (NSPS=3840, NTXDUR=30, NDOWNSPS=32, NDD=94, JZ=116) ! 24 Hz 3.125 baud 8 wpm -28.0dB (1.0Eb/N0) 25.28s
! parameter (NSPS=4000, NTXDUR=30, NDOWNSPS=32, NDD=90, JZ=32) ! 24 Hz 3 baud 8 wpm -28.2dB (1.0Eb/N0) 26.33s
parameter (NSPS=4000, NTXDUR=28, NDOWNSPS=20, NDD=90, JZ=32) ! 24 Hz 3 baud 8 wpm -28.2dB (1.0Eb/N0) 26.33s
parameter (AZ=12000.0/(1.0*NSPS)*0.8d0) !Dedupe overlap in Hz
parameter (ASTART=0.5) !Start delay in seconds

View File

@ -23,6 +23,12 @@ subroutine subtractjs8(dd,itone,f0,dt)
save first
nstart=dt*12000+1
if(NWRITELOG.eq.1) then
write(*,*) '<DecodeDebug> generating reference signal', nstart
flush(6)
endif
call genjs8refsig(itone,cref,f0)
camp=0.
do i=1,nframe
@ -30,6 +36,11 @@ subroutine subtractjs8(dd,itone,f0,dt)
if(id.ge.1.and.id.le.NMAX) camp(i)=dd(id)*conjg(cref(i))
enddo
if(NWRITELOG.eq.1) then
write(*,*) '<DecodeDebug> filtering', nfft
flush(6)
endif
if(first) then
! Create and normalize the filter
pi=4.0*atan(1.0)
@ -53,6 +64,11 @@ subroutine subtractjs8(dd,itone,f0,dt)
cfilt(1:nfft)=cfilt(1:nfft)*cw(1:nfft)
call four2a(cfilt,nfft,1,1,1)
if(NWRITELOG.eq.1) then
write(*,*) '<DecodeDebug> subtracting filtered reference', nfft
flush(6)
endif
! Subtract the reconstructed signal
do i=1,nframe
j=nstart+i-1

View File

@ -134,9 +134,8 @@ subroutine syncjs8(dd,nfa,nfb,syncmin,nfqso,s,candidate,ncand,sbase)
n=ia + indx(iz+1-i) - 1
if(red(n).lt.syncmin.or.isnan(red(n))) exit
if(NWRITELOG.eq.1) then
open(99, file="./js8.log", status="old", position="append", action="write")
write(99,*) 'red candidate', red(n), n*df, (jpeak(n)-1)*tstep
close(99)
write(*,*) '<DecodeDebug>', 'red candidate', red(n), n*df, (jpeak(n)-1)*tstep
flush(6)
endif
k=k+1
candidate0(1,k)=n*df

View File

@ -92,10 +92,8 @@ contains
call timer('syncjs8 ',1)
if(NWRITELOG.eq.1) then
open(99, file="./js8.log", status="old", position="append", action="write")
write(99,*) ncand, "candidates"
write(99,*) "---"
close(99)
write(*,*) '<DecodeDebug>', ncand, "candidates"
flush(6)
endif
do icand=1,ncand
@ -106,9 +104,8 @@ contains
nsnr0=min(99,nint(10.0*log10(sync) - 25.5)) !### empirical ###
if(NWRITELOG.eq.1) then
open(99, file="./js8.log", status="old", position="append", action="write")
write(99,*) 'icand', icand, f1, sync, xdt, xbase
close(99)
write(*,*) '<DecodeDebug> candidate', icand, 'f1', f1, 'sync', sync, 'xdt', xdt, 'xbase', xbase
flush(6)
endif
call timer('js8dec ',0)
@ -122,9 +119,8 @@ contains
hd=nharderrors+dmin
if(NWRITELOG.eq.1) then
open(99, file="./js8.log", status="old", position="append", action="write")
write(99,*) 'icand', icand, hd, nbadcrc
close(99)
write(*,*) '<DecodeDebug> candidate', icand, 'hard', hd, 'nbadcrc', nbadcrc
flush(6)
endif
call timer('js8dec ',1)
@ -145,9 +141,8 @@ contains
endif
if(NWRITELOG.eq.1) then
open(99, file="./js8.log", status="old", position="append", action="write")
write(99,*) '---'
close(99)
write(*,*) '<DecodeDebug> ---'
flush(6)
endif
enddo
enddo

View File

@ -92,9 +92,8 @@ contains
call timer('syncjs8 ',1)
if(NWRITELOG.eq.1) then
open(99, file="./js8.log", status="old", position="append", action="write")
write(99,*) ncand, "candidates"
close(99)
write(*,*) '<DecodeDebug>', ncand, "candidates"
flush(6)
endif
do icand=1,ncand
@ -105,9 +104,8 @@ contains
nsnr0=min(99,nint(10.0*log10(sync) - 25.5)) !### empirical ###
if(NWRITELOG.eq.1) then
open(99, file="./js8.log", status="old", position="append", action="write")
write(99,*) 'icand', icand, f1, sync, xdt, xbase
close(99)
write(*,*) '<DecodeDebug> candidate', icand, 'f1', f1, 'sync', sync, 'xdt', xdt, 'xbase', xbase
flush(6)
endif
call timer('js8dec ',0)
@ -121,9 +119,8 @@ contains
hd=nharderrors+dmin
if(NWRITELOG.eq.1) then
open(99, file="./js8.log", status="old", position="append", action="write")
write(99,*) 'icand', icand, hd, nbadcrc
close(99)
write(*,*) '<DecodeDebug> candidate', icand, 'hard', hd, 'nbadcrc', nbadcrc
flush(6)
endif
call timer('js8dec ',1)
@ -144,9 +141,8 @@ contains
endif
if(NWRITELOG.eq.1) then
open(99, file="./js8.log", status="old", position="append", action="write")
write(99,*) '---'
close(99)
write(*,*) '<DecodeDebug> ---'
flush(6)
endif
enddo
enddo

View File

@ -92,9 +92,8 @@ contains
call timer('syncjs8 ',1)
if(NWRITELOG.eq.1) then
open(99, file="./js8.log", status="old", position="append", action="write")
write(99,*) ncand, "candidates"
close(99)
write(*,*) '<DecodeDebug>', ncand, "candidates"
flush(6)
endif
do icand=1,ncand
@ -105,12 +104,15 @@ contains
nsnr0=min(99,nint(10.0*log10(sync) - 25.5)) !### empirical ###
if(NWRITELOG.eq.1) then
open(99, file="./js8.log", status="old", position="append", action="write")
write(99,*) 'icand', icand, f1, sync, xdt, xbase
close(99)
write(*,*) '<DecodeDebug> candidate', icand, 'f1', f1, 'sync', sync, 'xdt', xdt, 'xbase', xbase
flush(6)
endif
call timer('js8dec ',0)
! for now, subtraction of slow is not possible
if(NSPS.gt.1920) then
lsubtract=.false.
endif
call js8dec(dd,newdat,nQSOProgress,nfqso,nftx,ndepth,lft8apon, &
lapcqonly,napwid,lsubtract,nagain,iaptype,mycall12,mygrid6, &
hiscall12,bcontest,sync,f1,xdt,xbase,apsym,nharderrors,dmin, &
@ -121,9 +123,8 @@ contains
hd=nharderrors+dmin
if(NWRITELOG.eq.1) then
open(99, file="./js8.log", status="old", position="append", action="write")
write(99,*) 'icand', icand, hd, nbadcrc
close(99)
write(*,*) '<DecodeDebug> candidate', icand, 'hard', hd, 'nbadcrc', nbadcrc
flush(6)
endif
call timer('js8dec ',1)
@ -144,9 +145,8 @@ contains
endif
if(NWRITELOG.eq.1) then
open(99, file="./js8.log", status="old", position="append", action="write")
write(99,*) '---'
close(99)
write(*,*) '<DecodeDebug> ---'
flush(6)
endif
enddo
enddo

View File

@ -223,7 +223,6 @@ program jt9
do iblk=1,npts/kstep
k=iblk*kstep
if(mode.eq.8 .and. k.gt.179712) exit
call timer('read_wav',0)
read(unit=wav%lun,end=3) shared_data%id2(k-kstep+1:k)
go to 4
@ -287,6 +286,10 @@ program jt9
datetime="2013-Apr-16 15:13" !### Temp
shared_data%params%datetime=transfer(datetime,shared_data%params%datetime)
if(mode.eq.9 .and. fsplit.ne.2700) shared_data%params%nfa=fsplit
shared_data%params%kposA=0
shared_data%params%kposB=0
shared_data%params%kposC=0
shared_data%params%kposE=0
shared_data%params%kszA=NMAX-1
shared_data%params%kszB=NMAX-1
shared_data%params%kszC=NMAX-1