diff options
author | Andrej Rode <andrej.rode@ettus.com> | 2016-10-24 10:25:42 -0700 |
---|---|---|
committer | Martin Braun <martin.braun@ettus.com> | 2017-05-26 16:01:37 -0700 |
commit | 76e9e6393fe1d5a0ccc9e05deb431694921850ec (patch) | |
tree | b7f1097a04fd7a7d0a423a353fbeba037746b782 /tools/gr-usrptest/apps | |
parent | 06ff34eaa9e147b11d2698308fa91a5260fee2d2 (diff) | |
download | uhd-76e9e6393fe1d5a0ccc9e05deb431694921850ec.tar.gz uhd-76e9e6393fe1d5a0ccc9e05deb431694921850ec.tar.bz2 uhd-76e9e6393fe1d5a0ccc9e05deb431694921850ec.zip |
gr-usrptest: Initial creation
- new OOT-blocks: phase_calc_ccf hier-block, measurement_sink_f
- new python submodules: flowgraphs, functions, rts_tests
- new apps: usrp_phasealignment.py - cmdline example for manual testing
OOT-Blocks:
- phase_calc_ccf takes two complex input streams and conjugate
multiplys them and extracts the phase from the result and converts
it to degree scale
- measurement_sink_f: takes a float input stream and calculates average and stddev for a
specified number of samples. Start of a measurement is invoked by a
call of start_run() on the block. After a couple of runs average and
stddev can be extracted.
Python modules:
- flowgrahps contains reconfigurable flowgraphs for different GNU
Radio RF test cases
- functions contains functions which are used in different apps/RTS
scripts
- rts_tests contains test cases which are meant to be executed from
the RTS system. Depends on TinyDB, labview_automation
Apps:
- usrp_phasealignment.py is an example how to use the underlying
flowgraph to measure phase differences. Commandline arguments of
uhd_app can be used and several additional arguments can/have to be
specified. Runs a phase difference measurement --runs number of times and averages
phase difference over --duration seconds. Between measurements USRP
sinks are retuned to random frequencies in daughterboard range.
Results are displayed using motherboard serial and daughterboard
serial
Diffstat (limited to 'tools/gr-usrptest/apps')
-rw-r--r-- | tools/gr-usrptest/apps/CMakeLists.txt | 1 | ||||
-rwxr-xr-x | tools/gr-usrptest/apps/usrp_phasealignment.py | 72 | ||||
-rwxr-xr-x | tools/gr-usrptest/apps/usrp_selftest.py | 17 |
3 files changed, 90 insertions, 0 deletions
diff --git a/tools/gr-usrptest/apps/CMakeLists.txt b/tools/gr-usrptest/apps/CMakeLists.txt index c837d77f6..a40192924 100644 --- a/tools/gr-usrptest/apps/CMakeLists.txt +++ b/tools/gr-usrptest/apps/CMakeLists.txt @@ -21,5 +21,6 @@ include(GrPython) GR_PYTHON_INSTALL( PROGRAMS + usrp_phasealignment.py DESTINATION bin ) diff --git a/tools/gr-usrptest/apps/usrp_phasealignment.py b/tools/gr-usrptest/apps/usrp_phasealignment.py new file mode 100755 index 000000000..928788be4 --- /dev/null +++ b/tools/gr-usrptest/apps/usrp_phasealignment.py @@ -0,0 +1,72 @@ +#!/usr/bin/env python + +from gnuradio.uhd.uhd_app import UHDApp +from usrptest.flowgraphs import phasealignment_fg +from usrptest.functions import run_test, setup_phase_alignment_parser, setup_tx_phase_alignment_parser, setup_manual_phase_alignment_parser +import time +import argparse + + +def plot_results(results): + import matplotlib.pyplot as plt + ax = plt.axes() + ax.set_ylim(-180, 180) + for result in results: + plt.errorbar( + range(len(result['avg'])), + result["avg"], + result["stddev"], + label="{} - {}".format(result["first"], result["second"]), + axes=ax) + ax.legend(loc='upper left', bbox_to_anchor=(0.0, 0.0)) + plt.show() + + +def print_results(results): + for result in results: + print('Results for: {first} - {second}'.format( + first=result['first'], second=result['second'])) + for i, (avg, + stddev) in enumerate(zip(result['avg'], result['stddev'])): + print('\t {}. run avg: {}, stddev: {}'.format(i + 1, avg, stddev)) + + +def main(): + parser = argparse.ArgumentParser(conflict_handler='resolve') + UHDApp.setup_argparser(parser=parser) + parser = setup_phase_alignment_parser(parser) + parser = setup_tx_phase_alignment_parser(parser) + parser = setup_manual_phase_alignment_parser(parser) + args = parser.parse_args() + test_app = UHDApp(args=args) + if args.auto and args.start_freq and args.stop_freq: + from random import uniform + bw = (args.stop_freq - args.start_freq) / args.freq_bands + for nband in range(args.freq_bands): + freq1 = args.start_freq + nband * bw + new_freq = uniform(freq1, freq1 + bw) + test_app.args.freq = new_freq + raw_input( + "New test frequency: {:f} MHz. Adjust your signal generator and press ENTER to start measurement.". + format(new_freq / 1e6)) + fg = phasealignment_fg.phasealignment_fg(test_app) + fg.start() + results = run_test(fg, args.runs) + fg.stop() + fg.wait() + if args.plot: + plot_results(results) + print_results(results) + else: + fg = phasealignment_fg.phasealignment_fg(test_app) + fg.start() + results = run_test(fg, args.runs) + fg.stop() + fg.wait() + if args.plot: + plot_results(results) + print_results(results) + + +if __name__ == '__main__': + main() diff --git a/tools/gr-usrptest/apps/usrp_selftest.py b/tools/gr-usrptest/apps/usrp_selftest.py new file mode 100755 index 000000000..3dcd4e6ca --- /dev/null +++ b/tools/gr-usrptest/apps/usrp_selftest.py @@ -0,0 +1,17 @@ +#!/usr/bin/env python + +import argparse +from usrptest import parsers +from usrptest.flowgraphs import selftest_fg + + +def main(): + parser = argparse.ArgumentParser() + parser = parsers.add_core_args(parser) + parser = parsers.add_selftest_args(parser) + args = parser.parse_args() + my_flowgraph = selftest_fg.selftest_fg(args.frequency, args.samp_rate, args.dphase ,args.devices) + results = my_flowgraph.run() + print(results) +if __name__ == '__main__': + main() |