jayeffe
Junior Member level 2
hi everyone I have to modify this example file which must show me the data of the signal tap.
I need to view the FFT of the ADC_DA_F and DAC_DA_F Signal
i have to do the same thing for other similar signals, eg ADC_DB, DAC_DB
the example file that is generated by the signal tap has the shape I entered.
I am not an expert in matlab and the example file only works with two signals from the demonstration.
FILE:
Signal Legend:
Key Signal Name
0 = ADC_DA_F
1 = DAC_DA
2 = DAC_DB
3 = DE2_115_ADDA_TOP:U1|lpm_add:lpm|dataa[0..13]
4 = DE2_115_ADDA_TOP:U1|lpm_add:lpm|datab[0..13]
Data Table:
Signals-> 0 1 2 3 4
sample
-16 11904 1910 1910 947 4096
-15 6594 5043 5043 293 8191
-14 12901 8484 8484 10 4096
-13 7384 4106 4106 128 1
-12 12908 129 129 634 4096
-11 10919 4730 4730 1479 8191
write your code inside this tags
I need to view the FFT of the ADC_DA_F and DAC_DA_F Signal
i have to do the same thing for other similar signals, eg ADC_DB, DAC_DB
the example file that is generated by the signal tap has the shape I entered.
I am not an expert in matlab and the example file only works with two signals from the demonstration.
Code:
function [A2D, D2A]= nstp_plot(stp_txt_file_name)
%A2D_SignalName = 'HSTCD_AD_DA';
A2D_SignalName = 'ADC_DB';
A2D_Index = 0;
D2A_SignalName = 'DAC_DB';
D2A_Index = 0;
A2D='';
D2A='';
close all;
if ~isempty(dir(stp_txt_file_name))
startdata=0;
first_data=0;
fid = fopen(stp_txt_file_name);
if fid ~= -1 % file open is OK.
%----- get signal index---------------------------------
key_hit = 0;
while(key_hit == 0)
tline = fgetl(fid); % get one line string
disp(tline); % for debug
if (strcmp(strtok(tline), 'Key'))
fprintf ('hit\n'); % for debug
key_hit = 1;
ken_fine_end = 0;
tline = fgetl(fid); % read space line
while (ken_fine_end == 0)
tline = fgetl(fid);
ken_fine_end = isempty(tline); % if space line, setup find to end
[key_Index, tline] = strtok(tline);
[key_Equ, tline] = strtok(tline);
[key_signalName, tline] = strtok(tline);
fprintf ('\"%s\" \"%s\" \"%s\" \n',key_Index,key_Equ,key_signalName); % for debug
if (strcmp(key_signalName,A2D_SignalName))
A2D_Index = sscanf(key_Index,'%d') + 2; % add 2 to correct sample number and array index.
fprintf ('A2D Hit, Index = %d\n',A2D_Index); % for debug
else
if (strcmp(key_signalName,D2A_SignalName))
D2A_Index = sscanf(key_Index,'%d') + 2; % add 2 to correct sample number and array index.
fprintf ('D2A Hit, Index = %d\n',D2A_Index); % for debug
end;
end;
end;
end;
end;
while (feof(fid)<1)
tline = fgetl(fid);
if (strcmp(tline, 'sample'))
startdata=1;
end;
if (startdata==1) && (length(tline)>10)
a = sscanf(tline,'%d');
% if (length(a) > max(A2D_Index,D2A_Index))
if (first_data == 0)
A2D = a(A2D_Index);
D2A = a(D2A_Index);
else
A2D = [A2D a(A2D_Index)];
D2A = [D2A a(D2A_Index)];
end;
% end;
first_data = first_data + 1;
end;
end;
fclose(fid);
end;
else
disp([' unable to locate : ' stp_txt_file_name]);
end;
if length(A2D)>2^11-1
if (strcmp(A2D_SignalName,'HSTCD_AD_DA'))
STII_FFTPLOT(A2D-2048*4,'ADA Development Kit - Normalized spectral plot of the 14 bit output bus of ADC_A (J1)');
elseif (strcmp(A2D_SignalName,'ADC_DB'))
STII_FFTPLOT(A2D-2048*4,'ADA Development Kit - Normalized spectral plot of the 14 bit output bus of ADC_B (J2)');
end;
end
if length(D2A)>2^11-1
STII_FFTPLOT(D2A-2048*4,'ADA Development Kit - Normalized spectral plot of 14 bits of input data of DAC_B (J4)');
end
% ===================================================================
% function STII_FFTPLOT(data,ttitle)
% input data data : input data sequence
% ttitle : plot title string
function STII_FFTPLOT(data,ttitle)
fs = 1e5;
color ='r';
N=(2^11);
data = data(1:N);
snc=0;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Kaiser window values
FILE:
Signal Legend:
Key Signal Name
0 = ADC_DA_F
1 = DAC_DA
2 = DAC_DB
3 = DE2_115_ADDA_TOP:U1|lpm_add:lpm|dataa[0..13]
4 = DE2_115_ADDA_TOP:U1|lpm_add:lpm|datab[0..13]
Data Table:
Signals-> 0 1 2 3 4
sample
-16 11904 1910 1910 947 4096
-15 6594 5043 5043 293 8191
-14 12901 8484 8484 10 4096
-13 7384 4106 4106 128 1
-12 12908 129 129 634 4096
-11 10919 4730 4730 1479 8191
write your code inside this tags
Last edited by a moderator: