Add measurements: LPF, noise induced by all the stages
This commit is contained in:
@@ -1,49 +1,53 @@
|
||||
%%
|
||||
Tsim = 100; % [s]
|
||||
|
||||
%%
|
||||
tg = slrt;
|
||||
|
||||
%% TODO - Build this application if updated
|
||||
|
||||
%%
|
||||
if tg.Connected == "Yes"
|
||||
if tg.Status == "running"
|
||||
disp('Target is Running, Stopping...');
|
||||
tg.stop;
|
||||
while tg.Status == "running"
|
||||
pause(1);
|
||||
end
|
||||
disp('Target is Stopped');
|
||||
end
|
||||
if tg.Status == "stopped"
|
||||
%% Load the application
|
||||
disp('Load the Application');
|
||||
tg.load('disturbance_measurement');
|
||||
|
||||
%% Run the application
|
||||
disp('Starting the Application');
|
||||
tg.start;
|
||||
pause(300);
|
||||
pause(Tsim);
|
||||
tg.stop;
|
||||
|
||||
%% Load the data
|
||||
f = SimulinkRealTime.openFTP(tg);
|
||||
cd(f, 'data/disturbance_measurement/');
|
||||
mget(f, 'data_001.dat', 'data');
|
||||
close(f);
|
||||
end
|
||||
else
|
||||
error("The target computer is not connected");
|
||||
end
|
||||
|
||||
%%
|
||||
f = SimulinkRealTime.openFTP(tg);
|
||||
cd(f, 'data/disturbance_measurement/');
|
||||
mget(f, 'data_001.dat', 'data');
|
||||
close(f);
|
||||
|
||||
data = SimulinkRealTime.utils.getFileScopeData('data/data_001.dat').data;
|
||||
|
||||
size(data)
|
||||
|
||||
t = data(:, end);
|
||||
x1 = data(:, 1);
|
||||
x2 = data(:, 2);
|
||||
|
||||
save('mat/data_002.mat', 't', 'x1', 'x2');
|
||||
|
||||
%% Plot the data
|
||||
figure;
|
||||
hold on;
|
||||
plot(t, x1);
|
||||
plot(t, x2);
|
||||
hold off
|
||||
xlabel('Time [s]');
|
||||
ylabel('Voltage [V]');
|
||||
|
||||
%%
|
||||
figure;
|
||||
hold on;
|
||||
plot(t, x1-x2);
|
||||
hold off
|
||||
xlabel('Time [s]');
|
||||
ylabel('Voltage [V]');
|
||||
n = 17;
|
||||
|
||||
while isfile(['mat/data_', num2str(n, '%03d'), '.mat'])
|
||||
disp('File exists.');
|
||||
if input(['Are you sure you want to override the file ', 'mat/data_', ...
|
||||
num2str(n, '%03d'), '.mat', ' ? [Y/n]']) == 'Y'
|
||||
break;
|
||||
end
|
||||
n = input('What should be the measurement number?');
|
||||
end
|
||||
|
||||
save(['mat/data_', num2str(n, '%03d'), '.mat'], 'data');
|
||||
|
Reference in New Issue
Block a user