Work in progress toward trying a Q65-style sync.

This commit is contained in:
Joe Taylor 2024-02-25 10:10:51 -05:00
parent b25e7fce8c
commit 4491da67f7
3 changed files with 40 additions and 52 deletions

View File

@ -4,43 +4,31 @@ subroutine sfox_gen(idat,f0,fsample,isync,cdat)
complex cdat(NMAX) !Generated complex waveform
complex w,wstep
integer idat(NN)
integer isync(50)
integer isync(44)
integer itone(171)
twopi=8.0*atan(1.0)
tsync=NS*NSPS/fsample
! Create the itone sequence: data symbols and interspersed sync symbols
j=1
k=0
do i=1,NDS
if(j.le.NS .and. i.eq.isync(min(j,NS))) then
j=j+1 !Index for next sync symbol
itone(i)=0 !Insert sync symbol at tone 0
else
k=k+1
itone(i)=idat(k) + 1 !Symbol value 0 is transmitted at tone 1, etc.
endif
enddo
df=fsample/NSPS
w=1.0
j=0
k=0
i0=NQ/2
! First group of data symbols:
do n=1,ND1
k=k+1
dphi=(f0 + (idat(k)-i0)*df)*(twopi/fsample)
wstep=cmplx(cos(dphi),sin(dphi))
do i=1,NSPS
j=j+1
w=w*wstep
cdat(j)=w
enddo
enddo
! Insert sync symbols
do n=1,NS
dphi=(f0 + (isync(n)-i0)*df)*(twopi/fsample)
wstep=cmplx(cos(dphi),sin(dphi))
do i=1,NSPS
j=j+1
w=w*wstep
cdat(j)=w
enddo
enddo
! Final group of data symbols:
do n=1,ND2
k=k+1
dphi=(f0 + (idat(k)-i0)*df)*(twopi/fsample)
! Generate the waveform
do k=1,NDS
dphi=(f0 + (itone(k)-i0)*df)*(twopi/fsample)
wstep=cmplx(cos(dphi),sin(dphi))
do i=1,NSPS
j=j+1

View File

@ -1,10 +1,10 @@
module sfox_mod
parameter (NMAX=15*12000) !Samples in iwave (180,000)
integer MM,NQ,NN,KK,ND1,ND2,NFZ,NSPS,NS,NSYNC,NZ,NFFT,NFFT1
integer MM,NQ,NN,KK,NS,NDS,NFZ,NSPS,NSYNC,NZ,NFFT,NFFT1
contains
subroutine sfox_init(mm0,nn0,kk0,itu,fspread,delay,fsample,ts)
subroutine sfox_init(mm0,nn0,kk0,itu,fspread,delay,fsample,ns0)
character*2 itu
integer isps(54)
@ -18,19 +18,17 @@ contains
MM=mm0 !Bits per symbol
NQ=2**MM !Q, number of MFSK tones
NN=nn0 !Number of channel symbols
KK=kk0 !Information symbols
ND1=25 !Data symbols before sync
ND2=NN-ND1 !Data symbols after sync
NN=nn0 !Codeword length
KK=kk0 !Number of information symbols
NS=ns0 !Number of sync symbols
NDS=NN+NS !Total number of channel symbols
NFZ=3 !First zero
jsps=nint((12.8-ts)*fsample/NN)
jsps=nint(12.8*fsample/NDS)
iloc=minloc(abs(isps-jsps))
NSPS=isps(iloc(1)) !Samples per symbol
NS=nint(ts*fsample/NSPS)
if(mod(NS,2).eq.1) NS=NS+1
NSYNC=NS*NSPS !Samples in sync waveform
NZ=NSPS*(NN+NS) !Samples in full Tx waveform
NZ=NSPS*NDS !Samples in full Tx waveform
NFFT=32768 !Length of FFT for sync waveform
NFFT1=2*NSPS !Length of FFTs for symbol spectra

View File

@ -10,7 +10,7 @@ program sfoxtest
type(hdr) h !Header for .wav file
integer*2 iwave(NMAX) !Generated i*2 waveform
integer param(0:8)
integer isync(50)
integer isync(44)
real*4 xnoise(NMAX) !Random noise
real*4 dat(NMAX) !Generated real data
complex cdat(NMAX) !Generated complex waveform
@ -31,21 +31,24 @@ program sfoxtest
logical hard_sync
character fname*17,arg*12,itu*2
! Shortcut: this is OK for NS <= 24 only
data isync(1:24)/ 21, 94, 55,125, 94, 29, 11, 64, 63, 6, &
59, 67, 52, 39,116, 98, 67, 68, 75, 87, &
116, 22,113,105/
data isync/ 1, 2, 5, 11, 19, 24, 26, 28, 29, 35, &
39, 48, 51, 53, 55, 56, 66, 71, 74, 78, &
80, 82, 84, 85, 92, 98, 103, 107, 109, 111, &
116, 122, 130, 131, 134, 136, 137, 140, 146, 154, &
159, 161, 163, 165/
nargs=iargc()
if(nargs.ne.11) then
print*,'Usage: sfoxtest f0 DT ITU M N K ts v hs nfiles snr'
print*,'Example: sfoxtest 1500 0.15 MM 7 127 48 3 0 F 10 -10'
print*,'Usage: sfoxtest f0 DT ITU M N K NS v hs nfiles snr'
print*,'Example: sfoxtest 1500 0.15 MM 7 127 48 33 0 F 10 -10'
print*,' f0=0 means f0, DT will assume suitable random values'
print*,' LQ: Low Latitude Quiet'
print*,' MM: Mid Latitude Moderate'
print*,' HD: High Latitude Disturbed'
print*,' ... and similarly for LM LD MQ MD HQ HM'
print*,' ts: approximate sync duration (s)'
print*,' NS: number of sync symbols'
print*,' v=1 for .wav files, 2 for verbose output, 3 for both'
print*,' hs = T for hard-wired sync'
print*,' snr=0 means loop over SNRs'
@ -63,7 +66,7 @@ program sfoxtest
call getarg(6,arg)
read(arg,*) kk0
call getarg(7,arg)
read(arg,*) ts
read(arg,*) ns0
call getarg(8,arg)
read(arg,*) nv
call getarg(9,arg)
@ -77,7 +80,7 @@ program sfoxtest
call timer('sfoxtest',0)
fsample=12000.0 !Sample rate (Hz)
call sfox_init(mm0,nn0,kk0,itu,fspread,delay,fsample,ts)
call sfox_init(mm0,nn0,kk0,itu,fspread,delay,fsample,ns0)
baud=fsample/NSPS
tsym=1.0/baud
bw=NQ*baud
@ -107,7 +110,6 @@ program sfoxtest
baud=fsample/nsps !Keying rate, 11.719 baud for nsps=1024
bandwidth_ratio=2500.0/fsample
fgood0=1.0
! isync(NS-3:NS)=NQ/2 !Set last few sync symbols to NQ/2
! Generate a message
msg0=0