Fix bugs for generating and decoding JT65 shorthand messages.

This commit is contained in:
Joe Taylor 2020-05-07 13:54:02 -04:00
parent fcf6b1f816
commit 5693be1ee1
2 changed files with 31 additions and 24 deletions

View File

@ -196,9 +196,11 @@ program jt65sim
if(msg(1:2).eq.'73') nshorthand=4 if(msg(1:2).eq.'73') nshorthand=4
if(nshorthand.gt.0) then if(nshorthand.gt.0) then
ntoggle=0 ntoggle=0
do i=1,nsym,2 do i=1,nsym,4
itone(i)=ntoggle*10*nshorthand itone(i)=ntoggle*10*nshorthand
if(i+1.le.126) itone(i+1)=ntoggle*10*nshorthand if(i+1.le.126) itone(i+1)=ntoggle*10*nshorthand
if(i+2.le.126) itone(i+2)=ntoggle*10*nshorthand
if(i+3.le.126) itone(i+3)=ntoggle*10*nshorthand
ntoggle=mod(ntoggle+1,2) ntoggle=mod(ntoggle+1,2)
enddo enddo
endif endif

View File

@ -1,20 +1,19 @@
subroutine sh65(cx,n5,mode65,ntol,xdf,nspecial,snrdb) subroutine sh65(cx,n5,mode65,ntol,xdf,nspecial,snrdb)
parameter(NFFT=2048,NH=NFFT/2,MAXSTEPS=150) parameter(NFFT=2048,NH=NFFT/2)
complex cx(90000) complex cx(n5) !Centered on nfqso, sample rate 1378.125
complex c(0:NFFT-1) complex c(0:NFFT-1)
real s(-NH+1:NH) real s(-NH+1:NH)
real s2(-NH+1:NH,MAXSTEPS) real ss(-NH+1:NH,16)
real ss(-NH+1:NH,8) real sigmax(16)
real sigmax(8) integer ipk(16)
integer ipk(8)
s=0.
ss=0. ss=0.
jstep=NFFT/4 jstep=NFFT/8
nblks=n5/jstep - 3 nblks=272
ia=-jstep+1 ia=-jstep+1
do iblk=1,nblks do iblk=1,nblks
n=mod(iblk-1,16) + 1
ia=ia+jstep ia=ia+jstep
ib=ia+NFFT-1 ib=ia+NFFT-1
c=cx(ia:ib) c=cx(ia:ib)
@ -22,34 +21,37 @@ subroutine sh65(cx,n5,mode65,ntol,xdf,nspecial,snrdb)
do i=0,NFFT-1 do i=0,NFFT-1
j=i j=i
if(j.gt.NH) j=j-NFFT if(j.gt.NH) j=j-NFFT
p=real(c(i))**2 + aimag(c(i))**2 ss(j,n)=ss(j,n) + real(c(i))**2 + aimag(c(i))**2
s(j)=s(j) + p
s2(j,iblk)=p
enddo enddo
n=mod(iblk-1,8) +1
ss(-NH+1:NH,n)=ss(-NH+1:NH,n) + s2(-NH+1:NH,iblk)
enddo enddo
s=1.e-6*s s=1.e-5*s
ss=1.e-6*ss ss=1.e-5*ss
df=1378.1285/NFFT df=1378.1285/NFFT
nfac=40*mode65 nfac=40*mode65
dtstep=0.25/df dtstep=0.25/df
! Define range of frequencies to be searched do i=1,2*mode65
call smo121(ss,16*NFFT)
enddo
! do i=-NH+1,NH
! write(72,3072) i*df,(ss(i,j),j=1,16)
!3072 format(17f7.1)
! enddo
! Define freq range to be searched. Upper tone is at sync freq + 4*nfac*df Hz
fa=-ntol fa=-ntol
fb=ntol fb=ntol
ia2=max(-NH+1,nint(fa/df)) ia2=max(-NH+1,nint(fa/df))
! Upper tone is above sync tone by 4*nfac*df Hz
ib2=min(NH,nint(fb/df + 4.1*nfac)) ib2=min(NH,nint(fb/df + 4.1*nfac))
! Find strongest line in each of the 4 phases, repeating for each drift rate. ! Find strongest line in each of the 16 phases
sbest=0. sbest=0.
snrbest=0. snrbest=0.
nbest=1 nbest=1
ipk=0 ipk=0
do n=1,16
do n=1,8
sigmax(n)=0. sigmax(n)=0.
do i=ia2,ib2 do i=ia2,ib2
sig=ss(i,n) sig=ss(i,n)
@ -63,8 +65,8 @@ subroutine sh65(cx,n5,mode65,ntol,xdf,nspecial,snrdb)
endif endif
enddo enddo
enddo enddo
n2best=nbest+4 n2best=nbest+8
if(n2best.gt.8) n2best=nbest-4 if(n2best.gt.16) n2best=nbest-8
xdf=min(ipk(nbest),ipk(n2best))*df xdf=min(ipk(nbest),ipk(n2best))*df
nspecial=0 nspecial=0
if(abs(xdf).le.ntol) then if(abs(xdf).le.ntol) then
@ -74,6 +76,9 @@ subroutine sh65(cx,n5,mode65,ntol,xdf,nspecial,snrdb)
iderr=nint((xk-k)*nfac) iderr=nint((xk-k)*nfac)
! maxerr=nint(0.008*abs(idiff) + 0.51) ! maxerr=nint(0.008*abs(idiff) + 0.51)
maxerr=nint(0.02*abs(idiff) + 0.51) !### Better test ??? ### maxerr=nint(0.02*abs(idiff) + 0.51) !### Better test ??? ###
! write(71,3001) nbest,n2best,idiff,iderr,maxerr,k, &
! ipk(nbest)*df,ipk(n2best)*df,sbest
!3001 format(6i4,2f7.1,f7.2)
if(abs(iderr).le.maxerr .and. k.ge.2 .and. k.le.4) nspecial=k if(abs(iderr).le.maxerr .and. k.ge.2 .and. k.le.4) nspecial=k
snrdb=-30.0 snrdb=-30.0
if(nspecial.gt.0) then if(nspecial.gt.0) then