# ATSC decoder example in GR 3.7.1

**URL:** <https://www.ruby-forum.com/t/atsc-decoder-example-in-gr-3-7-1/236974>\
**Category:** GNU Radio\
**Created:** [October 16, 2013, 4:02am UTC](https://www.ruby-forum.com/t/atsc-decoder-example-in-gr-3-7-1/236974 "2013-10-16T04:02:23Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![addis\_a](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/c4cdca/32.png) [@addis\_a](https://www.ruby-forum.com/u/addis_a)\
**Post date:** [October 16, 2013, 4:02am UTC](https://www.ruby-forum.com/t/atsc-decoder-example-in-gr-3-7-1/236974/1 "2013-10-16T04:02:23Z")

</div>

As a part of my quest to understand some of the examples in GR (and  
eventually contribute some well-commented GRC examples of my own),  
I’ve been messing around with the atsc\_rx.py script. Unfortunately,  
since I have a USRP2, I can’t sample at 6.4Msps like the script wants.  
Instead, I tried sampling a strong local TV station at 10Msps and  
resampling at 6.4Msps, but the result is a ton of errors in the  
script’s output and a large TS file that I can’t make sense of.

I tried the following steps. First, capture a few seconds of raw TV  
signal (channel 39 in my area is the physical frequency of WSB):

uhd\_rx\_cfile -f 623M --samp-rate=10M -s wsb.iq

In a local copy of atsc\_rx.py, I added the following filter:

resamp = filter.fractional\_resampler\_cc(0, 10/6.4)

Then I added the resampler to the graph at the bottom of the script:

tb.connect( srcf, is2c, resamp, rrc, ilp, duc, c2f, fpll, lp\_filter)

Finally I ran the script:

./atsc\_rx.py wsb.iq wsb.ts

The console fills with errors related to the ATSC stream:

8404  
Using Volk machine: avx\_64\_mmx\_orc  
Setting initial\_freq: 3065000.000000  
atsc\_field\_sync\_demux: synced (FIELD-1) at 426209 [delta = 426209]  
atsc\_viterbi\_decoder: new starting offset = 0  
atsc\_field\_sync\_demux: lost sync at 464481  
!!! atsci\_equalizer: expected field sync, didn’t find one  
atsc\_field\_sync\_demux: segment number overflow  
atsc\_viterbi\_decoder: new starting offset = 7  
!!! atsci\_equalizer: expected field sync, didn’t find one  
atsc\_field\_sync\_demux: segment number overflow  
atsc\_field\_sync\_demux: lost sync at 1225761  
atsc\_viterbi\_decoder: new starting offset = 1…

(and so on, many times over)

I tried playing the output TS in vlc and reading it with avconv, but  
both programs found tons of errors with the file and couldn’t do  
anything useful with it. For the record, with some tweaking of the Tx  
settings, I was able to transmit the captured IQ file over the air and  
play the clip on a nearby TV (on a different, unused channel), so I  
know the data is in there somewhere.

My eventual goal is to turn this script into a GRC version, complete  
with GRC xml files for the ATSC blocks currently included in GR.  
However, I can’t begin this process without having it working in the  
first place. Is there anyone out there who understands the current  
script and can modify it to work with an adjustable input sample rate?  
That would go a long way toward helping me understand it all. Thanks  
in advance.

Ethan T (courtarro)

---

<div class="post-metadata">

**Author:** ![Ethan\_Trewhitt](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/ecb155/32.png) [@Ethan\_Trewhitt](https://www.ruby-forum.com/u/Ethan_Trewhitt)\
**Post date:** [October 22, 2013, 10:44pm UTC](https://www.ruby-forum.com/t/atsc-decoder-example-in-gr-3-7-1/236974/2 "2013-10-22T22:44:43Z")

</div>

On Tue, Oct 15, 2013 at 10:01 PM, Ethan Trewhitt  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> As a part of my quest to understand some of the examples in GR (and  
> eventually contribute some well-commented GRC examples of my own),  
> I’ve been messing around with the atsc\_rx.py script. Unfortunately,  
> since I have a USRP2, I can’t sample at 6.4Msps like the script wants.  
> Instead, I tried sampling a strong local TV station at 10Msps and  
> resampling at 6.4Msps, but the result is a ton of errors in the  
> script’s output and a large TS file that I can’t make sense of.

Hi Ethan,

I just wanted to point out that we’ve been working with Andrew D.  
on fixing up ATSC to a) work better and b) work with 3.7. He’s made a  
good start on things here:

[https://github.com/glneo/gnuradio/tree/atscfixup](https://github.com/glneo/gnuradio/tree/atscfixup)

There’s still work to be done, and Johnathan and I have been talking  
about how to best get this into GNU Radio. If you’re pursuing this  
project, definitely look here and maybe talk directly with Andrew.  
He’s apparently gotten pretty busy with school work this semester, so  
having another person working on this might be really good to finish  
it up.

Thanks,  
Tom
