nass-metrology-test-bench/matlab/run_test.m

102 lines
1.9 KiB
Matlab

tg = slrt;
%%
if tg.Connected == "Yes"
if tg.Status == "stopped"
%% Load the application
tg.load('test_sercalo');
%% Run the application
tg.start;
pause(101);
tg.stop;
end
end
%%
f = SimulinkRealTime.openFTP(tg);
mget(f, 'data/data_001.dat');
close(f);
%% Convert the Data
data = SimulinkRealTime.utils.getFileScopeData('data/data_001.dat').data;
Uch = data(:, 1);
Ucv = data(:, 2);
Unh = data(:, 3);
Unv = data(:, 4);
Vph = data(:, 5);
Vpv = data(:, 6);
Vch = data(:, 7);
Vcv = data(:, 8);
Vnh = data(:, 9);
Vnv = data(:, 10);
Va = data(:, 11);
t = data(:, end);
%% Plot the data
figure;
subplot(2, 3, 1);
hold on;
plot(t, Ucv, 'DisplayName', 'Ucv');
plot(t, Vpv, 'DisplayName', 'Vpv');
hold off
xlabel('Time [s]');
ylabel('Voltage [V]');
legend();
subplot(2, 3, 2);
hold on;
plot(t, Uch, 'DisplayName', 'Uch');
plot(t, Vph, 'DisplayName', 'Vph');
hold off
xlabel('Time [s]');
ylabel('Voltage [V]');
legend();
subplot(2, 3, 3);
hold on;
plot(t, Vch, 'DisplayName', 'Vch');
plot(t, Vcv, 'DisplayName', 'Vcv');
hold off
xlabel('Time [s]');
ylabel('Voltage [V]');
legend();
subplot(2, 3, 4);
hold on;
plot(t, Unh, 'DisplayName', 'Unh');
plot(t, Vnh, 'DisplayName', 'Vnh');
hold off
xlabel('Time [s]');
ylabel('Voltage [V]');
legend();
subplot(2, 3, 5);
hold on;
plot(t, Unv, 'DisplayName', 'Unv');
plot(t, Vnv, 'DisplayName', 'Vnv');
hold off
xlabel('Time [s]');
ylabel('Voltage [V]');
legend();
subplot(2, 3, 6);
hold on;
plot(t, Va, 'DisplayName', 'Va');
hold off
xlabel('Time [s]');
ylabel('Distance [m]');
legend();
%% Save
save('mat/data_rep_1.mat', 't', 'Uch', 'Ucv', ...
'Unh', 'Unv', ...
'Vph', 'Vpv', ...
'Vch', 'Vcv', ...
'Vnh', 'Vnv', ...
'Va');
%% Save - Huddle Test
save('mat/data_huddle_test_4.mat', 't', 'Vph', 'Vpv', 'Va');