mirror of
				https://github.com/saitohirga/WSJT-X.git
				synced 2025-10-25 10:00:23 -04:00 
			
		
		
		
	WIP in q65 sync scheme for superfox.
This commit is contained in:
		
							parent
							
								
									6d4372cafe
								
							
						
					
					
						commit
						391536f35a
					
				| @ -1,4 +1,4 @@ | |||||||
| subroutine sfox_gen(idat,f0,fsample,isync,cdat) | subroutine sfox_gen(idat,f0,fsample,isync,itone,cdat) | ||||||
| 
 | 
 | ||||||
|   use sfox_mod |   use sfox_mod | ||||||
|   complex cdat(NMAX)                     !Generated complex waveform |   complex cdat(NMAX)                     !Generated complex waveform | ||||||
| @ -21,17 +21,16 @@ subroutine sfox_gen(idat,f0,fsample,isync,cdat) | |||||||
|         itone(i)=idat(k) + 1    !Symbol value 0 is transmitted at tone 1, etc. |         itone(i)=idat(k) + 1    !Symbol value 0 is transmitted at tone 1, etc. | ||||||
|      endif |      endif | ||||||
|   enddo |   enddo | ||||||
| !  print*,'aaa',NN,k,NS,isync(NS),NDS |  | ||||||
|    |    | ||||||
|   df=fsample/NSPS |   df=fsample/NSPS | ||||||
|   w=1.0 |   w=1.0 | ||||||
|   j=0 |   j=0 | ||||||
|   i0=NQ/2 |   i0=NQ/2 | ||||||
| ! Generate the waveform | ! Generate the waveform | ||||||
|   do k=1,NDS |   do k=1,NDS                                       !Loop over all symbols | ||||||
|      dphi=(f0 + (itone(k)-i0)*df)*(twopi/fsample) |      dphi=(f0 + (itone(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                                   !NSPS samples per symbol | ||||||
|         j=j+1 |         j=j+1 | ||||||
|         w=w*wstep |         w=w*wstep | ||||||
|         cdat(j)=w |         cdat(j)=w | ||||||
|  | |||||||
| @ -1,23 +1,31 @@ | |||||||
| subroutine sfox_sync(iwave,fsample,isync,f,t) | subroutine sfox_sync(iwave,fsample,isync,f,t) | ||||||
| 
 | 
 | ||||||
|   use sfox_mod |   use sfox_mod | ||||||
|   parameter (NSTEPS=8) |   parameter (NSTEP=8) | ||||||
|   integer*2 iwave(NMAX) |   integer*2 iwave(NMAX) | ||||||
|   integer isync(44) |   integer isync(44) | ||||||
|   integer ipeak(1) |   integer ipeak(1) | ||||||
|   complex, allocatable :: c(:)             !Work array |   complex, allocatable :: c(:)             !Work array | ||||||
|   real x(171) |   real x(171) | ||||||
|   real, allocatable :: s(:,:)              !Symbol spectra, stepped by NSTEPS  |   real, allocatable :: s(:,:)              !Symbol spectra, stepped by NSTEP  | ||||||
|   real, allocatable :: savg(:)             !Average spectrum |   real, allocatable :: savg(:)             !Average spectrum | ||||||
|   real, allocatable :: ccf(:,:)            ! |   real, allocatable :: ccf(:,:) | ||||||
|   character*1 line(-15:15),mark(0:6),c1 | !  character*1 line(-15:15),mark(0:6),c1 | ||||||
|   data mark/' ','.','-','+','X','$','#'/ | !  data mark/' ','.','-','+','X','$','#'/ | ||||||
| 
 | 
 | ||||||
|   nh=NFFT1/2 |   nh=NFFT1/2 | ||||||
|   istep=NSPS/NSTEPS |   istep=NSPS/NSTEP | ||||||
|   jz=(13.5*fsample)/istep |   jz=(13.5*fsample)/istep | ||||||
|   df=fsample/NFFT1 |   df=fsample/NFFT1 | ||||||
|   tstep=istep/fsample |   dtstep=istep/fsample | ||||||
|  |   fsync=1500.0-bw/2 | ||||||
|  |   ftol=20.0 | ||||||
|  |   ia=nint((fsync-ftol)/df) | ||||||
|  |   ib=nint((fsync+ftol)/df) | ||||||
|  |   lagmax=1.0/dtstep | ||||||
|  |   lag1=0 | ||||||
|  |   lag2=lagmax | ||||||
|  | 
 | ||||||
|   x=0. |   x=0. | ||||||
|   do i=1,NS |   do i=1,NS | ||||||
|      x(isync(i))=1.0 |      x(isync(i))=1.0 | ||||||
| @ -26,11 +34,13 @@ subroutine sfox_sync(iwave,fsample,isync,f,t) | |||||||
|   allocate(s(0:nh/2,jz)) |   allocate(s(0:nh/2,jz)) | ||||||
|   allocate(savg(0:nh/2)) |   allocate(savg(0:nh/2)) | ||||||
|   allocate(c(0:NFFT1-1)) |   allocate(c(0:NFFT1-1)) | ||||||
|  |   allocate(ccf(ia:ib,lag1:lag2)) | ||||||
| 
 | 
 | ||||||
|   s=0. |   s=0. | ||||||
|   savg=0. |   savg=0. | ||||||
|   fac=1.0/NFFT1 |   fac=1.0/NFFT1 | ||||||
| ! Compute symbol spectra with df=baud/2 and NSTEPS steps per symbol. | 
 | ||||||
|  | ! Compute symbol spectra with df=baud/2 and NSTEP steps per symbol. | ||||||
|   do j=1,jz |   do j=1,jz | ||||||
|      k=(j-1)*istep |      k=(j-1)*istep | ||||||
|      do i=0,nh-1 |      do i=0,nh-1 | ||||||
| @ -43,105 +53,53 @@ subroutine sfox_sync(iwave,fsample,isync,f,t) | |||||||
|         s(i,j)=p |         s(i,j)=p | ||||||
|         savg(i)=savg(i) + p |         savg(i)=savg(i) + p | ||||||
|      enddo |      enddo | ||||||
|  |      ipeak=maxloc(s(ia:ib,j)) | ||||||
|  | !     print*,j,ipeak(1)+ia-1 | ||||||
|   enddo |   enddo | ||||||
| 
 |  | ||||||
|   pmax=maxval(s(82:112,1:jz)) |  | ||||||
|   s=s/pmax |  | ||||||
|   do j=jz,1,-1 |  | ||||||
|      do i=-15,15 |  | ||||||
|         k=6.001*s(97+i,j) |  | ||||||
|         line(i)=mark(k) |  | ||||||
|      enddo |  | ||||||
|      c1=' ' |  | ||||||
|      k=j/NSTEPS + 1 |  | ||||||
|      if(k.le.171) then |  | ||||||
|         if(x(k).ne.0.0) c1='*' |  | ||||||
|      endif |  | ||||||
| !     write(*,2001) j,c1,line |  | ||||||
| !2001 format(i3,2x,a1,' |',31a1,'|') |  | ||||||
|      xx=0 |  | ||||||
|      if(c1.eq.'*') xx=1 |  | ||||||
|      write(44,3044) j*tstep,xx,3.5*s(96:98,j) |  | ||||||
| 3044 format(f10.4,4f10.4) |  | ||||||
|   enddo |  | ||||||
|       |  | ||||||
|   savg=savg/jz |   savg=savg/jz | ||||||
|   ipeak=maxloc(savg(82:112)) |  | ||||||
|   i0=ipeak(1)+81 |  | ||||||
|   dxi=0. |  | ||||||
| !  if(i0.gt.0 .and. i0.lt.nh/2) then |  | ||||||
| !     call peakup(savg(i0-1),savg(i0),savg(i0+1),dxi) |  | ||||||
| !  endif |  | ||||||
|   f=(i0+dxi)*df + bw/2.0 |  | ||||||
| 
 | 
 | ||||||
|   do j=1,jz | !### | ||||||
|      k=j/NSTEPS + 1 | 
 | ||||||
|      xx=0 |   ccfbest=0. | ||||||
|      if(k.le.171) xx=x(k) |   ibest=0 | ||||||
|      write(43,3043) j,s(i0,j),xx |   lagpk=0 | ||||||
| 3043 format(i5,2f12.3) |   lagbest=0 | ||||||
|   enddo |   j0=0.5/dtstep                        !Nominal start-signal index | ||||||
|   lagmax=1.0/tstep + 1 |    | ||||||
|   pmax=0. |   do i=ia,ib | ||||||
|   lagpk=-99 |      ccfmax=0. | ||||||
| !  print*,i0,jz,tstep,lagmax |      do lag=lag1,lag2 | ||||||
|   do lag=0,lagmax |         ccft=0. | ||||||
|      p=0. |         do kk=1,NS | ||||||
|      do i=1,NS |            k=isync(kk) | ||||||
|         k=NSTEPS*(isync(i)-1) + 1 + lag |            n=NSTEP*(k-1) + 1 | ||||||
|         p=p + s(i0,k) |            j=n+lag+j0 | ||||||
|      enddo |            if(j.ge.1 .and. j.le.jz) ccft=ccft + s(i,j) | ||||||
|      p=p/NS |         enddo  ! kk | ||||||
|      if(p.gt.pmax) then |         ccft=ccft - NS*savg(i) | ||||||
|         pmax=p |         ccf(i,lag)=ccft | ||||||
|  |         if(ccft.gt.ccfmax) then | ||||||
|  |            ccfmax=ccft | ||||||
|            lagpk=lag |            lagpk=lag | ||||||
|         endif |         endif | ||||||
|      write(42,3042) lag,lag*tstep,p |      enddo  ! lag | ||||||
| 3042 format(i5,2f15.3) |  | ||||||
|   enddo |  | ||||||
|   t=lagpk*tstep |  | ||||||
| !  print*,f,t |  | ||||||
|   if(NS.ne.-99) return |  | ||||||
| 
 | 
 | ||||||
|   nsz=(nint(3.0*fsample) + NS*NSPS)/istep |      if(ccfmax.gt.ccfbest) then | ||||||
| 
 |         ccfbest=ccfmax | ||||||
| 
 |         ibest=i | ||||||
|   pmax=0. |         lagbest=lagpk | ||||||
|   ntol=100 |  | ||||||
|   iz=nint(ntol/df) |  | ||||||
|   i0=nint(1500.0/df) |  | ||||||
|   ipk=-999 |  | ||||||
|   jpk=-999 |  | ||||||
|   jz=nsz-NSTEPS*NS |  | ||||||
|   allocate(ccf(-iz:iz,1:jz)) |  | ||||||
|   ccf=0. |  | ||||||
|   do j=1,jz |  | ||||||
|      do i=-iz,iz |  | ||||||
|         p=0. |  | ||||||
|         do k=1,NS |  | ||||||
|            ii=i0+i+(2*(isync(k)-NQ/2)) |  | ||||||
|            jj=j + NSTEPS*(k-1) |  | ||||||
|            p=p + s(ii,jj) |  | ||||||
|         enddo |  | ||||||
|         ccf(i,j)=p |  | ||||||
|         if(p.gt.pmax) then |  | ||||||
|            pmax=p |  | ||||||
|            ipk=i |  | ||||||
|            jpk=j |  | ||||||
|      endif |      endif | ||||||
|      enddo |   enddo  ! i | ||||||
|   enddo |   f=ibest*df + bw/2 | ||||||
|  |   t=lagbest*dtstep | ||||||
|  | !  write(*,4100) ibest,lagbest,f,t | ||||||
|  | !4100 format(2i6,f10.1,f10.3) | ||||||
| 
 | 
 | ||||||
|   dxi=0. | !  print*,'aaa',ibest,lagbest | ||||||
|   dxj=0. |   do lag=lag1,lag2 | ||||||
|   if(jpk.gt.1 .and. jpk.lt.jz .and. abs(ipk).lt.iz) then |      write(51,3051) lag*dtstep,ccf(ibest,lag) | ||||||
|      call peakup(ccf(ipk-1,jpk),ccf(ipk,jpk),ccf(ipk+1,jpk),dxi) | 3051 format(2f12.4) | ||||||
|      call peakup(ccf(ipk,jpk-1),ccf(ipk,jpk),ccf(ipk,jpk+1),dxj) |   enddo | ||||||
|   endif |  | ||||||
| 
 |  | ||||||
|   dfreq=(ipk+dxi)*df |  | ||||||
|   f=1500.0+dfreq |  | ||||||
|   t=(jpk+dxj-201.0)*istep/fsample |  | ||||||
| 
 | 
 | ||||||
|   return |   return | ||||||
| end subroutine sfox_sync | end subroutine sfox_sync | ||||||
|  | |||||||
| @ -11,6 +11,8 @@ program sfoxtest | |||||||
|   integer*2 iwave(NMAX)                  !Generated i*2 waveform |   integer*2 iwave(NMAX)                  !Generated i*2 waveform | ||||||
|   integer param(0:8) |   integer param(0:8) | ||||||
|   integer isync(44) |   integer isync(44) | ||||||
|  |   integer jsync(171) | ||||||
|  |   integer itone(171) | ||||||
|   real*4 xnoise(NMAX)                    !Random noise |   real*4 xnoise(NMAX)                    !Random noise | ||||||
|   real*4 dat(NMAX)                       !Generated real data |   real*4 dat(NMAX)                       !Generated real data | ||||||
|   complex cdat(NMAX)                     !Generated complex waveform |   complex cdat(NMAX)                     !Generated complex waveform | ||||||
| @ -100,6 +102,27 @@ program sfoxtest | |||||||
|   allocate(rxprob2(0:NN-1)) |   allocate(rxprob2(0:NN-1)) | ||||||
|   allocate(correct(0:NN-1)) |   allocate(correct(0:NN-1)) | ||||||
| 
 | 
 | ||||||
|  |   idum=-1 | ||||||
|  |   jsync=0 | ||||||
|  |   jsync(1)=1 | ||||||
|  |   jsync(NDS)=1 | ||||||
|  |   ms=2 | ||||||
|  |   do i=1,100000 | ||||||
|  |      j=1 + (NDS-1)*ran1(idum) | ||||||
|  |      if(jsync(j).eq.0) then | ||||||
|  |         jsync(j)=1 | ||||||
|  |         ms=ms+1 | ||||||
|  |         if(ms.eq.NS) exit | ||||||
|  |      endif | ||||||
|  |   enddo | ||||||
|  |   j=0 | ||||||
|  |   do i=1,NDS | ||||||
|  |      if(jsync(i).eq.1) then | ||||||
|  |         j=j+1 | ||||||
|  |         isync(j)=i | ||||||
|  |      endif | ||||||
|  |   enddo | ||||||
|  | 
 | ||||||
|   rms=100. |   rms=100. | ||||||
|   baud=fsample/nsps                 !Keying rate, 11.719 baud for nsps=1024 |   baud=fsample/nsps                 !Keying rate, 11.719 baud for nsps=1024 | ||||||
|   bandwidth_ratio=2500.0/fsample |   bandwidth_ratio=2500.0/fsample | ||||||
| @ -116,10 +139,6 @@ program sfoxtest | |||||||
|   chansym0(0:kk-1)=msg0(1:kk) |   chansym0(0:kk-1)=msg0(1:kk) | ||||||
|   chansym0(kk:nn-1)=parsym(1:nn-kk) |   chansym0(kk:nn-1)=parsym(1:nn-kk) | ||||||
| 
 | 
 | ||||||
| ! Generate cdat, the SuperFox waveform |  | ||||||
|   call timer('gen     ',0) |  | ||||||
|   call sfox_gen(chansym0,f0,fsample,isync,cdat) |  | ||||||
|   call timer('gen     ',1) |  | ||||||
|   isnr0=-8 |   isnr0=-8 | ||||||
| 
 | 
 | ||||||
|   do isnr=isnr0,-20,-1 |   do isnr=isnr0,-20,-1 | ||||||
| @ -150,26 +169,26 @@ program sfoxtest | |||||||
|         f1=f0 |         f1=f0 | ||||||
|         if(f0.eq.0.0) then |         if(f0.eq.0.0) then | ||||||
|            f1=1500.0 + 20.0*(ran1(idum)-0.5) |            f1=1500.0 + 20.0*(ran1(idum)-0.5) | ||||||
|            xdt=0.3*ran1(idum) | !           xdt=0.3*ran1(idum) | ||||||
|            call timer('gen     ',0) |  | ||||||
|            call sfox_gen(chansym0,f1,fsample,isync,cdat) |  | ||||||
|            call timer('gen     ',1) |  | ||||||
|         endif |         endif | ||||||
|  |         call timer('gen     ',0) | ||||||
|  | ! Generate cdat, the SuperFox waveform | ||||||
|  |         call sfox_gen(chansym0,f1,fsample,isync,itone,cdat) | ||||||
|  |         call timer('gen     ',1) | ||||||
| 
 | 
 | ||||||
|         crcvd=0. |         crcvd=0. | ||||||
|         crcvd(1:NMAX)=cshift(cdat(1:NMAX),-nint(xdt*fsample)) |         crcvd(1:NMAX)=cshift(cdat(1:NMAX),-nint((0.5+xdt)*fsample)) | ||||||
|         call timer('watterso',0) |         call timer('watterso',0) | ||||||
|         if(fspread.ne.0 .or. delay.ne.0) call watterson(crcvd,NMAX,NZ,fsample,& |         if(fspread.ne.0 .or. delay.ne.0) call watterson(crcvd,NMAX,NZ,fsample,& | ||||||
|              delay,fspread) |              delay,fspread) | ||||||
|         call timer('watterso',1) |         call timer('watterso',1) | ||||||
|         crcvd=sig*crcvd+cnoise |  | ||||||
| 
 | 
 | ||||||
| !        dat=aimag(sigr*cdat(1:NMAX)) + xnoise     !Add generated AWGN noise |  | ||||||
|         dat=aimag(sigr*crcvd(1:NMAX)) + xnoise    !Add generated AWGN noise |         dat=aimag(sigr*crcvd(1:NMAX)) + xnoise    !Add generated AWGN noise | ||||||
|         fac=32767.0 |         fac=32767.0 | ||||||
|         if(snr.ge.90.0) iwave(1:NMAX)=nint(fac*dat(1:NMAX)) |         if(snr.ge.90.0) iwave(1:NMAX)=nint(fac*dat(1:NMAX)) | ||||||
|         if(snr.lt.90.0) iwave(1:NMAX)=nint(rms*dat(1:NMAX)) |         if(snr.lt.90.0) iwave(1:NMAX)=nint(rms*dat(1:NMAX)) | ||||||
| 
 | 
 | ||||||
|  |         crcvd=sig*crcvd+cnoise | ||||||
|         if(hard_sync) then |         if(hard_sync) then | ||||||
|            f=f1  ! + 5.0*(ran1(idum)-0.5) |            f=f1  ! + 5.0*(ran1(idum)-0.5) | ||||||
|            t=xdt ! + 0.01*(ran1(idum)-0.5) |            t=xdt ! + 0.01*(ran1(idum)-0.5) | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user