Scans through the D/A converter values, and copies a set of A/D converter readings to a file on USB local filesystem. Connect pin 18 to pin 17.

Dependencies:   mbed

Committer:
Mischa
Date:
Fri Dec 10 05:56:45 2010 +0000
Revision:
1:d9d6cf136120
Now includes a matlab script to show some of the results (overview.m, included as overview.cpp).

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Mischa 1:d9d6cf136120 1 % matlab code to plot results (multiple files):
Mischa 1:d9d6cf136120 2
Mischa 1:d9d6cf136120 3 fs={'OUT.TXT'
Mischa 1:d9d6cf136120 4 'OUTPSU.TXT'
Mischa 1:d9d6cf136120 5 'OUTUSBtiedgnd.TXT'
Mischa 1:d9d6cf136120 6 'OUTPSUtiedgnd.TXT'
Mischa 1:d9d6cf136120 7 'OUTUSBlongwait.TXT'
Mischa 1:d9d6cf136120 8 'OUTPSUlongwait.TXT'
Mischa 1:d9d6cf136120 9 'OUTUSBtiedgndlongwait.TXT'
Mischa 1:d9d6cf136120 10 'OUTPSUtiedgndlongwait.TXT'};
Mischa 1:d9d6cf136120 11 clear d
Mischa 1:d9d6cf136120 12 for i=1:numel(fs),
Mischa 1:d9d6cf136120 13 fh=fopen(fs{i},'r');
Mischa 1:d9d6cf136120 14 d(:,:,i)=fix(fread(fh,[100,1024],'uint16')/16);
Mischa 1:d9d6cf136120 15 fclose(fh);
Mischa 1:d9d6cf136120 16 end
Mischa 1:d9d6cf136120 17
Mischa 1:d9d6cf136120 18 %all the measurements as dots:
Mischa 1:d9d6cf136120 19 figure
Mischa 1:d9d6cf136120 20 m=0:1023;
Mischa 1:d9d6cf136120 21 m=repmat(m*4,[size(d,1),1,size(d,3)]);
Mischa 1:d9d6cf136120 22 c='rgbmrgbm';
Mischa 1:d9d6cf136120 23 for i=5:8,
Mischa 1:d9d6cf136120 24 plot(m(:,:,i),d(:,:,i),[c(i) '.']); hold on
Mischa 1:d9d6cf136120 25 end
Mischa 1:d9d6cf136120 26 axis tight
Mischa 1:d9d6cf136120 27
Mischa 1:d9d6cf136120 28 %statistics:
Mischa 1:d9d6cf136120 29 d=reshape(d,100*1024,8);
Mischa 1:d9d6cf136120 30 m=reshape(m,100*1024,8);
Mischa 1:d9d6cf136120 31 m=m+median(d(:)-m(:));
Mischa 1:d9d6cf136120 32 top=(d>4096-6 & m<4096-100);
Mischa 1:d9d6cf136120 33 bottom=(d<6 & m>100);
Mischa 1:d9d6cf136120 34 above=(d>m+100 & d<=4096-6);
Mischa 1:d9d6cf136120 35 below=(d<m-100 & d>=6);
Mischa 1:d9d6cf136120 36 bar(0:7,[sum(bottom); sum(below); sum(above); sum(top)]','stacked')
Mischa 1:d9d6cf136120 37
Mischa 1:d9d6cf136120 38 figure
Mischa 1:d9d6cf136120 39 plot(m,d,'k.'); hold on
Mischa 1:d9d6cf136120 40 plot(m(top),d(top),'r.'); hold on
Mischa 1:d9d6cf136120 41 plot(m(above),d(above),'y.'); hold on
Mischa 1:d9d6cf136120 42 plot(m(below),d(below),'c.'); hold on
Mischa 1:d9d6cf136120 43 plot(m(bottom),d(bottom),'b.'); hold on
Mischa 1:d9d6cf136120 44 axis tight