summaryrefslogtreecommitdiff
path: root/gr-atsc/src/python
diff options
context:
space:
mode:
authorcswiger <cswiger@221aa14e-8319-0410-a670-987f0aec2ac5>2007-04-23 10:45:42 +0000
committercswiger <cswiger@221aa14e-8319-0410-a670-987f0aec2ac5>2007-04-23 10:45:42 +0000
commitd049678e49aefaa823ce45bd9310e2e43c93e1cf (patch)
treeed7b5a030611df1e4ca916bf19717a165e1bab9f /gr-atsc/src/python
parentaaf51ed7d99ba7cb9badd38c15e8643425b8bf78 (diff)
Fixed atsc_field_sync_demux to consume input even when not creating
output. Added python files to make a complete 2.x atsc receiver, but it is not fully working. It will happily produce the exact same amount of transport stream output as a working system but has errors in the data. git-svn-id: http://gnuradio.org/svn/gnuradio/trunk@5081 221aa14e-8319-0410-a670-987f0aec2ac5
Diffstat (limited to 'gr-atsc/src/python')
-rw-r--r--gr-atsc/src/python/README32
-rwxr-xr-xgr-atsc/src/python/btl-fsd.py28
-rwxr-xr-xgr-atsc/src/python/fpll.py84
-rwxr-xr-xgr-atsc/src/python/interp.py74
-rwxr-xr-xgr-atsc/src/python/viterbi-out.py55
-rwxr-xr-xgr-atsc/src/python/xlate.py54
6 files changed, 327 insertions, 0 deletions
diff --git a/gr-atsc/src/python/README b/gr-atsc/src/python/README
new file mode 100644
index 0000000000..c5dd4af933
--- /dev/null
+++ b/gr-atsc/src/python/README
@@ -0,0 +1,32 @@
+Currently the best, fastest software decode is by using
+19.2MSps over 5 processes.
+
+1) Capture data - adjust gain (-g) frequency (-f) and which side
+the tvrx is on to fit your local setup:
+
+usrp_rx_cfile -R B -d 10 -g 65 -f 503e6 atsc_data_6-4m_complex
+
+
+2) Make pipes:
+
+mkfifo /tmp/atsc_pipe_1
+mkfifo /tmp/atsc_pipe_2
+mkfifo /tmp/atsc_pipe_3
+mkfifo /tmp/atsc_pipe_4
+mkfifo /tmp/atsc_pipe_5
+
+3) In seperate windows run processes:
+
+./interp.py <input rf data at 6.4Msps>
+./xlate.py
+./fpll.py
+./btl-fsd.py
+./viterbi-out.py <output mpeg transport stream>
+
+
+Status: Not fully working.
+
+Currently gr-atsc 2.x will produce the exact amount of data as a working system,
+but there are a some differences in the output. If you substitute the btl-fsd.py
+block with the corresponding code from gnuradio-0.9 it works.
+
diff --git a/gr-atsc/src/python/btl-fsd.py b/gr-atsc/src/python/btl-fsd.py
new file mode 100755
index 0000000000..ed26f4bbce
--- /dev/null
+++ b/gr-atsc/src/python/btl-fsd.py
@@ -0,0 +1,28 @@
+#!/usr/bin/python
+
+from gnuradio import gr
+from gnuradio import atsc
+
+fg = gr.flow_graph()
+
+btl = atsc.bit_timing_loop()
+fsc = atsc.fs_checker()
+eq = atsc.equalizer()
+fsd = atsc.field_sync_demux()
+
+out_data = gr.file_sink(atsc.sizeof_atsc_soft_data_segment,"/tmp/atsc_pipe_5")
+
+inp = gr.file_source(gr.sizeof_float,"/tmp/atsc_pipe_3")
+
+fg.connect(inp,btl)
+fg.connect((btl,0),(fsc,0))
+fg.connect((btl,1),(fsc,1))
+fg.connect((fsc,0),(eq,0))
+fg.connect((fsc,1),(eq,1))
+fg.connect((eq,0),(fsd,0))
+fg.connect((eq,1),(fsd,1))
+fg.connect(fsd,out_data)
+
+fg.run()
+
+
diff --git a/gr-atsc/src/python/fpll.py b/gr-atsc/src/python/fpll.py
new file mode 100755
index 0000000000..0788d0fb0c
--- /dev/null
+++ b/gr-atsc/src/python/fpll.py
@@ -0,0 +1,84 @@
+#!/usr/bin/env python
+#
+# Copyright 2004,2005 Free Software Foundation, Inc.
+#
+# This file is part of GNU Radio
+#
+# GNU Radio is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# GNU Radio is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GNU Radio; see the file COPYING. If not, write to
+# the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+# Boston, MA 02111-1307, USA.
+#
+
+from gnuradio import gr, atsc
+import math
+
+def main():
+
+ fg = gr.flow_graph()
+
+ u = gr.file_source(gr.sizeof_float,"/tmp/atsc_pipe_2")
+
+ input_rate = 19.2e6
+ IF_freq = 5.75e6
+
+
+ # 1/2 as wide because we're designing lp filter
+ symbol_rate = atsc.ATSC_SYMBOL_RATE/2.
+ NTAPS = 279
+ tt = gr.firdes.root_raised_cosine (1.0, input_rate, symbol_rate, .115, NTAPS)
+ # heterodyne the low pass coefficients up to the specified bandpass
+ # center frequency. Note that when we do this, the filter bandwidth
+ # is effectively twice the low pass (2.69 * 2 = 5.38) and hence
+ # matches the diagram in the ATSC spec.
+ arg = 2. * math.pi * IF_freq / input_rate
+ t=[]
+ for i in range(len(tt)):
+ t += [tt[i] * 2. * math.cos(arg * i)]
+ rrc = gr.fir_filter_fff(1, t)
+
+ fpll = atsc.fpll()
+
+ pilot_freq = IF_freq - 3e6 + 0.31e6
+ lower_edge = 6e6 - 0.31e6
+ upper_edge = IF_freq - 3e6 + pilot_freq
+ transition_width = upper_edge - lower_edge
+ lp_coeffs = gr.firdes.low_pass (1.0,
+ input_rate,
+ (lower_edge + upper_edge) * 0.5,
+ transition_width,
+ gr.firdes.WIN_HAMMING);
+
+ lp_filter = gr.fir_filter_fff (1,lp_coeffs)
+
+ alpha = 1e-5
+ iir = gr.single_pole_iir_filter_ff(alpha)
+ remove_dc = gr.sub_ff()
+
+ out = gr.file_sink(gr.sizeof_float,"/tmp/atsc_pipe_3")
+ # out = gr.file_sink(gr.sizeof_float,"/mnt/sata/atsc_data_float")
+
+ fg.connect(u, fpll, lp_filter)
+ fg.connect(lp_filter, iir)
+ fg.connect(lp_filter, (remove_dc,0))
+ fg.connect(iir, (remove_dc,1))
+ fg.connect(remove_dc, out)
+
+ fg.run()
+
+
+if __name__ == '__main__':
+ main ()
+
+
+
diff --git a/gr-atsc/src/python/interp.py b/gr-atsc/src/python/interp.py
new file mode 100755
index 0000000000..36cc72447b
--- /dev/null
+++ b/gr-atsc/src/python/interp.py
@@ -0,0 +1,74 @@
+#!/usr/bin/env /usr/bin/python
+#
+# Copyright 2004 Free Software Foundation, Inc.
+#
+# This file is part of GNU Radio
+#
+# GNU Radio is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# GNU Radio is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GNU Radio; see the file COPYING. If not, write to
+# the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+# Boston, MA 02111-1307, USA.
+#
+# This module starts the atsc processing chain taking the captured
+# off-air signal created with:
+#
+# usrp_rx_cfile.py -R <side with tuner, a or b>
+# -d 10 set decimation to get signal at 6.4e6 rate
+# -f <center of tv signal channel freq>
+# -g <appropriate gain for best signal / noise>
+#
+# All this module does is multiply the sample rate by 3, from 6.4e6 to
+# 19.2e6 complex samples / sec, then lowpass filter with a cutoff of 3.2MHz
+# and a transition band width of .5MHz. Center of the tv channels is
+# then at 0 with edges at -3.2MHz and 3.2MHz.
+
+from gnuradio import gr
+import sys
+
+def graph (args):
+
+ nargs = len (args)
+ if nargs == 1:
+ infile = args[0]
+ else:
+ sys.stderr.write('usage: interp.py input_file\n')
+ sys.exit (1)
+
+ sampling_freq = 6400000
+
+ fg = gr.flow_graph ()
+
+ src0 = gr.file_source (gr.sizeof_gr_complex,infile)
+ src1 = gr.sig_source_c (sampling_freq, gr.GR_CONST_WAVE, 1, 0)
+ src2 = gr.sig_source_c (sampling_freq, gr.GR_CONST_WAVE, 1, 0)
+
+ interlv = gr.interleave(gr.sizeof_gr_complex)
+
+ lp_coeffs = gr.firdes.low_pass ( 3, 19.2e6, 3.2e6, .5e6, gr.firdes.WIN_HAMMING )
+ lp = gr.fir_filter_ccf ( 1, lp_coeffs )
+
+ file = gr.file_sink(gr.sizeof_gr_complex,"/tmp/atsc_pipe_1")
+
+ fg.connect( src0, (interlv, 0) )
+ fg.connect( src1, (interlv, 1) )
+ fg.connect( src2, (interlv, 2) )
+ fg.connect( interlv, lp, file )
+
+ fg.start()
+ raw_input ('Head End: Press Enter to stop')
+ fg.stop()
+
+if __name__ == '__main__':
+ graph (sys.argv[1:])
+
+
diff --git a/gr-atsc/src/python/viterbi-out.py b/gr-atsc/src/python/viterbi-out.py
new file mode 100755
index 0000000000..f74900b34d
--- /dev/null
+++ b/gr-atsc/src/python/viterbi-out.py
@@ -0,0 +1,55 @@
+#!/usr/bin/env python
+#
+# Copyright 2004,2006 Free Software Foundation, Inc.
+#
+# This file is part of GNU Radio
+#
+# GNU Radio is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# GNU Radio is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GNU Radio; see the file COPYING. If not, write to
+# the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+# Boston, MA 02111-1307, USA.
+#
+
+from gnuradio import gr, atsc
+import sys
+
+def main(args):
+
+ nargs = len (args)
+ if nargs == 1:
+ outfile = args[0]
+ else:
+ sys.stderr.write ('usage: viterbi_out.py output_file\n')
+ sys.exit (1)
+
+ fg = gr.flow_graph()
+
+ src = gr.file_source(atsc.sizeof_atsc_soft_data_segment, "/tmp/atsc_pipe_5")
+ viterbi = atsc.viterbi_decoder()
+ deinter = atsc.deinterleaver()
+ rs_dec = atsc.rs_decoder()
+ derand = atsc.derandomizer()
+ depad = atsc.depad()
+ dst = gr.file_sink(gr.sizeof_char,outfile)
+ fg.connect(src, viterbi, deinter, rs_dec, derand, depad, dst)
+ fg.run ()
+
+
+if __name__ == '__main__':
+ main(sys.argv[1:])
+
+
+
+
+
+
diff --git a/gr-atsc/src/python/xlate.py b/gr-atsc/src/python/xlate.py
new file mode 100755
index 0000000000..4a7171d4df
--- /dev/null
+++ b/gr-atsc/src/python/xlate.py
@@ -0,0 +1,54 @@
+#!/usr/bin/env /usr/bin/python
+#
+# Copyright 2004 Free Software Foundation, Inc.
+#
+# This file is part of GNU Radio
+#
+# GNU Radio is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# GNU Radio is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GNU Radio; see the file COPYING. If not, write to
+# the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+# Boston, MA 02111-1307, USA.
+#
+# This module upconverts the 19.2e6 sample rate signal from a center
+# of 0 to 5.75e6 and converts to float, to prepare the signal for
+# the old gnuradio 0.9 block (bit timing loop, field sync checker,
+# equalizer and field sync demux), effectively simulating an
+# mc4020 card, except the sample rate is 19.2e6 instead of 20e6.
+#
+# The signal is then centered on 5.75e6 with edges at 5.75 + 3.2 = 8.95MHz
+# and 5.75 - 3.2 = 2.55Mhz, low pass filtered with cutoff at 9Mhz and a
+# transition band width of 1Mhz.
+#
+# Input complex -3.2 to 3.2Mhz, output float 2.55 to 8.95Mhz.
+
+from gnuradio import gr
+
+def graph ():
+ sampling_freq = 19200000
+
+ fg = gr.flow_graph ()
+
+ src0 = gr.file_source (gr.sizeof_gr_complex,"/tmp/atsc_pipe_1")
+
+ duc_coeffs = gr.firdes.low_pass ( 1, 19.2e6, 9e6, 1e6, gr.firdes.WIN_HAMMING )
+ duc = gr.freq_xlating_fir_filter_ccf ( 1, duc_coeffs, 5.75e6, 19.2e6 )
+
+ c2f = gr.complex_to_float()
+ file = gr.file_sink(gr.sizeof_float,"/tmp/atsc_pipe_2")
+
+ fg.connect( src0, duc, c2f, file )
+
+ fg.run()
+
+if __name__ == '__main__':
+ graph ()