Updates and additions to wsprcpm files.

This commit is contained in:
Steven Franke 2020-04-03 10:27:43 -05:00
parent 3f7b06853e
commit cf5a69d25b
5 changed files with 694 additions and 653 deletions

View File

@ -596,6 +596,13 @@ set (wsjt_FSRCS
lib/wqencode.f90 lib/wqencode.f90
lib/wspr_downsample.f90 lib/wspr_downsample.f90
lib/zplot9.f90 lib/zplot9.f90
lib/fsk4hf/wsprcpmsim.f90
lib/fsk4hf/wsprcpm_wav.f90
lib/fsk4hf/wsprcpmd.f90
lib/fsk4hf/bpdecode204.f90
lib/fsk4hf/osd204.f90
lib/fsk4hf/genwsprcpm.f90
lib/fsk4hf/encode204.f90
) )
# temporary workaround for a gfortran v7.3 ICE on Fedora 27 64-bit # temporary workaround for a gfortran v7.3 ICE on Fedora 27 64-bit
@ -1327,6 +1334,12 @@ target_link_libraries (ft4sim_mult wsjt_fort wsjt_cxx)
add_executable (record_time_signal Audio/tools/record_time_signal.cpp) add_executable (record_time_signal Audio/tools/record_time_signal.cpp)
target_link_libraries (record_time_signal wsjt_cxx wsjt_qtmm wsjt_qt) target_link_libraries (record_time_signal wsjt_cxx wsjt_qtmm wsjt_qt)
add_executable (wsprcpmsim lib/fsk4hf/wsprcpmsim.f90 wsjtx.rc)
target_link_libraries (wsprcpmsim wsjt_fort wsjt_cxx)
add_executable (wsprcpmd lib/fsk4hf/wsprcpmd.f90 wsjtx.rc)
target_link_libraries (wsprcpmd wsjt_fort wsjt_cxx)
endif(WSJT_BUILD_UTILS) endif(WSJT_BUILD_UTILS)
# build the main application # build the main application

View File

@ -2,69 +2,69 @@ subroutine genwsprcpm(msg,msgsent,itone)
! Encode a WSPRCPM message, producing array itone(). ! Encode a WSPRCPM message, producing array itone().
! !
use crc use crc
include 'wsprcpm_params.f90' include 'wsprcpm_params.f90'
character*22 msg,msgsent character*22 msg,msgsent
character*64 cbits character*64 cbits
character*32 sbits character*32 sbits
integer iuniqueword0 integer iuniqueword0
integer*1,target :: idat(9) integer*1,target :: idat(9)
integer*1 msgbits(68),codeword(ND) integer*1 msgbits(68),codeword(ND)
logical first logical first
integer icw(ND) integer icw(ND)
integer id(NS+ND) integer id(NS+ND)
integer jd(NS+ND) integer jd(NS+ND)
integer ipreamble(16) !Freq estimation preamble integer ipreamble(16) !Freq estimation preamble
integer isync(200) !Long sync vector integer isync(200) !Long sync vector
integer itone(NN) integer itone(NN)
data ipreamble/1,1,1,1,0,0,0,0,0,0,0,0,1,1,1,1/ data ipreamble/1,1,1,1,0,0,0,0,0,0,0,0,1,1,1,1/
data first/.true./ data first/.true./
data iuniqueword0/z'30C9E8AD'/ data iuniqueword0/z'30C9E8AD'/
save first,isync,ipreamble save first,isync,ipreamble
if(first) then if(first) then
write(sbits,'(b32.32)') iuniqueword0 write(sbits,'(b32.32)') iuniqueword0
read(sbits,'(32i1)') isync(1:32) read(sbits,'(32i1)') isync(1:32)
read(sbits,'(32i1)') isync(33:64) read(sbits,'(32i1)') isync(33:64)
read(sbits,'(32i1)') isync(65:96) read(sbits,'(32i1)') isync(65:96)
read(sbits,'(32i1)') isync(97:128) read(sbits,'(32i1)') isync(97:128)
read(sbits,'(32i1)') isync(129:160) read(sbits,'(32i1)') isync(129:160)
read(sbits,'(32i1)') isync(161:192) read(sbits,'(32i1)') isync(161:192)
read(sbits,'(8i1)') isync(193:200) read(sbits,'(8i1)') isync(193:200)
first=.false. first=.false.
endif endif
idat=0 idat=0
call wqencode(msg,ntype0,idat) !Source encoding call wqencode(msg,ntype0,idat) !Source encoding
id7=idat(7) id7=idat(7)
if(id7.lt.0) id7=id7+256 if(id7.lt.0) id7=id7+256
id7=id7/64 id7=id7/64
write(*,*) 'idat ',idat write(*,*) 'idat ',idat
icrc=crc14(c_loc(idat),9) icrc=crc14(c_loc(idat),9)
write(*,*) 'icrc: ',icrc write(*,*) 'icrc: ',icrc
write(*,'(a6,b16.16)') 'icrc: ',icrc write(*,'(a6,b16.16)') 'icrc: ',icrc
call wqdecode(idat,msgsent,itype) call wqdecode(idat,msgsent,itype)
print*,msgsent,itype print*,msgsent,itype
write(cbits,1004) idat(1:6),id7,iand(icrc,z'3FFF') write(cbits,1004) idat(1:6),id7,iand(icrc,z'3FFF')
1004 format(6b8.8,b2.2,b14.14) 1004 format(6b8.8,b2.2,b14.14)
msgbits=0 msgbits=0
read(cbits,1006) msgbits(1:64) read(cbits,1006) msgbits(1:64)
1006 format(64i1) 1006 format(64i1)
write(*,'(50i1,1x,14i1,1x,4i1)') msgbits write(*,'(50i1,1x,14i1,1x,4i1)') msgbits
call encode204(msgbits,codeword) !Encode the test message call encode204(msgbits,codeword) !Encode the test message
! Message structure: ! Message structure:
! d100 p16 d100 ! d100 p16 d100
itone(1:100)=isync(1:100)+2*codeword(1:100) itone(1:100)=isync(1:100)+2*codeword(1:100)
itone(101:116)=ipreamble+1 itone(101:116)=ipreamble+1
itone(117:216)=isync(101:200)+2*codeword(101:200) itone(117:216)=isync(101:200)+2*codeword(101:200)
itone=2*itone-3 itone=2*itone-3
do i=1,216 do i=1,216
write(*,*) i,itone(i) write(*,*) i,itone(i)
enddo enddo
return return
end subroutine genwsprcpm end subroutine genwsprcpm

View File

@ -2,43 +2,43 @@ subroutine wsprcpm_wav(baud,xdt,h,f0,itone,snrdb,iwave)
! Generate iwave() from itone(). ! Generate iwave() from itone().
include 'wsprcpm_params.f90' include 'wsprcpm_params.f90'
parameter (NMAX=120*12000) parameter (NMAX=120*12000)
integer itone(NN) integer itone(NN)
integer*2 iwave(NMAX) integer*2 iwave(NMAX)
real*8 twopi,dt,dphi0,dphi1,dphi,phi real*8 twopi,dt,dphi0,dphi1,dphi,phi
real dat(NMAX) real dat(NMAX)
twopi=8.d0*atan(1.d0) twopi=8.d0*atan(1.d0)
dt=1.d0/12000.d0 dt=1.d0/12000.d0
dat=0. dat=0.
if(snrdb.lt.90) then if(snrdb.lt.90) then
do i=1,NMAX do i=1,NMAX
dat(i)=gran() !Generate gaussian noise dat(i)=gran() !Generate gaussian noise
enddo enddo
bandwidth_ratio=2500.0/6000.0 bandwidth_ratio=2500.0/6000.0
sig=sqrt(2*bandwidth_ratio)*10.0**(0.05*snrdb) sig=sqrt(2*bandwidth_ratio)*10.0**(0.05*snrdb)
else else
sig=1.0 sig=1.0
endif endif
phi=0.d0 phi=0.d0
k=nint(xdt/dt) k=nint(xdt/dt)
do j=1,NN do j=1,NN
dphi=twopi*(f0+itone(j)*(h/2.0d0)*baud)*dt dphi=twopi*(f0+itone(j)*(h/2.0d0)*baud)*dt
do i=1,NSPS0 do i=1,NSPS0
k=k+1 k=k+1
phi=phi+dphi phi=phi+dphi
if(phi.gt.twopi) phi=phi-twopi if(phi.gt.twopi) phi=phi-twopi
xphi=phi xphi=phi
if(k.gt.0 .and. k.le.NMAX) dat(k)=dat(k) + sig*sin(xphi) if(k.gt.0 .and. k.le.NMAX) dat(k)=dat(k) + sig*sin(xphi)
enddo enddo
enddo enddo
fac=32767.0 fac=32767.0
rms=100.0 rms=100.0
if(snrdb.ge.90.0) iwave=nint(fac*dat) if(snrdb.ge.90.0) iwave=nint(fac*dat)
if(snrdb.lt.90.0) iwave=nint(rms*dat) if(snrdb.lt.90.0) iwave=nint(rms*dat)
return return
end subroutine wsprcpm_wav end subroutine wsprcpm_wav

