Working through decoder fixes, getting closer

This commit is contained in:
Jordan Sherer 2020-04-30 21:14:29 -04:00
parent 60f9a03898
commit 1a10ab5d13
13 changed files with 125 additions and 105 deletions

View File

@ -4,7 +4,7 @@ parameter (NCOSTAS=1) !Which JS8 Costas Arrays to use (1=origina
parameter (NSPS=1920, NTXDUR=15, NDOWNSPS=32, NDD=100, JZ=62) ! 50 Hz 6.250 baud 16 wpm -25.0dB (1.0Eb/N0) 12.64s
parameter (AZ=12000.0/(1.0*NSPS)*0.8d0) !Dedupe overlap in Hz
parameter (AZ=12000.0/(1.0*NSPS)*0.64d0) !Dedupe overlap in Hz
parameter (ASTART=0.5) !Start delay in seconds
parameter (ASYNCMIN=1.5) !Minimum Sync

View File

@ -2,7 +2,7 @@ parameter (NCOSTAS=2) !Which JS8 Costas Arrays to use (1=origina
parameter (NSPS=600, NTXDUR=6, NDOWNSPS=12, NDD=120, JZ=172) ! 160 Hz 20 baud 40 wpm -20.0dB (1.0Eb/N0) 3.95s
parameter (AZ=12000.0/(1.0*NSPS)*0.8d0) !Dedupe overlap in Hz
parameter (AZ=12000.0/(1.0*NSPS)*0.6d0) !Dedupe overlap in Hz
parameter (ASTART=0.1) !Start delay in seconds
parameter (ASYNCMIN=1.5) !Minimum Sync

View File

@ -1,4 +1,4 @@
subroutine js8dec(dd0,newdat,nQSOProgress,nfqso,nftx,ndepth,lapon,lapcqonly, &
subroutine js8dec(dd0,icos,newdat,nQSOProgress,nfqso,nftx,ndepth,lapon,lapcqonly, &
napwid,lsubtract,nagain,iaptype,mycall12,mygrid6,hiscall12,bcontest, &
sync0,f1,xdt,xbase,apsym,nharderrors,dmin,nbadcrc,ipass,iera,msg37,xsnr)
@ -45,7 +45,7 @@ subroutine js8dec(dd0,newdat,nQSOProgress,nfqso,nftx,ndepth,lapon,lapcqonly, &
save nappasses,naptypes
integer icos7a(0:6), icos7b(0:6), icos7c(0:6)
if(NCOSTAS.eq.1) then
if(icos.eq.1) then
icos7a = (/4,2,5,6,1,3,0/) !Beginning Costas 7x7 tone pattern
icos7b = (/4,2,5,6,1,3,0/) !Middle Costas 7x7 tone pattern
icos7c = (/4,2,5,6,1,3,0/) !End Costas 7x7 tone pattern
@ -119,7 +119,7 @@ subroutine js8dec(dd0,newdat,nQSOProgress,nfqso,nftx,ndepth,lapon,lapcqonly, &
endif
do idt=i0-NQSYMBOL,i0+NQSYMBOL !Search over +/- one quarter symbol
call syncjs8d(cd0,idt,ctwk,0,sync)
call syncjs8d(cd0,icos,idt,ctwk,0,sync)
if(NWRITELOG.eq.0) then
write(*,*) '<DecodeDebug> ', 'idt', idt, 'sync', sync
flush(6)
@ -148,7 +148,7 @@ subroutine js8dec(dd0,newdat,nQSOProgress,nfqso,nftx,ndepth,lapon,lapcqonly, &
ctwk(i)=cmplx(cos(phi),sin(phi))
phi=mod(phi+dphi,twopi)
enddo
call syncjs8d(cd0,i0,ctwk,1,sync)
call syncjs8d(cd0,icos,i0,ctwk,1,sync)
if(NWRITELOG.eq.0) then
write(*,*) '<DecodeDebug> ', 'df', delf, 'sync', sync
flush(6)
@ -169,7 +169,7 @@ subroutine js8dec(dd0,newdat,nQSOProgress,nfqso,nftx,ndepth,lapon,lapcqonly, &
flush(6)
endif
call syncjs8d(cd0,i0,ctwk,2,sync)
call syncjs8d(cd0,icos,i0,ctwk,2,sync)
j=0
do k=1,NN
@ -247,63 +247,63 @@ subroutine js8dec(dd0,newdat,nQSOProgress,nfqso,nftx,ndepth,lapon,lapcqonly, &
bmetb(i1)=r1
! Metric for Cauchy noise
! r1=log(ps(1)**3+ps(3)**3+ps(5)**3+ps(7)**3)- &
! log(ps(0)**3+ps(2)**3+ps(4)**3+ps(6)**3)
! r2=log(ps(2)**3+ps(3)**3+ps(6)**3+ps(7)**3)- &
! log(ps(0)**3+ps(1)**3+ps(4)**3+ps(5)**3)
! r4=log(ps(4)**3+ps(5)**3+ps(6)**3+ps(7)**3)- &
! log(ps(0)**3+ps(1)**3+ps(2)**3+ps(3)**3)
r1=log(ps(1)**3+ps(3)**3+ps(5)**3+ps(7)**3)- &
log(ps(0)**3+ps(2)**3+ps(4)**3+ps(6)**3)
r2=log(ps(2)**3+ps(3)**3+ps(6)**3+ps(7)**3)- &
log(ps(0)**3+ps(1)**3+ps(4)**3+ps(5)**3)
r4=log(ps(4)**3+ps(5)**3+ps(6)**3+ps(7)**3)- &
log(ps(0)**3+ps(1)**3+ps(2)**3+ps(3)**3)
! Metric for AWGN, no fading
! bscale=2.5
! b0=bessi0(bscale*ps(0))
! b1=bessi0(bscale*ps(1))
! b2=bessi0(bscale*ps(2))
! b3=bessi0(bscale*ps(3))
! b4=bessi0(bscale*ps(4))
! b5=bessi0(bscale*ps(5))
! b6=bessi0(bscale*ps(6))
! b7=bessi0(bscale*ps(7))
! r1=log(b1+b3+b5+b7)-log(b0+b2+b4+b6)
! r2=log(b2+b3+b6+b7)-log(b0+b1+b4+b5)
! r4=log(b4+b5+b6+b7)-log(b0+b1+b2+b3)
bscale=2.5
b0=bessi0(bscale*ps(0))
b1=bessi0(bscale*ps(1))
b2=bessi0(bscale*ps(2))
b3=bessi0(bscale*ps(3))
b4=bessi0(bscale*ps(4))
b5=bessi0(bscale*ps(5))
b6=bessi0(bscale*ps(6))
b7=bessi0(bscale*ps(7))
r1=log(b1+b3+b5+b7)-log(b0+b2+b4+b6)
r2=log(b2+b3+b6+b7)-log(b0+b1+b4+b5)
r4=log(b4+b5+b6+b7)-log(b0+b1+b2+b3)
! if(nQSOProgress .eq. 0 .or. nQSOProgress .eq. 5) then
! ! When bits 88:115 are set as ap bits, bit 115 lives in symbol 39 along
! ! with no-ap bits 116 and 117. Take care of metrics for bits 116 and 117.
! if(j.eq.39) then ! take care of bits that live in symbol 39
! if(apsym(28).lt.0) then
! bmetap(i2)=max(ps(2),ps(3))-max(ps(0),ps(1))
! bmetap(i1)=max(ps(1),ps(3))-max(ps(0),ps(2))
! else
! bmetap(i2)=max(ps(6),ps(7))-max(ps(4),ps(5))
! bmetap(i1)=max(ps(5),ps(7))-max(ps(4),ps(6))
! endif
! endif
! endif
!
! ! When bits 116:143 are set as ap bits, bit 115 lives in symbol 39 along
! ! with ap bits 116 and 117. Take care of metric for bit 115.
! if(j.eq.39) then ! take care of bit 115
! iii=2*(apsym(29)+1)/2 + (apsym(30)+1)/2 ! known values of bits 116 & 117
! if(iii.eq.0) bmetap(i4)=ps(4)-ps(0)
! if(iii.eq.1) bmetap(i4)=ps(5)-ps(1)
! if(iii.eq.2) bmetap(i4)=ps(6)-ps(2)
! if(iii.eq.3) bmetap(i4)=ps(7)-ps(3)
! endif
!
! ! bit 144 lives in symbol 48 and will be 1 if it is set as an ap bit.
! ! take care of metrics for bits 142 and 143
! if(j.eq.48) then ! bit 144 is always 1
! bmetap(i4)=max(ps(5),ps(7))-max(ps(1),ps(3))
! bmetap(i2)=max(ps(3),ps(7))-max(ps(1),ps(5))
! endif
!
! ! bit 154 lives in symbol 52 and will be 0 if it is set as an ap bit
! ! take care of metrics for bits 155 and 156
! if(j.eq.52) then ! bit 154 will be 0 if it is set as an ap bit.
! bmetap(i2)=max(ps(2),ps(3))-max(ps(0),ps(1))
! bmetap(i1)=max(ps(1),ps(3))-max(ps(0),ps(2))
! endif
if(nQSOProgress .eq. 0 .or. nQSOProgress .eq. 5) then
! When bits 88:115 are set as ap bits, bit 115 lives in symbol 39 along
! with no-ap bits 116 and 117. Take care of metrics for bits 116 and 117.
if(j.eq.39) then ! take care of bits that live in symbol 39
if(apsym(28).lt.0) then
bmetap(i2)=max(ps(2),ps(3))-max(ps(0),ps(1))
bmetap(i1)=max(ps(1),ps(3))-max(ps(0),ps(2))
else
bmetap(i2)=max(ps(6),ps(7))-max(ps(4),ps(5))
bmetap(i1)=max(ps(5),ps(7))-max(ps(4),ps(6))
endif
endif
endif
! When bits 116:143 are set as ap bits, bit 115 lives in symbol 39 along
! with ap bits 116 and 117. Take care of metric for bit 115.
if(j.eq.39) then ! take care of bit 115
iii=2*(apsym(29)+1)/2 + (apsym(30)+1)/2 ! known values of bits 116 & 117
if(iii.eq.0) bmetap(i4)=ps(4)-ps(0)
if(iii.eq.1) bmetap(i4)=ps(5)-ps(1)
if(iii.eq.2) bmetap(i4)=ps(6)-ps(2)
if(iii.eq.3) bmetap(i4)=ps(7)-ps(3)
endif
! bit 144 lives in symbol 48 and will be 1 if it is set as an ap bit.
! take care of metrics for bits 142 and 143
if(j.eq.48) then ! bit 144 is always 1
bmetap(i4)=max(ps(5),ps(7))-max(ps(1),ps(3))
bmetap(i2)=max(ps(3),ps(7))-max(ps(1),ps(5))
endif
! bit 154 lives in symbol 52 and will be 0 if it is set as an ap bit
! take care of metrics for bits 155 and 156
if(j.eq.52) then ! bit 154 will be 0 if it is set as an ap bit.
bmetap(i2)=max(ps(2),ps(3))-max(ps(0),ps(1))
bmetap(i1)=max(ps(1),ps(3))-max(ps(0),ps(2))
endif
enddo
@ -457,7 +457,6 @@ subroutine js8dec(dd0,newdat,nQSOProgress,nfqso,nftx,ndepth,lapon,lapcqonly, &
decoded=decoded0
message(1:12)=origmsg(1:12)
icos=NCOSTAS
call genjs8(message,icos,mygrid6,bcontest,i3bit,msgsent,msgbits,itone)
if(lsubtract) then
if(NWRITELOG.eq.1) then

View File

@ -2,7 +2,7 @@ parameter (NCOSTAS=2) !Which JS8 Costas Arrays to use (1=origina
parameter (NSPS=3840, NTXDUR=28, NDOWNSPS=32, NDD=90, JZ=32) ! 25 Hz 3.125 baud 8 wpm -28.0dB (1.0Eb/N0) 25.28s
parameter (AZ=12000.0/(1.0*NSPS)*0.8d0) !Dedupe overlap in Hz
parameter (AZ=12000.0/(1.0*NSPS)*0.64d0) !Dedupe overlap in Hz
parameter (ASTART=0.5) !Start delay in seconds
parameter (ASYNCMIN=1.5) !Minimum Sync

View File

@ -2,7 +2,7 @@ parameter (NCOSTAS=2) !Which JS8 Costas Arrays to use (1=origina
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 (AZ=12000.0/(1.0*NSPS)*0.8d0) !Dedupe overlap in Hz
parameter (AZ=12000.0/(1.0*NSPS)*0.64d0)!Dedupe overlap in Hz
parameter (ASTART=0.1) !Start delay in seconds
parameter (ASYNCMIN=1.5) !Minimum Sync

View File

@ -6,10 +6,11 @@ subroutine subtractjs8(dd,itone,f0,dt)
! Complex amp : cfilt(t) = LPF[ dd(t)*CONJG(cref(t)) ]
! Subtract : dd(t) = dd(t) - 2*REAL{cref*cfilt}
parameter (NSHIFT=0)
parameter (NFRAME=NSPS*NN)
parameter (NFFT=NMAX, NFILT=1400)
real dd(NMAX), window(-NFILT/2:NFILT/2)
real*4 dd(NMAX), window(-NFILT/2:NFILT/2)
complex cref,camp,cfilt,cw
integer itone(NN)
logical first
@ -38,36 +39,51 @@ subroutine subtractjs8(dd,itone,f0,dt)
endif
if(first) then
! Create and normalize the filter
! Create and normalize the filter
if(NWRITELOG.eq.1) then
write(*,*) '<DecodeDebug> creating and normalizing filter'
flush(6)
endif
pi=4.0*atan(1.0)
fac=1.0/float(NFFT)
sum=0.0
do j=-NFILT/2,NFILT/2
window(j)=cos(pi*j/NFILT)**2
sum=sum+window(j)
enddo
cw=0.
! this ultimately shifts 1/2 of the window out of computation
! since it's multiplied against cfilt whiich will only have amp
! values for NFRAME length, which will always be > 20000 samples
! longer than the NFRAME.
! cw(1:NFILT+1)=window/sum
! cw=cshift(cw,NFILT/2+1)
cw(1:NFILT/2)=window(1:NFILT/2)
! we really don't even need the second half of the window.
! start=NMAX-NFILT/2
! end=NMAX-NFILT+1
! cw(start:end)=window(-NFILT/2:1)
cw=cw/sum
call four2a(cw,NFFT,1,-1,1)
cw=cw*fac
first=.false.
if(NSHIFT.ne.1) then
pi=4.0*atan(1.0)
fac=1.0/float(NFFT)
sum=0.0
do j=-NFILT/2,NFILT/2
window(j)=cos(pi*j/NFILT)**2
sum=sum+window(j)
enddo
cw=0.
cw(1:NFILT+1)=window/sum
cw=cshift(cw,NFILT/2+1)
call four2a(cw,NFFT,1,-1,1)
cw=cw*fac
first=.false.
else
pi=4.0*atan(1.0)
fac=1.0/float(NFFT)
sum=0.0
do j=-NFILT/2,NFILT/2
window(j)=cos(pi*j/NFILT)**2
sum=sum+window(j)
enddo
cw=0.
! this ultimately shifts 1/2 of the window out of computation
! since it's multiplied against cfilt whiich will only have amp
! values for NFRAME length, which will always be > 20000 samples
! longer than the NFRAME.
! cw(1:NFILT+1)=window/sum
! cw=cshift(cw,NFILT/2+1)
cw(1:NFILT/2)=window(1:NFILT/2)
! we really don't even need the second half of the window.
! start=NMAX-NFILT/2
! end=NMAX-NFILT+1
! cw(start:end)=window(-NFILT/2:1)
cw=cw/sum
call four2a(cw,NFFT,1,-1,1)
cw=cw*fac
first=.false.
endif
endif
if(NWRITELOG.eq.1) then

View File

@ -1,4 +1,4 @@
subroutine syncjs8(dd,nfa,nfb,syncmin,nfqso,s,candidate,ncand,sbase)
subroutine syncjs8(dd,icos,nfa,nfb,syncmin,nfqso,s,candidate,ncand,sbase)
!include 'js8_params.f90'
@ -20,7 +20,7 @@ subroutine syncjs8(dd,nfa,nfb,syncmin,nfqso,s,candidate,ncand,sbase)
integer icos7a(0:6), icos7b(0:6), icos7c(0:6)
if(NCOSTAS.eq.1) then
if(icos.eq.1) then
icos7a = (/4,2,5,6,1,3,0/) !Beginning Costas 7x7 tone pattern
icos7b = (/4,2,5,6,1,3,0/) !Middle Costas 7x7 tone pattern
icos7c = (/4,2,5,6,1,3,0/) !End Costas 7x7 tone pattern

View File

@ -1,4 +1,4 @@
subroutine syncjs8d(cd0,i0,ctwk,itwk,sync)
subroutine syncjs8d(cd0,icos,i0,ctwk,itwk,sync)
! Compute sync power for a complex, downsampled JS8 signal.
!include 'js8_params.f90'
@ -17,7 +17,7 @@ subroutine syncjs8d(cd0,i0,ctwk,itwk,sync)
integer icos7a(0:6), icos7b(0:6), icos7c(0:6)
if(NCOSTAS.eq.1) then
if(icos.eq.1) then
icos7a = (/4,2,5,6,1,3,0/) !Beginning Costas 7x7 tone pattern
icos7b = (/4,2,5,6,1,3,0/) !Middle Costas 7x7 tone pattern
icos7c = (/4,2,5,6,1,3,0/) !End Costas 7x7 tone pattern

View File

@ -48,6 +48,7 @@ contains
integer allsnrs(100)
save s,dd
icos=int(NCOSTAS)
bcontest=iand(nexp_decode,128).ne.0
this%callback => callback
write(datetime,1001) nutc !### TEMPORARY ###
@ -86,7 +87,7 @@ contains
endif
call timer('syncjs8 ',0)
call syncjs8(dd,ifa,ifb,syncmin,nfqso,s,candidate,ncand,sbase)
call syncjs8(dd,icos,ifa,ifb,syncmin,nfqso,s,candidate,ncand,sbase)
call timer('syncjs8 ',1)
if(NWRITELOG.eq.1) then
@ -106,7 +107,7 @@ contains
endif
call timer('js8dec ',0)
call js8dec(dd,newdat,nQSOProgress,nfqso,nftx,ndepth,lft8apon, &
call js8dec(dd,icos,newdat,nQSOProgress,nfqso,nftx,ndepth,lft8apon, &
lapcqonly,napwid,lsubtract,nagain,iaptype,mycall12,mygrid6, &
hiscall12,bcontest,sync,f1,xdt,xbase,apsym,nharderrors,dmin, &
nbadcrc,iappass,iera,msg37,xsnr)

View File

@ -48,6 +48,7 @@ contains
integer allsnrs(100)
save s,dd
icos=int(NCOSTAS)
bcontest=iand(nexp_decode,128).ne.0
this%callback => callback
write(datetime,1001) nutc !### TEMPORARY ###
@ -86,7 +87,7 @@ contains
endif
call timer('syncjs8 ',0)
call syncjs8(dd,ifa,ifb,syncmin,nfqso,s,candidate,ncand,sbase)
call syncjs8(dd,icos,ifa,ifb,syncmin,nfqso,s,candidate,ncand,sbase)
call timer('syncjs8 ',1)
if(NWRITELOG.eq.1) then
@ -106,7 +107,7 @@ contains
endif
call timer('js8dec ',0)
call js8dec(dd,newdat,nQSOProgress,nfqso,nftx,ndepth,lft8apon, &
call js8dec(dd,icos,newdat,nQSOProgress,nfqso,nftx,ndepth,lft8apon, &
lapcqonly,napwid,lsubtract,nagain,iaptype,mycall12,mygrid6, &
hiscall12,bcontest,sync,f1,xdt,xbase,apsym,nharderrors,dmin, &
nbadcrc,iappass,iera,msg37,xsnr)

View File

@ -48,6 +48,7 @@ contains
integer allsnrs(100)
save s,dd
icos=int(NCOSTAS)
bcontest=iand(nexp_decode,128).ne.0
this%callback => callback
write(datetime,1001) nutc !### TEMPORARY ###
@ -86,7 +87,7 @@ contains
endif
call timer('syncjs8 ',0)
call syncjs8(dd,ifa,ifb,syncmin,nfqso,s,candidate,ncand,sbase)
call syncjs8(dd,icos,ifa,ifb,syncmin,nfqso,s,candidate,ncand,sbase)
call timer('syncjs8 ',1)
if(NWRITELOG.eq.1) then
@ -106,7 +107,7 @@ contains
endif
call timer('js8dec ',0)
call js8dec(dd,newdat,nQSOProgress,nfqso,nftx,ndepth,lft8apon, &
call js8dec(dd,icos,newdat,nQSOProgress,nfqso,nftx,ndepth,lft8apon, &
lapcqonly,napwid,lsubtract,nagain,iaptype,mycall12,mygrid6, &
hiscall12,bcontest,sync,f1,xdt,xbase,apsym,nharderrors,dmin, &
nbadcrc,iappass,iera,msg37,xsnr)

View File

@ -48,6 +48,7 @@ contains
integer allsnrs(100)
save s,dd
icos=int(NCOSTAS)
bcontest=iand(nexp_decode,128).ne.0
this%callback => callback
write(datetime,1001) nutc !### TEMPORARY ###
@ -86,7 +87,7 @@ contains
endif
call timer('syncjs8 ',0)
call syncjs8(dd,ifa,ifb,syncmin,nfqso,s,candidate,ncand,sbase)
call syncjs8(dd,icos,ifa,ifb,syncmin,nfqso,s,candidate,ncand,sbase)
call timer('syncjs8 ',1)
if(NWRITELOG.eq.1) then
@ -106,7 +107,7 @@ contains
endif
call timer('js8dec ',0)
call js8dec(dd,newdat,nQSOProgress,nfqso,nftx,ndepth,lft8apon, &
call js8dec(dd,icos,newdat,nQSOProgress,nfqso,nftx,ndepth,lft8apon, &
lapcqonly,napwid,lsubtract,nagain,iaptype,mycall12,mygrid6, &
hiscall12,bcontest,sync,f1,xdt,xbase,apsym,nharderrors,dmin, &
nbadcrc,iappass,iera,msg37,xsnr)

View File

@ -48,6 +48,7 @@ contains
integer allsnrs(100)
save s,dd
icos=int(NCOSTAS)
bcontest=iand(nexp_decode,128).ne.0
this%callback => callback
write(datetime,1001) nutc !### TEMPORARY ###
@ -86,7 +87,7 @@ contains
endif
call timer('syncjs8 ',0)
call syncjs8(dd,ifa,ifb,syncmin,nfqso,s,candidate,ncand,sbase)
call syncjs8(dd,icos,ifa,ifb,syncmin,nfqso,s,candidate,ncand,sbase)
call timer('syncjs8 ',1)
if(NWRITELOG.eq.1) then
@ -106,7 +107,7 @@ contains
endif
call timer('js8dec ',0)
call js8dec(dd,newdat,nQSOProgress,nfqso,nftx,ndepth,lft8apon, &
call js8dec(dd,icos,newdat,nQSOProgress,nfqso,nftx,ndepth,lft8apon, &
lapcqonly,napwid,lsubtract,nagain,iaptype,mycall12,mygrid6, &
hiscall12,bcontest,sync,f1,xdt,xbase,apsym,nharderrors,dmin, &
nbadcrc,iappass,iera,msg37,xsnr)