% Mon May  4 05:09:32 UTC 2015
% contains actual parameters for ppk
% set the DDS parameters for programming
% all SI units
% need to specify operating parameters
% middle frequency, the new IUT 26.20--26.42 band
fr=26.31e6                 % Hz
% chirp length as assumed in WERA, stretched s, not real chirp length  
%w_chirp=0.2166666  %s gives standard WERA MT 1280, no folding to 0 Doppler
w_chirp=0.223776    %s folds 60 Hz near zero Doppler and makes MT integer
% hf bandwidth
hf_bw=2.247768901969500e+05        % Hz
% this gives exactly 2/3 km
% frequency offset for calibration/demodulation
delta_f=-80

format long

% speed of light in vacuum
c0=2.99792458e8;

% speed of radio waves in moist tropical air
c=c0*(1-300/1e6);

% range_res, expected range resolution
range_res=c/(2*hf_bw);  % m

% WERA Vectron OCXO
w_fs = 256*60*5/13;
w_hf_lf = (2^8*3*10);
w_FVclk = w_fs*w_hf_lf;
w_pll = 4;
w_Fclk = w_FVclk*w_pll;

% LERA Vectron OCXO
l_FVclk = 50e6;
l_hf_lf = 2^13;
l_fs = l_FVclk/l_hf_lf;
l_pll = 5;
l_Fclk = l_FVclk*l_pll;

% Novatech on-board Ilco TCXO
n_FVclk = 2^48/10^7;
n_hf_lf = 2^12;
n_fs = n_FVclk/n_hf_lf;
n_pll = 10;
n_Fclk = n_FVclk*n_pll;

% LERA Ilco TCXO on DDS-BUF board
i_FVclk = w_fs*2^12;
i_hf_lf = 2^12;
i_fs = w_fs;
i_pll = 10;
i_Fclk = i_FVclk*i_pll;

% set which one we're working with: the LERA VECTRON clock
Fclk=l_Fclk;
fs=l_fs;

% ratio of Novatech TCXO to lera OCXO
nl_Fclk_ratio=n_Fclk/l_Fclk;

% ratio of LERA fs to WERA fs
lw_fs_ratio=l_fs/w_fs;

% dds step in Hz
dds_step = Fclk/2^48;

% dds cycle/Hz
dds = 1./dds_step;

% actual chirp length in s
l_chirp=w_chirp/lw_fs_ratio

% DD8m parameters
F0=(fr-hf_bw/2+delta_f)*nl_Fclk_ratio/1e6
F1=(fr-hf_bw/2)*nl_Fclk_ratio/1e6
Td=1
Tr=floor(l_chirp*l_Fclk/2) % in "update clock" cycles, /2
Fd=floor(hf_bw/Tr*nl_Fclk_ratio*1e6)/1e12
mt=l_chirp*l_fs            % samples-per-chirp in WERA language