File diff suppressed because it is too large Load Diff

View File

@ -3,107 +3,104 @@ program wsprcpmsim
! Generate simulated data for a 2-minute "WSPR-LF" mode. Output is saved ! Generate simulated data for a 2-minute "WSPR-LF" mode. Output is saved
! to a *.c2 or *.wav file. ! to a *.c2 or *.wav file.
use wavhdr use wavhdr
include 'wsprcpm_params.f90' !Set various constants include 'wsprcpm_params.f90' !Set various constants
parameter (NMAX=120*12000) parameter (NMAX=120*12000)
type(hdr) hwav !Header for .wav file type(hdr) hwav !Header for .wav file
character arg*12,fname*16 character arg*12,fname*16
character msg*22,msgsent*22 character msg*22,msgsent*22
complex c0(0:NMAX/NDOWN-1) complex c0(0:NMAX/NDOWN-1)
complex c(0:NMAX/NDOWN-1) complex c(0:NMAX/NDOWN-1)
real*8 fMHz real*8 fMHz
integer itone(NN) integer itone(NN)
integer*2 iwave(NMAX) !Generated full-length waveform integer*2 iwave(NMAX) !Generated full-length waveform
! Get command-line argument(s) ! Get command-line argument(s)
nargs=iargc() nargs=iargc()
if(nargs.ne.8) then if(nargs.ne.9) then
print*,'Usage: wsprmsksim "message" f0 DT fsp del nwav nfiles snr' print*,'Usage: wsprcpmsim "message" f0 DT fsp del nwav nfiles snr h'
print*,'Example: wsprmsksim "K1ABC FN42 30" 50 0.0 0.1 1.0 1 10 -33' print*,'Example: wsprcpmsim "K1ABC FN42 30" 50 0.0 0.1 1.0 1 10 -33 1.0'
go to 999 go to 999
endif endif
call getarg(1,msg) !Message to be transmitted call getarg(1,msg) !Message to be transmitted
call getarg(2,arg) call getarg(2,arg)
read(arg,*) f0 !Freq relative to WSPR-band center (Hz) read(arg,*) f0 !Freq relative to WSPR-band center (Hz)
call getarg(3,arg) call getarg(3,arg)
read(arg,*) xdt !Time offset from nominal (s) read(arg,*) xdt !Time offset from nominal (s)
call getarg(4,arg) call getarg(4,arg)
read(arg,*) fspread !Watterson frequency spread (Hz) read(arg,*) fspread !Watterson frequency spread (Hz)
call getarg(5,arg) call getarg(5,arg)
read(arg,*) delay !Watterson delay (ms) read(arg,*) delay !Watterson delay (ms)
call getarg(6,arg) call getarg(6,arg)
read(arg,*) nwav !1 for *.wav file, 0 for *.c2 file read(arg,*) nwav !1 for *.wav file, 0 for *.c2 file
call getarg(7,arg) call getarg(7,arg)
read(arg,*) nfiles !Number of files read(arg,*) nfiles !Number of files
call getarg(8,arg) call getarg(8,arg)
read(arg,*) snrdb !SNR_2500 read(arg,*) snrdb !SNR_2500
call getarg(9,arg)
read(arg,*) h !h
twopi=8.0*atan(1.0) twopi=8.0*atan(1.0)
fs=12000.0/NDOWN ! fs=12000.0/NDOWN !
dt=1.0/fs !Sample interval (s) dt=1.0/fs !Sample interval (s)
tt=NSPS*dt !Duration of "itone" symbols (s) tt=NSPS*dt !Duration of "itone" symbols (s)
baud=1.0/tt !Keying rate for "itone" symbols (baud) baud=1.0/tt !Keying rate for "itone" symbols (baud)
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(bandwidth_ratio) * 10.0**(0.05*snrdb) sig=sqrt(bandwidth_ratio) * 10.0**(0.05*snrdb)
if(snrdb.gt.90.0) sig=1.0 if(snrdb.gt.90.0) sig=1.0
txt=NN*NSPS0/12000.0 txt=NN*NSPS0/12000.0
call genwsprcpm(msg,msgsent,itone) !Encode the message, get itone call genwsprcpm(msg,msgsent,itone) !Encode the message, get itone
write(*,1000) f0,xdt,txt,snrdb,fspread,delay,nfiles,msgsent write(*,1000) f0,xdt,txt,snrdb,fspread,delay,nfiles,msgsent
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, &
' fspread:',f6.1,' delay:',f6.1,' nfiles:',i3,2x,a22) ' fspread:',f6.1,' delay:',f6.1,' nfiles:',i3,2x,a22)
h=1.00 c0=0.
c0=0. k=-1 + nint(xdt/dt)
k=-1 + nint(xdt/dt) do j=1,NN
do j=1,NN dp=twopi*(f0+itone(j)*(h/2.0)*baud)*dt
dp=twopi*(f0+itone(j)*(h/2.0)*baud)*dt do i=1,NSPS
do i=1,NSPS k=k+1
k=k+1 phi=mod(phi+dp,twopi)
phi=mod(phi+dp,twopi) if(k.ge.0 .and. k.lt.NMAX/NDOWN) c0(k)=cmplx(cos(phi),sin(phi))
if(k.ge.0 .and. k.lt.NMAX/NDOWN) c0(k)=cmplx(cos(phi),sin(phi)) enddo
enddo enddo
enddo call sgran()
call sgran() do ifile=1,nfiles
do ifile=1,nfiles c=c0
c=c0 if(nwav.eq.0) then
if(nwav.eq.0) then if( fspread .ne. 0.0 .or. delay .ne. 0.0 ) then
if( fspread .ne. 0.0 .or. delay .ne. 0.0 ) then ntot=NMAX/NDOWN
call watterson(c,NMAX/NDOWN,fs,delay,fspread) nsig=NN*NSPS
endif call watterson(c,ntot,nsig,fs,delay,fspread)
!do i=0,NMAX/NDOWN-1 endif
!write(23,*) i,real(c(i)),imag(c(i)) c=c*sig
!enddo if(snrdb.lt.90) then
c=c*sig do i=0,NMAX/NDOWN-1 !Add gaussian noise at specified SNR
if(snrdb.lt.90) then xnoise=gran()
do i=0,NMAX/NDOWN-1 !Add gaussian noise at specified SNR ynoise=gran()
xnoise=gran() c(i)=c(i) + cmplx(xnoise,ynoise)
ynoise=gran() enddo
c(i)=c(i) + cmplx(xnoise,ynoise) endif
enddo write(fname,1100) ifile
endif 1100 format('000000_',i4.4,'.c2')
write(fname,1100) ifile open(10,file=fname,status='unknown',access='stream')
1100 format('000000_',i4.4,'.c2') fMHz=10.1387d0
open(10,file=fname,status='unknown',access='stream') nmin=2
fMHz=10.1387d0 write(10) fname,nmin,fMHz,c !Save to *.c2 file
nmin=2 close(10)
write(10) fname,nmin,fMHz,c !Save to *.c2 file else
close(10) call wsprcpm_wav(baud,xdt,h,f0,itone,snrdb,iwave)
!do i=0,NMAX/NDOWN-1 hwav=default_header(12000,NMAX)
!write(57,*) i,real(c(i)),imag(c(i)) write(fname,1102) ifile
!enddo 1102 format('000000_',i4.4,'.wav')
else open(10,file=fname,status='unknown',access='stream')
call wsprcpm_wav(baud,xdt,h,f0,itone,snrdb,iwave) write(10) hwav,iwave !Save to *.wav file
hwav=default_header(12000,NMAX) close(10)
write(fname,1102) ifile endif
1102 format('000000_',i4.4,'.wav') write(*,1110) ifile,xdt,f0,snrdb,fname
open(10,file=fname,status='unknown',access='stream') 1110 format(i4,f7.2,f8.2,f7.1,2x,a16)
write(10) hwav,iwave !Save to *.wav file enddo
close(10)
endif
write(*,1110) ifile,xdt,f0,snrdb,fname
1110 format(i4,f7.2,f8.2,f7.1,2x,a16)
enddo
999 end program wsprcpmsim 999 end program wsprcpmsim