aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xdoc/fir-filter/generate-filter.py31
1 files changed, 28 insertions, 3 deletions
diff --git a/doc/fir-filter/generate-filter.py b/doc/fir-filter/generate-filter.py
index e4e2d0b..403f080 100755
--- a/doc/fir-filter/generate-filter.py
+++ b/doc/fir-filter/generate-filter.py
@@ -3,6 +3,14 @@
# that can be used for the FIRFilter function in
# CRC DabMod
#
+# Usage:
+# 1) adapt the filter settings below
+# 2) Call this script and redirect the output of this script into a file
+#
+# Requires:
+# A recent gnuradio version (3.7)
+#
+#
# The MIT License (MIT)
#
# Copyright (c) 2013 Matthias P. Braendli
@@ -27,13 +35,30 @@
# SOFTWARE.
import gnuradio
-from gnuradio import gr
+from gnuradio import digital
+
+# From documentation at
+# http://gnuradio.org/doc/doxygen/classgr_1_1filter_1_1firdes.html
+
+# use "window method" to design a low-pass FIR filter
+#
+# gain: overall gain of filter (typically 1.0)
+# sampling_freq: sampling freq (Hz)
+# cutoff_freq: center of transition band (Hz)
+# transition_width: width of transition band (Hz).
+# The normalized width of the transition band is what sets the number of taps required. Narrow --> more taps
+# window_type: What kind of window to use. Determines maximum attenuation and passband ripple.
+# beta: parameter for Kaiser window
gain = 1
-rate = 2.048e6
+sampling_freq = 2.048e6
cutoff = 810e3
transition_width = 150e3
-taps = gr.firdes_low_pass(gain, rate, cutoff, transition_width, gr.firdes.WIN_HAMMING, beta=6.76)
+window = digital.filter.window.WIN_HAMMING
+
+
+# Generate filter taps and print them out
+taps = digital.filter.firdes_low_pass(gain, sampling_freq, cutoff, transition_width, window, beta=6.76)
print(len(taps))
for t in taps: