Merge branch 'feat-ft2' of bitbucket.org:k1jt/wsjtx into feat-ft2

This commit is contained in:
Joe Taylor 2019-01-18 16:23:19 -05:00
commit 486440beb4
5 changed files with 138 additions and 31 deletions

View File

@ -469,6 +469,7 @@ set (wsjt_FSRCS
lib/geodist.f90 lib/geodist.f90
lib/getlags.f90 lib/getlags.f90
lib/getmet4.f90 lib/getmet4.f90
lib/ft2/gfsk_pulse.f90
lib/graycode.f90 lib/graycode.f90
lib/graycode65.f90 lib/graycode65.f90
lib/grayline.f90 lib/grayline.f90

View File

@ -93,7 +93,7 @@ program ft2d
ibest=-1 ibest=-1
sybest=-99. sybest=-99.
dfbest=-1. dfbest=-1.
do if=-15,+15 do if=-30,+30
df=if df=if
a=0. a=0.
a(1)=-df a(1)=-df
@ -120,8 +120,6 @@ program ft2d
enddo enddo
enddo enddo
!dfbest=0.0
!ibest=187
a=0. a=0.
a(1)=-dfbest a(1)=-dfbest
call twkfreq1(c2,NMAX/16,fs,a,cb) call twkfreq1(c2,NMAX/16,fs,a,cb)
@ -197,7 +195,6 @@ program ft2d
call bpdecode128_90(llr2,apmask,max_iterations,message77,cw,nharderror,niterations) call bpdecode128_90(llr2,apmask,max_iterations,message77,cw,nharderror,niterations)
if(nharderror.ge.0) exit if(nharderror.ge.0) exit
enddo enddo
nhardmin=-1
if(sum(message77).eq.0) cycle if(sum(message77).eq.0) cycle
if( nharderror.ge.0 ) then if( nharderror.ge.0 ) then
write(c77,'(77i1)') message77(1:77) write(c77,'(77i1)') message77(1:77)
@ -212,8 +209,8 @@ program ft2d
nsnr=nint(xsnr) nsnr=nint(xsnr)
freq=f0+dfbest freq=f0+dfbest
1210 format(a11,2i4,f6.2,f12.7,2x,a22,i3) 1210 format(a11,2i4,f6.2,f12.7,2x,a22,i3)
write(*,1212) datetime(8:11),nsnr,ibest/750.0,freq,message,'*',idf,nseq,ijitter,nharderror,nhardmin write(*,1212) datetime(8:11),nsnr,ibest/750.0,freq,message,'*',nseq,nharderror
1212 format(a4,i4,f5.1,f11.1,2x,a22,a1,i5,i5,i5,i5,i5) 1212 format(a4,i4,f5.1,f11.1,2x,a22,a1,i5,i5)
goto 888 goto 888
endif endif
enddo ! nseq enddo ! nseq

View File

@ -13,6 +13,8 @@ program ft2sim
complex c0(0:NMAX-1) complex c0(0:NMAX-1)
complex c(0:NMAX-1) complex c(0:NMAX-1)
real wave(NMAX) real wave(NMAX)
real dphi(0:NMAX-1)
real pulse(480)
integer itone(NN) integer itone(NN)
integer*1 msgbits(77) integer*1 msgbits(77)
integer*2 iwave(NMAX) !Generated full-length waveform integer*2 iwave(NMAX) !Generated full-length waveform
@ -42,12 +44,6 @@ program ft2sim
call getarg(8,arg) call getarg(8,arg)
read(arg,*) snrdb !SNR_2500 read(arg,*) snrdb !SNR_2500
nsig=1
if(f0.lt.100.0) then
nsig=f0
f0=1500
endif
nfiles=abs(nfiles) nfiles=abs(nfiles)
twopi=8.0*atan(1.0) twopi=8.0*atan(1.0)
fs=12000.0 !Sample rate (Hz) fs=12000.0 !Sample rate (Hz)
@ -55,8 +51,8 @@ program ft2sim
hmod=0.8 !Modulation index (0.5 is MSK, 1.0 is FSK) hmod=0.8 !Modulation index (0.5 is MSK, 1.0 is FSK)
tt=NSPS*dt !Duration of symbols (s) tt=NSPS*dt !Duration of symbols (s)
baud=1.0/tt !Keying rate (baud) baud=1.0/tt !Keying rate (baud)
bw=1.5*baud !Occupied bandwidth (Hz)
txt=NZ*dt !Transmission length (s) txt=NZ*dt !Transmission length (s)
bandwidth_ratio=2500.0/(fs/2.0) bandwidth_ratio=2500.0/(fs/2.0)
sig=sqrt(2*bandwidth_ratio) * 10.0**(0.05*snrdb) sig=sqrt(2*bandwidth_ratio) * 10.0**(0.05*snrdb)
if(snrdb.gt.90.0) sig=1.0 if(snrdb.gt.90.0) sig=1.0
@ -70,9 +66,8 @@ program ft2sim
call genft2(msg37,0,msgsent37,itone,itype) call genft2(msg37,0,msgsent37,itone,itype)
write(*,*) write(*,*)
write(*,'(a9,a37,3x,a7,i1,a1,i1)') 'Message: ',msgsent37,'i3.n3: ',i3,'.',n3 write(*,'(a9,a37,3x,a7,i1,a1,i1)') 'Message: ',msgsent37,'i3.n3: ',i3,'.',n3
write(*,1000) f0,xdt,txt,snrdb,bw write(*,1000) f0,xdt,txt,snrdb
1000 format('f0:',f9.3,' DT:',f6.2,' TxT:',f6.1,' SNR:',f6.1, & 1000 format('f0:',f9.3,' DT:',f6.2,' TxT:',f6.1,' SNR:',f6.1)
' BW:',f5.1)
write(*,*) write(*,*)
if(i3.eq.1) then if(i3.eq.1) then
write(*,*) ' mycall hiscall hisgrid' write(*,*) ' mycall hiscall hisgrid'
@ -88,21 +83,41 @@ program ft2sim
call sgran() call sgran()
! The filtered frequency pulse
do i=1,480
tt=(i-240.5)/160.0
pulse(i)=gfsk_pulse(1.0,tt)
enddo
! Define the instantaneous frequency waveform
dphi_peak=twopi*(hmod/2.0)/real(NSPS)
dphi=0.0
do j=1,NN
ib=(j-1)*160
ie=ib+480-1
dphi(ib:ie)=dphi(ib:ie)+dphi_peak*pulse*(2*itone(j)-1)
enddo
phi=0.0
c0=0.0
dphi=dphi+twopi*f0*dt
do j=0,NMAX-1
c0(j)=cmplx(cos(phi),sin(phi))
phi=mod(phi+dphi(j),twopi)
enddo
c0(0:159)=c0(0:159)*(1.0-cos(twopi*(/(i,i=0,159)/)/320.0) )/2.0
c0(145*160:145*160+159)=c0(145*160:145*160+159)*(1.0+cos(twopi*(/(i,i=0,159)/)/320.0 ))/2.0
c0(146*160:)=0.
k=nint((xdt+0.25)/dt)
c0=cshift(c0,-k)
ia=k
do ifile=1,nfiles do ifile=1,nfiles
k=nint((xdt+0.25)/dt) c=c0
ia=k if(fspread.ne.0.0 .or. delay.ne.0.0) call watterson(c,NMAX,NWAVE,fs,delay,fspread)
phi=0.0 c=sig*c
c0=0.0
do j=1,NN !Generate complex waveform
dphi=twopi*(f0*dt+(hmod/2.0)*(2*itone(j)-1)/real(NSPS))
do i=1,NSPS
if(k.ge.0 .and. k.lt.NMAX) c0(k)=cmplx(cos(phi),sin(phi))
k=k+1
phi=mod(phi+dphi,twopi)
enddo
enddo
if(fspread.ne.0.0 .or. delay.ne.0.0) call watterson(c0,NMAX,NWAVE,fs,delay,fspread)
c=sig*c0
ib=k ib=k
wave=real(c) wave=real(c)

View File

@ -0,0 +1,88 @@
subroutine ft2_gfsk_iwave(msg37,f0,snrdb,iwave)
! Generate waveform for experimental "FT2" mode
use packjt77
include 'ft2_params.f90' !Set various constants
parameter (NWAVE=(NN+2)*NSPS)
character msg37*37,msgsent37*37
real wave(NWAVE),xnoise(NWAVE)
real dphi(NWAVE)
real pulse(480)
integer itone(NN)
integer*2 iwave(NWAVE) !Generated full-length waveform
logical first
data first/.true./
save pulse
twopi=8.0*atan(1.0)
fs=12000.0 !Sample rate (Hz)
dt=1.0/fs !Sample interval (s)
hmod=0.8 !Modulation index (MSK=0.5, FSK=1.0)
tt=NSPS*dt !Duration of symbols (s)
baud=1.0/tt !Keying rate (baud)
bw=1.5*baud !Occupied bandwidth (Hz)
txt=NZ*dt !Transmission length (s)
bandwidth_ratio=2500.0/(fs/2.0)
! sig=sqrt(2*bandwidth_ratio) * 10.0**(0.05*snrdb)
! if(snrdb.gt.90.0) sig=1.0
txt=NN*NSPS/12000.0
if(first) then
! The filtered frequency pulse
do i=1,480
tt=(i-240.5)/160.0
pulse(i)=gfsk_pulse(1.0,tt)
enddo
dphi_peak=twopi*(hmod/2.0)/real(NSPS)
first=.false.
endif
! Source-encode, then get itone():
itype=1
call genft2(msg37,0,msgsent37,itone,itype)
! Create the instantaneous frequency waveform
dphi=0.0
do j=1,NN
ib=(j-1)*160+1
ie=ib+480-1
dphi(ib:ie)=dphi(ib:ie)+dphi_peak*pulse*(2*itone(j)-1)
enddo
phi=0.0
wave=0.0
sqrt2=sqrt(2.)
dphi=dphi+twopi*f0*dt
do j=1,NWAVE
wave(j)=sqrt2*sin(phi)
sqsig=sqsig + wave(j)**2
phi=mod(phi+dphi(j),twopi)
enddo
wave(1:160)=wave(1:160)*(1.0-cos(twopi*(/(i,i=0,159)/)/320.0) )/2.0
wave(145*160+1:146*160)=wave(145*160+1:146*160)*(1.0+cos(twopi*(/(i,i=0,159)/)/320.0 ))/2.0
wave(146*160+1:)=0.
if(snrdb.gt.90.0) then
iwave=nint((32767.0/sqrt(2.0))*wave)
return
endif
sqnoise=1.e-30
if(snrdb.lt.90) then
do i=1,NWAVE !Add gaussian noise at specified SNR
xnoise(i)=gran() !Noise has rms = 1.0
enddo
endif
xnoise=xnoise*sqrt(0.5*fs/2500.0)
fac=30.0
snr_amplitude=10.0**(0.05*snrdb)
wave=fac*(snr_amplitude*wave + xnoise)
datpk=maxval(abs(wave))
print*,'A',snr_amplitude,datpk
iwave=nint((30000.0/datpk)*wave)
return
end subroutine ft2_gfsk_iwave

6
lib/ft2/gfsk_pulse.f90 Normal file
View File

@ -0,0 +1,6 @@
real function gfsk_pulse(b,t)
pi=4.*atan(1.0)
c=pi*sqrt(2.0/log(2.0))
gfsk_pulse=0.5*(erf(c*b*(t+0.5))-erf(c*b*(t-0.5)))
return
end function gfsk_pulse