test-bench-apa/matlab/test_iff_gains.m

55 lines
1.4 KiB
Mathematica
Raw Normal View History

2020-08-21 14:12:22 +02:00
tg = slrt;
%% Gains to test
g_iff = [0, 1, 5, 10, 50, 100];
results = {zeros(1, length(g_iff))};
if tg.Connected == "Yes"
stop(tg);
%% Set Parameters for the Simulation
% setparam(tg, 'Noise', 'Variance', 0);
setparam(tg, 'Sine', 'Amplitude', 0);
setparam(tg, 'DC_value', 'Value', 0);
setparam(tg, 'Chirp_gain', 'Gain', 0.03);
setparam(tg, 'iff_enable', 'Gain', 1);
if tg.Status == "stopped"
for i = 1:length(g_iff)
setparam(tg, 'g_iff', 'Gain', g_iff(i));
fprintf('(%i/%i) - Testing for g_iff = %.1f', i, length(g_iff), g_iff(i));
start(tg);
pause(101);
stop(tg);
setparam(tg, 'g_iff', 'Gain', 0);
%%
f = SimulinkRealTime.openFTP(tg);
mget(f, 'apa95ml.dat', 'data');
close(f);
%% Convert the Data
data = SimulinkRealTime.utils.getFileScopeData('data/apa95ml.dat').data;
u = data(:, 1); % Input Voltage [V]
y = data(:, 2); % Output Displacement [m]
v = data(:, 3); % Output Voltage (Force Sensor) [V]
t = data(:, 4); % Time [s]
results(i) = {struct('t', t, 'u', u, 'y', y, 'v', v)};
end
end
end
save('../mat/apa95ml_iff_test.mat', 'results');
%% Best functions
% viewTargetScreen(tg);