include check scripts to the project.

changed pulseWidth to pulseT.
This commit is contained in:
canisio
2026-04-28 15:22:03 -03:00
parent edef1dbed3
commit 6093942ab3
10 changed files with 228 additions and 9 deletions

Binary file not shown.

View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Info>
<Category UUID="FileClassCategory">
<Label UUID="design"/>
</Category>
</Info>

View File

@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<Info location="checkFreqSamples.m" type="File"/>

View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Info>
<Category UUID="FileClassCategory">
<Label UUID="design"/>
</Category>
</Info>

View File

@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<Info location="checkCounterSamples.m" type="File"/>

Binary file not shown.

View File

@@ -0,0 +1,116 @@
%% =========================================================
% Data
% =========================================================
clc;
X = raw_DPW.Data; % [512 x nFrames x nTime]
% Remove first DPW if needed (initialization artifact)
X = X(:,:,2:end);
[nSamples, nFrames_cfg, nTime] = size(X);
%% =========================================================
% PARAMETERS
% =========================================================
COUNTER_MAX = 511; % counter: 0..511
%% =========================================================
% VALIDATION
% =========================================================
for t = 1:nTime
fprintf('\n=== Checking DPW %d ===\n', t);
X_dpw = X(:,:,t);
% Flatten stream
x_seq = reshape(X_dpw, [], 1);
% Extract stored integers
real_seq = double(storedInteger(real(x_seq))); % sample counter
frame_seq = double(storedInteger(imag(x_seq))); % frame index
%% -----------------------------------------------------
% 1. Sample progression
% -----------------------------------------------------
d_real = diff(real_seq);
valid_steps = (d_real == 1) | (d_real == -COUNTER_MAX);
if all(valid_steps)
fprintf(' Sample progression OK\n');
else
idx = find(~valid_steps, 1);
fprintf(' Sample progression ERROR at index %d\n', idx);
end
%% -----------------------------------------------------
% 2. Detect counter wraps (511 0)
% -----------------------------------------------------
wrap_idx = find(real_seq(1:end-1) == COUNTER_MAX & real_seq(2:end) == 0);
fprintf('Detected wraps: %d (configured: %d)\n', ...
length(wrap_idx), nFrames_cfg);
if length(wrap_idx) == nFrames_cfg
fprintf(' Wrap count matches configuration\n');
else
fprintf(' Wrap count mismatch\n');
end
%% -----------------------------------------------------
% 3. Check frame increment at wraps (no wrap logic)
% -----------------------------------------------------
ok_wrap = true;
for k = 1:length(wrap_idx)
i = wrap_idx(k);
f_before = frame_seq(i);
f_after = frame_seq(i+1);
if f_after ~= f_before + 1
fprintf(' Frame increment error at idx %d (%d %d)\n', ...
i, f_before, f_after);
ok_wrap = false;
break;
end
end
if ok_wrap
fprintf(' Frame increments correctly at all wraps\n');
end
%% -----------------------------------------------------
% 4. Informative: frame regions (+1 effect)
% -----------------------------------------------------
d_frame = diff(frame_seq);
nFrames_detected = sum(d_frame == 1) + 1;
fprintf('Frame regions (including partial): %d (expected: %d + 1)\n', ...
nFrames_detected, nFrames_cfg);
%% -----------------------------------------------------
% 5. Optional: per-frame sanity (2 indices)
% -----------------------------------------------------
frame_idx_matrix = storedInteger(imag(X_dpw));
frame_ok = true;
for f = 1:nFrames_cfg
u = unique(frame_idx_matrix(:,f));
if length(u) > 2
fprintf(' Frame %d has >2 frame indices\n', f);
frame_ok = false;
break;
end
end
if frame_ok
fprintf(' Frame structure OK (2 indices per frame)\n');
end
end

View File

@@ -0,0 +1,87 @@
%% =========================================================
% Data
% =========================================================
X = single(raw_DPW.Data); % [512 x nFrames x nTime]
X = X(:,:,2:end); % First DPW is zeroed
X = 2*X; % Rescale (see channelizer block on PL)
[nSamples, nFrames, nTime] = size(X);
N = nSamples;
%% =========================================================
% Parameters
% =========================================================
Fs = 512e6; % Hz
f_axis = (-N/2 : N/2-1) * (Fs/N) / 1e6; % MHz
%% =========================================================
% Apply fftshift per frame (dim = 1)
% =========================================================
X_shift = fftshift(X, 1);
%% =========================================================
% Convert to power
% =========================================================
P = abs(X_shift).^2;
%% =========================================================
% OPTION 1 Mean Spectrum (over frames AND time)
% =========================================================
P_mean = mean(P, [2 3]); % average over frames and triggers
P_mean = squeeze(P_mean); % [512 x 1]
figure;
plot(f_axis, 10*log10(P_mean + 1e-12), 'LineWidth', 1.5);
grid on;
xlabel('Frequency (MHz)');
ylabel('Power (dB)');
title('Mean Channelized Spectrum (Frames + Time)');
%% =========================================================
% OPTION 2 Max Spectrum (detect intermittent peaks)
% =========================================================
P_max = max(P, [], [2 3]);
P_max = squeeze(P_max);
figure;
plot(f_axis, 10*log10(P_max + 1e-12), 'LineWidth', 1.5);
grid on;
xlabel('Frequency (MHz)');
ylabel('Power (dB)');
title('Max Channelized Spectrum (Frames + Time)');
%% =========================================================
% OPTION 3 Time-Frequency Visualization
% =========================================================
% Collapse frames keep time evolution
P_time = squeeze(mean(P, 2)); % [512 x nTime]
figure;
surf(1:nTime, f_axis, 10*log10(P_time + 1e-12), 'EdgeColor','none');
view(2);
axis tight;
xlabel('Trigger Index');
ylabel('Frequency (MHz)');
title('Channelizer Output Over Time');
colorbar;
%% =========================================================
% OPTIONAL Frame evolution inside a single trigger
% =========================================================
t_sel = 5; % pick last capture
P_frame = squeeze(P(:,:,t_sel)); % [512 x nFrames]
figure;
surf(1:nFrames, f_axis, 10*log10(P_frame + 1e-12), 'EdgeColor','none');
view(2);
axis tight;
xlabel('Frame Index');
ylabel('Frequency (MHz)');
title(['Channelizer Output Within DPW (Trigger ', num2str(t_sel), ')']);
colorbar;

View File

@@ -2,7 +2,7 @@
% Data
% =========================================================
X = single(raw_DPW.Data);
X = X(:,:,2:end); % first DPW useless (zeroed)
X = X(:,:,1:end); % first DPW useless (zeroed)
%% =========================================================
% Parameters

View File

@@ -23,12 +23,9 @@ NCOCountIncDT = numerictype(1,NCOAccumWL*2,NCOAccumWL);
%% Test signal parameters
% Pulse width
pulseWidth = 4e-6;
% Pulse start/end frequencies
pulseCentFreq = 0e6;
pulseBw = 0e6; % Pulse bandwidth
pulseBw = 32e6; % Pulse bandwidth
% Number of pulses
numPulses = 10;
@@ -37,11 +34,14 @@ numPulses = 10;
PRF = 20e3;
PRI = 1/PRF;
% Pulse time duration
%pulseT = 10; % use very long pulse help emulate CW
pulseT = 8e-6;
% CW mode (bypass pulse generation)
CwMode = true;
if CwMode
pulseWidth = 1000; % very long pulse help emulate CW
end
% Counter mode (bypass pulse and CW generation)
CounterMode = true;
@@ -52,7 +52,7 @@ pulseGenGain = 1;
%% Software parameters
% Signal generator update rate
TsSW = 0.5;
TsSW = 0.0005;
%% Simulation parameters