% GUISDAP v1.50   94-03-10 Copyright Asko Huuskonen, Markku Lehtinen 
% 
% CP1KTvcinit.m
% N_scan=64; % Complete virtual channel definition, 640 virtual channels
N_scan=32; % Half of the channels defined, 320 virtual channels 
vc_ch=zeros(1,10*N_scan);
vc_t1=zeros(1,10*N_scan);
vc_t2=zeros(1,10*N_scan);
T_scan=15302;

% One round of the main loops defines 10 virtual channels for one scan,
% which lasts for 15302 us.

for scan=0:N_scan-1
  SHIFT=scan*T_scan;
%                         power   long    altern    power    power
%                        profile  pulse    code    profile  profile
  vc_ch((1:10)+10*scan)=[  1  2   3  4    5   6     5   6    7  8 ];
  vc_t1((1:10)+10*scan)=[  0  0   0  0   0.2 0.7   0.0 0.5   0  0 ]*T_scan+SHIFT;
  vc_t2((1:10)+10*scan)=[  1  1   1  1   1.0 1.5   0.2 0.7   1  1 ]*T_scan+SHIFT;
end

for scan=32:N_scan-1 % This loop is not executed, if N_scan=32
  SHIFT=scan*T_scan;
% Channels 5,6 and 7,8 change roles for the latter half of the experiment cycle
%                         power   long    altern    power    power
%                        profile  pulse    code    profile  profile
  vc_ch((1:10)+10*scan)=[  1  2   3  4    7   8     7   8    5  6 ];
  vc_t1((1:10)+10*scan)=[  0  0   0  0   0.2 0.7   0.0 0.5   0  0 ]*T_scan+SHIFT;
  vc_t2((1:10)+10*scan)=[  1  1   1  1   1.0 1.5   0.2 0.7   1  1 ]*T_scan+SHIFT;
end
ind=find(vc_t2>64*T_scan);
vc_t2(ind)=vc_t2(ind)-64*T_scan;
