mirror of
https://github.com/saitohirga/WSJT-X.git
synced 2025-05-24 10:22:26 -04:00
Separate generation of SuperFox sync LO, and rationalize frequencies used in gen_sfox.f90 and hard_symbols.f90.
This commit is contained in:
parent
6310419a4d
commit
c24a0d3c72
@ -590,6 +590,7 @@ set (wsjt_FSRCS
|
|||||||
lib/superfox/gen_sfox.f90
|
lib/superfox/gen_sfox.f90
|
||||||
lib/superfox/sync_sf.f90
|
lib/superfox/sync_sf.f90
|
||||||
lib/superfox/hard_symbols.f90
|
lib/superfox/hard_symbols.f90
|
||||||
|
lib/superfox/gen_sf_clo.f90
|
||||||
lib/superfox/ran1.f90
|
lib/superfox/ran1.f90
|
||||||
)
|
)
|
||||||
|
|
||||||
|
26
lib/superfox/gen_sf_clo.f90
Normal file
26
lib/superfox/gen_sf_clo.f90
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
subroutine gen_sf_clo(fsample,syncwidth,clo)
|
||||||
|
|
||||||
|
! Generate complex LO for the SuperFox sync signal
|
||||||
|
|
||||||
|
use sfox_mod
|
||||||
|
complex clo(NMAX) !Complex Local Oscillator
|
||||||
|
complex w,wstep
|
||||||
|
|
||||||
|
twopi=8.0*atan(1.0)
|
||||||
|
tsync=NS*NSPS/fsample
|
||||||
|
w=1.0
|
||||||
|
a0=1500.0+ syncwidth/2.0 !Frequency at midpoint of LO waveform
|
||||||
|
a2=2.0*syncwidth/tsync !Frequency drift rate
|
||||||
|
x0=0.5*(nsync+1)
|
||||||
|
s=2.0/nsync
|
||||||
|
do i=1,nsync
|
||||||
|
if(i.eq.nsync/2+1) a2=-a2 !Reverse sign of drift at midpoint
|
||||||
|
x=s*(i-x0)
|
||||||
|
dphi=(a0 + x*a2)*(twopi/fsample)
|
||||||
|
wstep=cmplx(cos(dphi),sin(dphi))
|
||||||
|
w=w*wstep
|
||||||
|
clo(i)=conjg(w)
|
||||||
|
enddo
|
||||||
|
|
||||||
|
return
|
||||||
|
end subroutine gen_sf_clo
|
@ -1,39 +1,22 @@
|
|||||||
subroutine gen_sfox(idat,f0,fsample,syncwidth,cdat,clo)
|
subroutine gen_sfox(idat,f0,fsample,syncwidth,cdat)
|
||||||
|
|
||||||
use sfox_mod
|
use sfox_mod
|
||||||
! include "sfox_params.f90"
|
! include "sfox_params.f90"
|
||||||
complex cdat(NMAX) !Generated complex waveform
|
complex cdat(NMAX) !Generated complex waveform
|
||||||
complex clo(NMAX) !Complex Local Oscillator
|
|
||||||
complex w,wstep
|
complex w,wstep
|
||||||
integer idat(ND)
|
integer idat(ND)
|
||||||
|
|
||||||
twopi=8.0*atan(1.0)
|
twopi=8.0*atan(1.0)
|
||||||
tsync=NS*NSPS/fsample
|
tsync=NS*NSPS/fsample
|
||||||
|
|
||||||
! Generate complex LO for SuperFox sync
|
|
||||||
w=1.0
|
|
||||||
a0=1500.0+ syncwidth/2.0 !Frequency at midpoint of LO waveform
|
|
||||||
a2=2.0*syncwidth/tsync !Frequency drift rate
|
|
||||||
x0=0.5*(nsync+1)
|
|
||||||
s=2.0/nsync
|
|
||||||
do i=1,nsync
|
|
||||||
if(i.eq.nsync/2+1) a2=-a2 !Reverse sign of drift at midpoint
|
|
||||||
x=s*(i-x0)
|
|
||||||
dphi=(a0 + x*a2)*(twopi/fsample)
|
|
||||||
wstep=cmplx(cos(dphi),sin(dphi))
|
|
||||||
w=w*wstep
|
|
||||||
clo(i)=conjg(w)
|
|
||||||
enddo
|
|
||||||
|
|
||||||
! Generate complex SuperFox waveform
|
|
||||||
|
|
||||||
df=fsample/NSPS
|
df=fsample/NSPS
|
||||||
|
w=1.0
|
||||||
j=0
|
j=0
|
||||||
k=0
|
k=0
|
||||||
|
i0=NQ/2
|
||||||
! First group of data symbols:
|
! First group of data symbols:
|
||||||
do n=1,ND1
|
do n=1,ND1
|
||||||
k=k+1
|
k=k+1
|
||||||
dphi=(f0 + (idat(k)-65)*df)*(twopi/fsample)
|
dphi=(f0 + (idat(k)-i0)*df)*(twopi/fsample)
|
||||||
wstep=cmplx(cos(dphi),sin(dphi))
|
wstep=cmplx(cos(dphi),sin(dphi))
|
||||||
do i=1,NSPS
|
do i=1,NSPS
|
||||||
j=j+1
|
j=j+1
|
||||||
@ -45,6 +28,8 @@ subroutine gen_sfox(idat,f0,fsample,syncwidth,cdat,clo)
|
|||||||
! Sync waveform
|
! Sync waveform
|
||||||
a1=f0 + syncwidth/2.0 !Frequency at midpoint of sync waveform
|
a1=f0 + syncwidth/2.0 !Frequency at midpoint of sync waveform
|
||||||
a2=2.0*syncwidth/tsync !Frequency drift rate
|
a2=2.0*syncwidth/tsync !Frequency drift rate
|
||||||
|
x0=0.5*(nsync+1)
|
||||||
|
s=2.0/nsync
|
||||||
do i=1,nsync
|
do i=1,nsync
|
||||||
j=j+1
|
j=j+1
|
||||||
if(i.eq.nsync/2+1) a2=-a2 !Reverse sign of drift at midpoint
|
if(i.eq.nsync/2+1) a2=-a2 !Reverse sign of drift at midpoint
|
||||||
@ -58,7 +43,7 @@ subroutine gen_sfox(idat,f0,fsample,syncwidth,cdat,clo)
|
|||||||
! Final group of data symbols:
|
! Final group of data symbols:
|
||||||
do n=1,ND2
|
do n=1,ND2
|
||||||
k=k+1
|
k=k+1
|
||||||
dphi=(f0 + (idat(k)-65)*df)*(twopi/fsample)
|
dphi=(f0 + (idat(k)-i0)*df)*(twopi/fsample)
|
||||||
wstep=cmplx(cos(dphi),sin(dphi))
|
wstep=cmplx(cos(dphi),sin(dphi))
|
||||||
do i=1,NSPS
|
do i=1,NSPS
|
||||||
j=j+1
|
j=j+1
|
||||||
|
@ -1,16 +1,16 @@
|
|||||||
subroutine hard_symbols(crcvd,f,t,jdat)
|
subroutine hard_symbols(crcvd,f,t,chansym)
|
||||||
|
|
||||||
use sfox_mod
|
use sfox_mod
|
||||||
! include "sfox_params.f90"
|
! include "sfox_params.f90"
|
||||||
complex crcvd(NMAX) !Signal as received
|
complex crcvd(NMAX) !Signal as received
|
||||||
complex c(0:NSPS-1) !Work array, one symbol long
|
complex c(0:NSPS-1) !Work array, one symbol long
|
||||||
real s(0:NSPS-1) !Power spectrum
|
real s(0:NQ-1) !Power spectrum
|
||||||
integer jdat(NN) !Recovered hard-decision symbols
|
integer chansym(NN) !Recovered hard-decision symbols
|
||||||
integer ipk(1)
|
integer ipk(1)
|
||||||
|
|
||||||
i0=nint(12000.0*t)
|
i0=nint(12000.0*t)
|
||||||
df=12000.0/NSPS
|
df=12000.0/NSPS
|
||||||
j0=nint(f/df)-128
|
j0=nint(f/df)-NQ/2
|
||||||
do n=1,ND !Loop over all symbols
|
do n=1,ND !Loop over all symbols
|
||||||
ib=n*NSPS + i0
|
ib=n*NSPS + i0
|
||||||
if(n.gt.ND1) ib=(NS+n)*NSPS + i0
|
if(n.gt.ND1) ib=(NS+n)*NSPS + i0
|
||||||
@ -18,8 +18,8 @@ subroutine hard_symbols(crcvd,f,t,jdat)
|
|||||||
if(ia.lt.1 .or. ib.gt.NMAX) cycle
|
if(ia.lt.1 .or. ib.gt.NMAX) cycle
|
||||||
c=crcvd(ia:ib)
|
c=crcvd(ia:ib)
|
||||||
call four2a(c,NSPS,1,-1,1) !Compute symbol spectrum
|
call four2a(c,NSPS,1,-1,1) !Compute symbol spectrum
|
||||||
do i=0,NSPS-1
|
do j=0,NQ-1
|
||||||
s(i)=real(c(i))**2 + aimag(c(i))**2
|
s(j)=real(c(j0+j))**2 + aimag(c(j0+j))**2
|
||||||
enddo
|
enddo
|
||||||
|
|
||||||
! Could we measure fspread, perhaps in the sync routine, and use that to
|
! Could we measure fspread, perhaps in the sync routine, and use that to
|
||||||
@ -27,13 +27,8 @@ subroutine hard_symbols(crcvd,f,t,jdat)
|
|||||||
! call smo121(s,NSPS) !Helps for LD, HM propagation...
|
! call smo121(s,NSPS) !Helps for LD, HM propagation...
|
||||||
! call smo121(s,NSPS)
|
! call smo121(s,NSPS)
|
||||||
|
|
||||||
ipk=maxloc(s)
|
ipk=maxloc(s(0:NQ-1))
|
||||||
ipk(1)=ipk(1)-j0
|
chansym(n)=ipk(1) - 1
|
||||||
if(ipk(1).ge.64) then
|
|
||||||
jdat(n)=ipk(1)-64
|
|
||||||
else
|
|
||||||
jdat(n)=ipk(1)+256-64
|
|
||||||
endif
|
|
||||||
enddo
|
enddo
|
||||||
|
|
||||||
return
|
return
|
||||||
|
@ -80,11 +80,15 @@ program sfoxtest
|
|||||||
h=default_header(12000,NMAX)
|
h=default_header(12000,NMAX)
|
||||||
idummy=0
|
idummy=0
|
||||||
bandwidth_ratio=2500.0/6000.0
|
bandwidth_ratio=2500.0/6000.0
|
||||||
|
fgood0=1.0
|
||||||
|
|
||||||
! Generate a message
|
! Generate a message
|
||||||
msg0=0
|
msg0=0
|
||||||
do i=1,KK-2
|
do i=1,KK-2
|
||||||
msg0(i)=i
|
! msg0(i)=i-1
|
||||||
|
msg0(i)=int(NQ*ran1(idummy))
|
||||||
|
! msg0(i)=0
|
||||||
|
! if(i.gt.ND1) msg0(i)=NQ-1
|
||||||
enddo
|
enddo
|
||||||
! Append a CRC here ...
|
! Append a CRC here ...
|
||||||
|
|
||||||
@ -92,10 +96,12 @@ program sfoxtest
|
|||||||
call rs_encode_sf(msg0,parsym) !Compute parity symbols
|
call rs_encode_sf(msg0,parsym) !Compute parity symbols
|
||||||
chansym0(1:kk)=msg0(1:kk)
|
chansym0(1:kk)=msg0(1:kk)
|
||||||
chansym0(kk+1:nn)=parsym(1:nn-kk)
|
chansym0(kk+1:nn)=parsym(1:nn-kk)
|
||||||
fgood0=1.0
|
|
||||||
|
|
||||||
! Generate cdat (SuperFox waveform) and clo (LO for sync detection)
|
! Generate clo, the LO for sync detection
|
||||||
call gen_sfox(chansym0,f0,fsample,syncwidth,cdat,clo)
|
call gen_sf_clo(fsample,syncwidth,clo)
|
||||||
|
|
||||||
|
! Generate cdat, the SuperFox waveform
|
||||||
|
call gen_sfox(chansym0,f0,fsample,syncwidth,cdat)
|
||||||
|
|
||||||
do isnr=0,-20,-1
|
do isnr=0,-20,-1
|
||||||
snr=isnr
|
snr=isnr
|
||||||
@ -154,6 +160,7 @@ program sfoxtest
|
|||||||
call twkfreq(crcvd,crcvd,NMAX,12000.0,a)
|
call twkfreq(crcvd,crcvd,NMAX,12000.0,a)
|
||||||
f=1500.0
|
f=1500.0
|
||||||
call hard_symbols(crcvd,f,t,chansym) !Get hard symbol values
|
call hard_symbols(crcvd,f,t,chansym) !Get hard symbol values
|
||||||
|
|
||||||
nera=0
|
nera=0
|
||||||
chansym=mod(chansym,nq) !Enforce 0 to nq-1
|
chansym=mod(chansym,nq) !Enforce 0 to nq-1
|
||||||
nharderr=count(chansym.ne.chansym0) !Count hard errors
|
nharderr=count(chansym.ne.chansym0) !Count hard errors
|
||||||
|
Loading…
x
Reference in New Issue
Block a user