IEEE 802.15.4 subsystem
Sign in or create your account | Project List | Help
IEEE 802.15.4 subsystem Git Source Tree
Root/
| Source at commit 03ee256a3b1a774e72bc79a65e02e62a56fc62dd created 7 years 22 days ago. By Stefan Schmidt, web: add 0.3 firmware binaries into release folder for web page | |
|---|---|
| 1 | #!/bin/sh |
| 2 | |
| 3 | PATH=..:$PATH |
| 4 | |
| 5 | usage() |
| 6 | { |
| 7 | echo "usage: $0 [-f font] [-m] [-o fft_file] [-p png_file] prefix \ |
| 8 | frequency" 1>&2 |
| 9 | exit 1 |
| 10 | } |
| 11 | |
| 12 | |
| 13 | font= |
| 14 | term= |
| 15 | output= |
| 16 | show_max=false |
| 17 | out= |
| 18 | |
| 19 | while true; do |
| 20 | case "$1" in |
| 21 | -f) [ "$2" ] || usage |
| 22 | shift |
| 23 | font=$1;; |
| 24 | -m) show_max=true;; |
| 25 | -o) [ "$2" ] || usage |
| 26 | shift |
| 27 | out=$1;; |
| 28 | -p) [ "$2" ] || usage |
| 29 | shift |
| 30 | term="set term png" |
| 31 | output="set output \"$1\"";; |
| 32 | -*) usage;; |
| 33 | *) |
| 34 | break;; |
| 35 | esac |
| 36 | shift |
| 37 | done |
| 38 | |
| 39 | [ "$2" ] || usage |
| 40 | [ "$3" ] && usage |
| 41 | |
| 42 | tmp=${out:-_tmp} |
| 43 | prefix=$1 |
| 44 | f=$2 |
| 45 | |
| 46 | fft -s 100 -d -w hamming 100 <$prefix-$f >$tmp |
| 47 | set `norm $tmp` |
| 48 | |
| 49 | xm=$1.0 # sample number of y peak |
| 50 | ym=$2 # magnitude of y peak |
| 51 | n=$3 # total number of samples |
| 52 | span=6.25 # ADC sample rate in MHz / decimation (100 MHz/16) |
| 53 | |
| 54 | if [ ${ym#-} = $ym ]; then |
| 55 | ymbar=-$ym |
| 56 | ymbarlt=2 |
| 57 | else |
| 58 | ymbar=$ym |
| 59 | ymbarlt=1 |
| 60 | fi |
| 61 | |
| 62 | gnuplot -persist <<EOF |
| 63 | $term |
| 64 | $output |
| 65 | |
| 66 | set label "$prefix" at graph 0.03, graph 0.93 font "$font,22" |
| 67 | set label sprintf("%+.1f dB", $ym) at graph 0.03, graph 0.82 font "$font,18" |
| 68 | |
| 69 | set label sprintf("%.1f MHz", $f-0.5) \ |
| 70 | at graph 0.97, graph 0.93 right font "$font,22" |
| 71 | set label sprintf("%+.1f ppm", (($xm/$n-0.5)*$span+0.5)/($f-0.5)*1000000) \ |
| 72 | at graph 0.97, graph 0.82 right font "$font,18" |
| 73 | |
| 74 | set xrange [-2.5:2.5] |
| 75 | set yrange [-70:0] |
| 76 | |
| 77 | set mxtics 10 |
| 78 | set mytics 2 |
| 79 | set grid |
| 80 | |
| 81 | set xlabel "MHz from nominal frequency of test wave" |
| 82 | |
| 83 | set style fill solid 1 |
| 84 | plot "$tmp" using ((\$0/$n-0.5)*$span+0.5):(\$1-$ym) with lines notitle, \ |
| 85 | "<echo -0.9 $ymbar 0.2" with boxes lt $ymbarlt notitle |
| 86 | EOF |
| 87 | |
| 88 | [ "$out" ] || rm -f $tmp |
| 89 | $show_max && echo $ym |
| 90 | |
