From 4fc3f0dcdb30e4b5168cce3e71d5bb91312af962 Mon Sep 17 00:00:00 2001 From: baobrien Date: Tue, 28 Jun 2016 06:24:51 +0000 Subject: [PATCH] Added adc plotter git-svn-id: https://svn.code.sf.net/p/freetel/code@2832 01035d8c-6547-0410-b346-abe4f91aad63 --- codec2-dev/octave/adc_plot_spec.m | 51 +++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100755 codec2-dev/octave/adc_plot_spec.m diff --git a/codec2-dev/octave/adc_plot_spec.m b/codec2-dev/octave/adc_plot_spec.m new file mode 100755 index 00000000..ceba542b --- /dev/null +++ b/codec2-dev/octave/adc_plot_spec.m @@ -0,0 +1,51 @@ +#!/usr/bin/env octave +% Plot the spectrum and waveform coming off of the ADC + +% Author: Brady O'Brien 28 June 2016 + +% Copyright 2016 Brady O'Brien +% +% All rights reserved. +% +% This program is free software; you can redistribute it and/or modify +% it under the terms of the GNU Lesser General Public License version 2, as +% published by the Free Software Foundation. This program is +% distributed in the hope that it will be useful, but WITHOUT ANY +% WARRANTY; without even the implied warranty of MERCHANTABILITY or +% FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public +% License for more details. +% +% You should have received a copy of the GNU Lesser General Public License +% along with this program; if not, see . + + +%adc_file_name = '/home/baobrien/workspace/freetel-code/codec2-dev/stm32/adc_samp' +%adc_file_name = '/dev/ttyACM1' +%adc_file_name = 'infifo'; +fs = 96000 +sampsize = 96000 +%graphics_toolkit('gnuplot') + +fin = fopen(adc_file_name,'r') +first = 1 +cont = 0 +sampinc = (1/sampsize)*fs + +[samps cont] = fread(fin,sampsize,'short'); +y = (1:(sampsize/2)); +yp = (1:sampsize/2)*(fs/(sampsize/2)); +pltdat = plot(10*log10(abs(fft(samps)(y)))); +pltx = 10*log10(abs(fft(samps)(y))); +axis([0 fs 20 90]) +set (pltdat, "ydatasource", "pltx"); +set (pltdat, "xdatasource", "yp"); +%set (pltdat, "ydatasource", "y"); + +while(first || cont==sampsize) + first = 0; + %sleep(.001); + [samps cont] = fread(fin,sampsize,'short'); + pltx = 10*log10(abs(fft(samps)(y))); + refreshdata + refresh +endwhile -- 2.25.1