⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 calc_gc1115coef.m

📁 一个滤波器设计程序
💻 M
📖 第 1 页 / 共 2 页
字号:
function calc_GC1115coef()
   % uses firls to design low pass filter for GC1115 

   % filterdesign = 1;  % 6 carrier TDSCDMA
   % filterdesign = 2;  % 1 carrier Wimax 802.16.e 10Mhz
   % filterdesign = 3;  % 3 carrier WCDMA, middle carrier at 0IF
                        % dec2, 2 channel
   % filterdesign = 4;  % 1 carrier WCDMA, designed for gapped carriers,
                        % dec2, 2 channel
   % filterdesign = 5;  % 1 carrier Wimax 802.16.e 10Mhz
  % filterdesign = 6;  %  1car TDSCDMA, for gapped carriers
  % filterdesign = 7;  %  1car CDMA2000, for gapped carriers
   % filterdesign = 8;  % 2chan 28Mhz complex, 1 carrier Wimax 802.16.e 10Mhz
       
   filterdesign = 8
   
   if(filterdesign == 1)
      GC1115_clock_rate = 61.44e6
      inmode = 1;      % 1 = parallel IQ, 2 = interleaved IQ
      indec = 1;       % 1 or 2
   
      carrierBW = 1.6e6 * 3;  % BW above zero IF, if not contiguous design for one carrier
                               % note if a carrier is centered at 0, the value is .5 + other carriers 
   
      num_desiredtaps = 249;                         
      method = 1;    % 0 - LP, 1 - LP w/Window, 2 - RRC, 3- RRC w/Window 
   
      windowtype = 1.01; % 0 - none, 1 - Hamming, >1 - KaiserBessel Alpha
      if(method == 3)
         Beta = .22 / windowtype;    % pulse shaping filter excess bandwidth
      else
         Beta = .22;
      end   
      Fs = carrierBW - .1e6;     % used with Least Squares as start of stopband
      if(method == 1)
         Fp = (.7/windowtype) * Fs;        % used with Least Squares as end of passband
      else
         Fp = .7 * Fs;        % used with Least Squares as end of passband
      end
      Passbd = .15;   % used with Least Squares as passband ripple in db
      Stopbd = -50; % used with Least Squared as stopband rejection in db
      
      PFIRcoef_bits = 12; % fixed point resolution
      chopmode = 20;     % deletes taps from both ends
      num_cancellationtaps = num_desiredtaps + (2 * chopmode);

      outcoef_foldername = 'C:\Engineering';
      numtext = sprintf('%d_%d.taps',method, num_desiredtaps); 
      outcoef_filename = strcat('GC1115canccoef_', numtext);
   end
   
   if(filterdesign == 2)
      GC1115_clock_rate = 67.2e6;
      inmode = 1;      % 1 = parallel IQ, 2 = interleaved IQ
      indec = 1;       % 1 or 2
   
      carrierBW = 10e6 * .5;  % BW above zero IF, if not contiguous design for one carrier
                               % note if a carrier is centered at 0, the value is .5 + other carriers 
   
      num_desiredtaps = 211;                         
      method = 0;    % 0 - LP, 1 - LP w/Window, 2 - RRC, 3- RRC w/Window 
   
      windowtype = 1.01; % 0 - none, 1 - Hamming, >1 - KaiserBessel Alpha
      if(method == 3)
         Beta = .22 / windowtype;    % pulse shaping filter excess bandwidth
      else
         Beta = .22;
      end   
      Fs = carrierBW - .1e6;     % used with Least Squares as start of stopband
      if(method == 1)
         Fp = (.7/windowtype) * Fs;        % used with Least Squares as end of passband
      else
         Fp = .7 * Fs;        % used with Least Squares as end of passband
      end
      Passbd = .15;   % used with Least Squares as passband ripple in db
      Stopbd = -50; % used with Least Squared as stopband rejection in db
      
      PFIRcoef_bits = 12; % fixed point resolution
      chopmode = 20;     % deletes taps from both ends
      num_cancellationtaps = num_desiredtaps + (2 * chopmode);

      outcoef_foldername = 'C:\Engineering';
      numtext = sprintf('%d_%d.taps',method, num_desiredtaps); 
      outcoef_filename = strcat('GC1115canccoef_', numtext);
   end
   
   if(filterdesign == 3)
      GC1115_clock_rate = 122.88e6;
      inmode = 2;      % 1 = parallel IQ, 2 = interleaved IQ
      indec = 2;       % 1 or 2
   
      carrierBW = 3.84e6 * 1.5;  % BW above zero IF, if not contiguous design for one carrier
                               % note if a carrier is centered at 0, the value is .5 + other carriers 
   
      num_desiredtaps = 249;                         
      method = 3;    % 0 - LP, 1 - LP w/Window, 2 - RRC, 3- RRC w/Window 
   
      windowtype = 1.01; % 0 - none, 1 - Hamming, >1 - KaiserBessel Alpha
      if(method == 3)
         Beta = .22 / windowtype;    % pulse shaping filter excess bandwidth
      else
         Beta = .22;
      end   
      Fs = carrierBW - .1e6;     % used with Least Squares as start of stopband
      if(method == 1)
         Fp = (.7/windowtype) * Fs;        % used with Least Squares as end of passband
      else
         Fp = .7 * Fs;        % used with Least Squares as end of passband
      end
      Passbd = .15;   % used with Least Squares as passband ripple in db
      Stopbd = -50; % used with Least Squared as stopband rejection in db
      
      PFIRcoef_bits = 12; % fixed point resolution
      chopmode = 20;     % deletes taps from both ends
      num_cancellationtaps = num_desiredtaps + (2 * chopmode);

      outcoef_foldername = 'C:\Engineering';
      numtext = sprintf('%d_%d.taps',method, num_desiredtaps); 
      outcoef_filename = strcat('GC1115canccoef_', numtext);
   end
   
   if(filterdesign == 4)
      GC1115_clock_rate = 122.88e6;
      inmode = 2;      % 1 = parallel IQ, 2 = interleaved IQ
      indec = 2;       % 1 or 2
   
      carrierBW = 3.84e6 * .5;  % BW above zero IF, if not contiguous design for one carrier
                               % note if a carrier is centered at 0, the value is .5 + other carriers 
   
      num_desiredtaps = 219;                         
      method = 1;    % 0 - LP, 1 - LP w/Window, 2 - RRC, 3- RRC w/Window 
   
      windowtype = 1.1; % 0 - none, 1 - Hamming, >1 - KaiserBessel Alpha
      if(method == 3)
         Beta = .22 / windowtype;    % pulse shaping filter excess bandwidth
      else
         Beta = .22;
      end   
      Fs = carrierBW - .1e6;     % used with Least Squares as start of stopband
      if(method == 1)
         Fp = (.7/windowtype) * Fs;        % used with Least Squares as end of passband
      else
         Fp = .7 * Fs;        % used with Least Squares as end of passband
      end
      Passbd = .15;   % used with Least Squares as passband ripple in db
      Stopbd = -70; % used with Least Squared as stopband rejection in db
      
      PFIRcoef_bits = 12; % fixed point resolution
      chopmode = 20;     % deletes taps from both ends
      num_cancellationtaps = num_desiredtaps + (2 * chopmode);

      outcoef_foldername = 'C:\Engineering';
      numtext = sprintf('%d_%d.taps',method, num_desiredtaps); 
      outcoef_filename = strcat('GC1115canccoef_', numtext);
   end
 
   if(filterdesign == 5)
      GC1115_clock_rate = 4 * 28/25 * 10e6;
      inmode = 1;      % 1 = parallel IQ, 2 = interleaved IQ
      indec = 1;       % 1 or 2
   
      carrierBW = 10e6 * .5;  % BW above zero IF, if not contiguous design for one carrier
                               % note if a carrier is centered at 0, the value is .5 + other carriers 
   
      num_desiredtaps = 279;                         
      method = 1;    % 0 - LP, 1 - LP w/Window, 2 - RRC, 3- RRC w/Window 
   
      windowtype = 1.01; % 0 - none, 1 - Hamming, >1 - KaiserBessel Alpha
      if(method == 3)
         Beta = .22 / windowtype;    % pulse shaping filter excess bandwidth
      else
         Beta = .22;
      end   
      Fs = carrierBW - .2e6;     % used with Least Squares as start of stopband
      if(method == 1)
         Fp = (.8/windowtype) * Fs;        % used with Least Squares as end of passband
      else
         Fp = .8 * Fs;        % used with Least Squares as end of passband
      end
      Passbd = .1;   % used with Least Squares as passband ripple in db
      Stopbd = -70; % used with Least Squared as stopband rejection in db
      
      PFIRcoef_bits = 12; % fixed point resolution
      chopmode = 20;     % deletes taps from both ends
      num_cancellationtaps = num_desiredtaps + (2 * chopmode);

      outcoef_foldername = 'C:\Temp';
      numtext = sprintf('%d_%d.taps',method, num_desiredtaps); 
      outcoef_filename = strcat('GC1115canccoef_', numtext);
   end
   
   if(filterdesign == 6)
      GC1115_clock_rate = 122.88e6
      inmode = 1;      % 1 = parallel IQ, 2 = interleaved IQ
      indec = 2;       % 1 or 2
   
      carrierBW = 1.6e6 * 3;  % BW above zero IF, if not contiguous design for one carrier
                               % note if a carrier is centered at 0, the value is .5 + other carriers 
   
      num_desiredtaps = 249;                         
      method = 1;    % 0 - LP, 1 - LP w/Window, 2 - RRC, 3- RRC w/Window 
   
      windowtype = 1.01; % 0 - none, 1 - Hamming, >1 - KaiserBessel Alpha
      if(method == 3)
         Beta = .22 / windowtype;    % pulse shaping filter excess bandwidth
      else
         Beta = .22;
      end   
      Fs = carrierBW - .1e6;     % used with Least Squares as start of stopband
      if(method == 1)
         Fp = (.7/windowtype) * Fs;        % used with Least Squares as end of passband
      else
         Fp = .7 * Fs;        % used with Least Squares as end of passband
      end
      Passbd = .15;   % used with Least Squares as passband ripple in db
      Stopbd = -50; % used with Least Squared as stopband rejection in db
      
      PFIRcoef_bits = 12; % fixed point resolution
      chopmode = 20;     % deletes taps from both ends
      num_cancellationtaps = num_desiredtaps + (2 * chopmode);

      outcoef_foldername = 'C:\Engineering';
      numtext = sprintf('%d_%d.taps',method, num_desiredtaps); 
      outcoef_filename = strcat('GC1115canccoef_', numtext);
   end
 
   if(filterdesign == 7)
      GC1115_clock_rate = 61.44e6;
      inmode = 1;      % 1 = parallel IQ, 2 = interleaved IQ
      indec = 1;       % 1 or 2
   
      carrierBW = .5 * 1.2288e6;  % BW above zero IF, if not contiguous design for one carrier
                               % note if a carrier is centered at 0, the value is .5 + other carriers 
   
      num_desiredtaps = 159;                         
      method = 1;    % 0 - LP, 1 - LP w/Window, 2 - RRC, 3- RRC w/Window 
   
      windowtype = 1.01; % 0 - none, 1 - Hamming, >1 - KaiserBessel Alpha
      if(method == 3)
         Beta = .22 / windowtype;    % pulse shaping filter excess bandwidth
      else
         Beta = .22;
      end   
      Fs = carrierBW - .1e6;     % used with Least Squares as start of stopband
      if(method == 1)
         Fp = (.25/windowtype) * Fs;        % used with Least Squares as end of passband
      else
         Fp = .25 * Fs;        % used with Least Squares as end of passband
      end
      Passbd = .1;   % used with Least Squares as passband ripple in db
      Stopbd = -60; % used with Least Squared as stopband rejection in db
      
      PFIRcoef_bits = 12; % fixed point resolution
      chopmode = 20;     % deletes taps from both ends
      num_cancellationtaps = num_desiredtaps + (2 * chopmode);

      outcoef_foldername = 'C:\Documents and Settings\a0871012\My Documents\My GC Studio Projects\GC1115\newDanamtest';
      numtext = sprintf('%d_%d.taps',method, num_desiredtaps); 
      outcoef_filename = strcat('GC1115canccoef_CDMA2000_', numtext);
   end

   if(filterdesign == 8)
      GC1115_clock_rate = 112e6;
      inmode = 2;      % 1 = parallel IQ, 2 = interleaved IQ (must be Interleaved IQ for 2 chan)
      indec = 2;       % 1 or 2 (must be 2 for 2 chan)
   
      carrierBW = 10e6 * .5;  % BW above zero IF, if not contiguous design for one carrier
                               % note if a carrier is centered at 0, the value is .5 + other carriers 
   
      num_desiredtaps = 249;                         
      method = 1;    % 0 - LP, 1 - LP w/Window, 2 - RRC, 3- RRC w/Window 
   
      windowtype = 1.01; % 0 - none, 1 - Hamming, >1 - KaiserBessel Alpha
      if(method == 3)
         Beta = .22 / windowtype;    % pulse shaping filter excess bandwidth
      else
         Beta = .22;
      end   
      Fs = carrierBW - .2e6;     % used with Least Squares as start of stopband
      if(method == 1)
         Fp = (.82/windowtype) * Fs;        % used with Least Squares as end of passband
      else
         Fp = .82 * Fs;        % used with Least Squares as end of passband
      end
      Passbd = 2;   % used with Least Squares as passband ripple in db
      Stopbd = -70; % used with Least Squared as stopband rejection in db
      
      PFIRcoef_bits = 12; % fixed point resolution
      chopmode = 20;     % deletes taps from both ends
      num_cancellationtaps = num_desiredtaps + (2 * chopmode);

      outcoef_foldername = 'C:\Temp';
      numtext = sprintf('%filtdes8_%d_%d.taps',method, num_desiredtaps); 
      outcoef_filename = strcat('GC1115_', numtext);
   end
   
   % constants and fudge factors 
   Remez_fudge = 80;  % fudge factor for Remez versus Least Squares calc
   
   LPFilter = 0;
   LPFilter_Window = 1;
   RRC = 2;
   RRC_Window = 3;
   Hybrid = 4;

   clock_rate = GC1115_clock_rate / ( inmode * indec);
   Firres_bits = PFIRcoef_bits;
   FIRmax = 2^ (Firres_bits - 1) - 1;
   numPFIRtaps = num_cancellationtaps;

   %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   % normalize frequency and amplitude
   %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   freq(1:4) =    [0, Fp, Fs, (clock_rate /2)];
   ampldbV(1:4) = [0, Passbd, Stopbd, Stopbd];

   % convert freq[] to normalized freq
   % convert amplitude in dbV to ratio, assumes same number of points as freq[]
   for n = 1: 4
      norm_freq(n) = freq(n) / (clock_rate /2)  % normalize to filter samplerate
      if(n < 4)
         ratio_ampl(n) = 10^( ampldbV(n) / 20);
      else
         ratio_ampl(n) = 0;
      end   
   end
         
   % weighting vector uses passband ripple for quality factor
   % w(1: 2) = [1/Passbd, 10];
   w(1: 2) = [10, 2];

   % RRC filter parameters
   if(windowtype > 1)
      sampleratio = carrierBW * (1.6/windowtype) / clock_rate;
   else
      sampleratio = carrierBW * 1.6 / clock_rate;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -