commit-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Commit-gnuradio] r11612 - in gnuradio/branches/developers/n4hy/pfb_iir2


From: n4hy
Subject: [Commit-gnuradio] r11612 - in gnuradio/branches/developers/n4hy/pfb_iir2: gnuradio-core/src/lib/general gnuradio-examples/python/apps/filter_design_tool
Date: Mon, 17 Aug 2009 16:15:58 -0600 (MDT)

Author: n4hy
Date: 2009-08-17 16:15:57 -0600 (Mon, 17 Aug 2009)
New Revision: 11612

Modified:
   
gnuradio/branches/developers/n4hy/pfb_iir2/gnuradio-core/src/lib/general/gr_iirdes.cc
   
gnuradio/branches/developers/n4hy/pfb_iir2/gnuradio-examples/python/apps/filter_design_tool/iirdestest.py
Log:
chebyshev type II or inverse Cheby added and  bandpass test added

Modified: 
gnuradio/branches/developers/n4hy/pfb_iir2/gnuradio-core/src/lib/general/gr_iirdes.cc
===================================================================
--- 
gnuradio/branches/developers/n4hy/pfb_iir2/gnuradio-core/src/lib/general/gr_iirdes.cc
       2009-08-17 22:01:53 UTC (rev 11611)
+++ 
gnuradio/branches/developers/n4hy/pfb_iir2/gnuradio-core/src/lib/general/gr_iirdes.cc
       2009-08-17 22:15:57 UTC (rev 11612)
@@ -290,9 +290,61 @@
                double Rp,
                double Rs)
 {
-  vector<double> rtn(2);
-  if ((fresp == BANDPASS) || (fresp == BANDSTOP)) rtn.resize(3);
-  return rtn;
+  double  qs = pow(10.,(fabs(Rs)/10.0));
+  double  qp = pow(10.,(fabs(Rp)/10.0));
+  switch (fresp) {
+  case gr_iirdes::LOWPASS: {
+    vector<double> rtn(2);
+    double Wa;
+    if (Wp[0]>=Ws[0])
+      throw std::invalid_argument ("For lowpass filter Wp < Ws");
+
+    rtn[1] = Ws[0];
+    Ws[0] = tan(M_PI*Ws[0]);
+    Wp[0] = tan(M_PI*Wp[0]);
+    Wa = Wp[0]/Ws[0];
+    rtn[0] = ceil(acosh(sqrt((qs-1)/(qp-1)))/acosh(1.0/Wa));
+    return rtn;
+  }
+  case gr_iirdes::HIGHPASS: {
+    double Wa;
+    vector<double> rtn(2);
+    if (Ws[0]>=Wp[0]) throw std::invalid_argument ("For highpass filter Wp > 
Ws");
+    rtn[1] = Ws[0];
+    Ws[0] = tan(M_PI*Ws[0]);
+    Wp[0] = tan(M_PI*Wp[0]);
+    Wa = Ws[0]/Wp[0];
+    rtn[0] = ceil(acosh(sqrt((qs-1)/(qp-1)))/acosh(1.0/Wa));
+    return rtn;
+  }
+  case gr_iirdes::BANDPASS: {
+    double Wa[2];
+    vector<double> rtn(3);
+    if ((Ws[0]>=Wp[0]) ||
+       (Wp[0]>=Wp[1]) ||
+       (Wp[1]>=Ws[1])) throw std::invalid_argument
+                         ("For bandpass filter Ws[0]<Wp[0]<Wp[1]<Ws[1]");
+
+    rtn[1] = Ws[0];
+    rtn[2] = Ws[1];
+    Ws[0] = tan(M_PI*Ws[0]);
+    Wp[0] = tan(M_PI*Wp[0]);
+    Ws[1] = tan(M_PI*Ws[1]);
+    Wp[1] = tan(M_PI*Wp[1]);
+    for (int i=0;i<2;i++)
+      Wa[i]=(Wp[i]*Wp[i]-Ws[0]*Ws[1])/(Wp[i]*(Ws[0]-Ws[1]));
+    Wa[0]=fmin(fabs(Wa[0]),fabs(Wa[1]));
+    rtn[0] = ceil(acosh(sqrt((qs-1)/(qp-1)))/acosh(1.0/Wa[0]));
+    return rtn;
+  }
+  case gr_iirdes::BANDSTOP: {
+    vector<double> rtn(3);
+    throw std::invalid_argument
+                         ("bandstop filter not implemented yet");
+    return rtn;
+  }}
+  return (vector<double>) NULL;
+
 }
 
 vector<double>

Modified: 
gnuradio/branches/developers/n4hy/pfb_iir2/gnuradio-examples/python/apps/filter_design_tool/iirdestest.py
===================================================================
--- 
gnuradio/branches/developers/n4hy/pfb_iir2/gnuradio-examples/python/apps/filter_design_tool/iirdestest.py
   2009-08-17 22:01:53 UTC (rev 11611)
+++ 
gnuradio/branches/developers/n4hy/pfb_iir2/gnuradio-examples/python/apps/filter_design_tool/iirdestest.py
   2009-08-17 22:15:57 UTC (rev 11612)
@@ -36,7 +36,14 @@
                               60)
 print "Chebyshev Bandpass design, order and cutoff frequency = ",numbersC,"\n"
 
+numbersIC = gr.iirdes.invchebyshevord(gr.iirdes.BANDPASS,
+                              [.2, .3],
+                              [.1, .4],
+                              .1,
+                              60)
+print "Inverse Chebyshev (Cheby Type 2) Bandpass design, order and cutoff 
frequency = ",numbersIC,"\n"
 
+
 tf=[0.0976, 0.1953, 0.0976, 0.3333, -0.9428, 1.0]
 order = gr.iirdes.tf2order(tf)
 print "order of filter= ",order,"\n"





reply via email to

[Prev in Thread] Current Thread [Next in Thread]