TV signal testing using Python and inexpensive USB TV tuners

Introduction

Here is some preliminary information on a Python program I developed for doing TV signal tests. Multiple antennas with different orientations are mounted on a of a top a vehicle and connected to multiple tuners. While not as accurate as using a 10 meter mast driven along a 30 meter path this method should provide results more in line with what viewers with low outdoor or indoor antennas will receive. This setup using four tuners and four antennas allowed measuring eleven channels (44 measurements total) in under 8 minutes.

The sigtest.py program loads a list of channels in the "zap" format. It cycles through the list, tuning a USB tuner to each channel in the list and records the tuner status, signal level, bit error rate (BER), signal-to-noise ratio (SNR), number of uncorrected packets and lock status. An average of the readings is stored in the avesiglog.csv file and the last reading is from each channel is logged to separate csv files. Each reading is stamped with time and location data from a text file continously updated by the gpsdatalog.py program.

This program was tested with Python versions 2.7.8 and 2.7.9. The sigtest.py program depends on the ZapLib library and Pyzap Python bindings. It evolved from the test.py program provided with PyZap.

Dependencies:

For more information on the dvb-apps and zap see these LinuxTV sites:

sigtest.py

Download

Logging GPS location and time

The time and location fields in the sigtest.py log files are obtained by reading the last line of the gpslog.txt file that is continuously updated by the gpsdatalog program. While it would be nice to have the GPS data generated directly in the sigtest.py program, I'm still learning how to do multithreaded processing in Python. Writing the GPS data to the text file provides a continuous record of where the test vehicle was during the measurements. This program will crash badly if gpsd is not running when it is launched. You can easily check gpsd status as well as gps reception using the xgps program.

Dan Mandle, who wrote the program that's makes up the core of the gpsdatalog.py program, has an excellent description of how to get gpsd running on his page Getting GPSd to work with Python and Threading. More detailed instructions on installing and using gpsd, as well as some helpful troubleshooting tips, can be found at gpsd -- a GPS service daemon. Make sure gpsd is working before running gpsdatalog.py.

gpsdatalog.py

Download