Added adc plotter
authorbaobrien <baobrien@01035d8c-6547-0410-b346-abe4f91aad63>
Tue, 28 Jun 2016 06:24:51 +0000 (06:24 +0000)
committerbaobrien <baobrien@01035d8c-6547-0410-b346-abe4f91aad63>
Tue, 28 Jun 2016 06:24:51 +0000 (06:24 +0000)
git-svn-id: https://svn.code.sf.net/p/freetel/code@2832 01035d8c-6547-0410-b346-abe4f91aad63

codec2-dev/octave/adc_plot_spec.m [new file with mode: 0755]

diff --git a/codec2-dev/octave/adc_plot_spec.m b/codec2-dev/octave/adc_plot_spec.m
new file mode 100755 (executable)
index 0000000..ceba542
--- /dev/null
@@ -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 <http://www.gnu.org/licenses/>.
+
+
+%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