1
0
mirror of git://projects.qi-hardware.com/ben-wpan.git synced 2024-11-25 08:26:14 +02:00

usrp/sps/: spectrum scan utilities (work in progress)

- collect: set up a test transmission at each available frequency, then
  then record the signal seen by the USRP2
- norm: extract parameters necessary for normalization
- viz: visualize the spectrum with gnuplot
- row: generate rows of spectra with "viz"
This commit is contained in:
Werner Almesberger 2011-03-03 23:26:31 -03:00
parent da8962344c
commit fd27bdc442
4 changed files with 130 additions and 0 deletions

14
usrp/sps/collect Executable file
View File

@ -0,0 +1,14 @@
#!/bin/sh
if ! [ "$1" ]; then
echo "usage: $0 prefix" 2>&1
exit 1
fi
f=2405
while [ $f -le 2480 ]; do
f1=`expr $f + 1`
atrf-txrx -f $f -p 4 -T -0.5 \
'sleep 1; usrp2_rx_cfile.py -d 16 -g 46 -f '$f'M -N 1M '$1-$f
atrf-txrx -f $f -p 4 -T +0.5 \
'sleep 1; usrp2_rx_cfile.py -d 16 -g 46 -f '$f1'M -N 1M '$1-$f1
f=`expr $f + 5`
done

10
usrp/sps/norm Executable file
View File

@ -0,0 +1,10 @@
#!/usr/bin/perl
for ($n = 0; <>; $n++) {
if ($_ > $ym || !defined $ym) {
$xm = $n;
chop($ym = $_);
}
}
print "$xm $ym $n\n";

37
usrp/sps/row Executable file
View File

@ -0,0 +1,37 @@
#!/bin/sh
export GDFONTPATH
GDFONTPATH=$GDFONTPATH:/usr/share/fonts/truetype/ttf-liberation/
if ! [ "$1" ]; then
echo "usage: $0 prefix" 2>&1
exit 1
fi
prefix=$1
echo "<TR><TH>$prefix"
f=2405
while [ $f -le 2480 ]; do
echo "<TD align="center">$f MHz"
f=`expr $f + 5`
done
echo "<TR><TD align="right">-0.5 MHz"
f=2405
while [ $f -le 2480 ]; do
./viz -f LiberationSans-Bold -p $prefix-$f.png $prefix $f
convert -resize '15%' $prefix-$f.png $prefix-$f-small.png
echo "<TD><A href=\"$prefix-$f.png\"><IMG src=\"$prefix-$f-small.png\"></A>"
f=`expr $f + 5`
done
echo "<TR><TD align="right">+0.5 MHz"
f=2405
while [ $f -le 2480 ]; do
f1=`expr $f + 1`
./viz -f LiberationSans-Bold -p $prefix-$f1.png $prefix $f1
convert -resize '15%' $prefix-$f1.png $prefix-$f1-small.png
echo "<TD><A href=\"$prefix-$f1.png\"><IMG src=\"$prefix-$f1-small.png\"></A>"
f=`expr $f + 5`
done

69
usrp/sps/viz Executable file
View File

@ -0,0 +1,69 @@
#!/bin/sh
usage()
{
echo "usage: $0 [-f font] prefix frequency" 1>&2
exit 1
}
font=
term=
output=
while true; do
case "$1" in
-f) [ "$2" ] || usage
shift
font=$1
shift;;
-p) [ "$2" ] || usage
shift
term="set term png"
output="set output \"$1\""
shift;;
*)
break;;
esac
done
[ "$2" ] || usage
[ "$3" ] && usage
prefix=$1
f=$2
../fft -s 100 -d -w hamming 100 <./$prefix-$f >_tmp
set `./norm _tmp`
xm=$1.0 # sample number of y peak
ym=$2 # magnitude of y peak
n=$3 # total number of samples
span=6.25 # ADC sample rate in MHz / decimation (100 MHz/16)
gnuplot -persist <<EOF
$term
$output
set label "$prefix" at graph 0.03, graph 0.93 font "$font,22"
set label sprintf("+%.1f dB", $ym) at graph 0.03, graph 0.82 font "$font,18"
set label sprintf("%.1f MHz", $f-0.5) \
at graph 0.97, graph 0.93 right font "$font,22"
set label sprintf("+%.1f ppm", (($xm/$n-0.5)*$span+0.5)/($f-0.5)*1000000) \
at graph 0.97, graph 0.82 right font "$font,18"
set xrange [-2.5:2.5]
set yrange [-70:0]
set mxtics 10
set mytics 2
set grid
set xlabel "MHz from nominal frequency of test wave"
set style fill solid 1
plot "_tmp" using ((\$0/$n-0.5)*$span+0.5):(\$1-$ym) with lines notitle, \
"<echo -0.9 -$ym 0.2" with boxes notitle
EOF
rm -f _tmp