update simulink file

This commit is contained in:
Thomas Dehaeze 2021-06-10 14:17:06 +02:00
parent 7e9d08a21d
commit 21abe53df0
6 changed files with 66 additions and 58 deletions

Binary file not shown.

View File

@ -11,7 +11,7 @@ addpath('./src/');
%% Load measurement data for APA number 1
strut_number = 1;
% load(sprintf('mat/frf_data_exc_strut_%i_noise_lf.mat', strut_number), 't', 'Va', 'Vs', 'de');
load(sprintf('mat/frf_data_exc_strut_%i_noise_hf.mat', strut_number), 't', 'Va', 'Vs', 'de');
load(sprintf('mat/iff_strut_%i_noise.mat', strut_number), 't', 'Va', 'Vs', 'de');
% Compute transfer functions:
@ -21,7 +21,7 @@ Fs = 1/Ts;
win = hanning(ceil(1*Fs)); % Hannning Windows
%% DVF
[G_dvf, f] = tfestimate(Va, de, win, [], [], 1/Ts);
[G_dvf, f] = tfestimate(Vexc, de, win, [], [], 1/Ts);
figure;
tiledlayout(3, 1, 'TileSpacing', 'None', 'Padding', 'None');

View File

@ -19,15 +19,16 @@ data = SimulinkRealTime.utils.getFileScopeData('data/data.dat').data;
de = data(:, 1:6); % Measurment displacement (encoder) [m]
Vs = data(:, 7:12); % Measured voltage (force sensor) [V]
Va = data(:, 13); % Excitation Voltage [V]
u = data(:, 13:18); % DAC Voltage (command) [V]
Vexc = data(:, 19); % Excitation Voltage [V]
t = data(:, end); % Time [s]
% And we save this to a =mat= file:
strut_number = 6;
% save(sprintf('mat/frf_data_exc_strut_%i_noise.mat', strut_number), 't', 'Va', 'Vs', 'de');
% save(sprintf('mat/frf_data_exc_strut_%i_noise_lf.mat', strut_number), 't', 'Va', 'Vs', 'de');
% save(sprintf('mat/frf_data_exc_strut_%i_sweep.mat', strut_number), 't', 'Va', 'Vs', 'de');
save(sprintf('mat/frf_data_exc_strut_%i_noise_hf.mat', strut_number), 't', 'Va', 'Vs', 'de');
% save(sprintf('mat/frf_data_exc_strut_%i_add_mass_closed_circuit.mat', strut_number), 't', 'Va', 'Vs', 'de');
save(sprintf('mat/iff_strut_%i_noise_g_400.mat', strut_number), 't', 'u', 'Vs', 'Vexc', 'de');
% save(sprintf('mat/frf_data_exc_strut_%i_noise_lf.mat', strut_number), 't', 'u', 'Vs', 'de');
% save(sprintf('mat/frf_data_exc_strut_%i_sweep.mat', strut_number), 't', 'u', 'Vs', 'de');
% save(sprintf('mat/iff_strut_%i_noise_hf.mat', strut_number), 't', 'u', 'Vs', 'de');
% save(sprintf('mat/frf_data_exc_strut_%i_add_mass_closed_circuit.mat', strut_number), 't', 'u', 'Vs', 'de');

View File

@ -16,9 +16,13 @@ Trec_dur = 100; % Recording Duration [s]
Tsim = 2*Trec_start + Trec_dur; % Simulation Time [s]
%% Security
u_min = -1;
u_max = 6;
%% Shaped Noise
V_noise = generateShapedNoise('Ts', 1/Fs, ...
'V_mean', 3.25, ...
'V_mean', 0, ...
't_start', Trec_start, ...
'exc_duration', Trec_dur, ...
'smooth_ends', true, ...
@ -35,7 +39,7 @@ G_sweep = 0.2*(s^2 + 2*gc*xi*wn*s + wn^2)/(s^2 + 2*xi*wn*s + wn^2);
V_sweep = generateSweepExc('Ts', Ts, ...
'f_start', 10, ...
'f_end', 400, ...
'V_mean', 3.25, ...
'V_mean', 0, ...
't_start', Trec_start, ...
'exc_duration', Trec_dur, ...
'sweep_type', 'log', ...
@ -44,7 +48,7 @@ V_sweep = generateSweepExc('Ts', Ts, ...
V_sweep_lf = generateSweepExc('Ts', Ts, ...
'f_start', 0.1, ...
'f_end', 10, ...
'V_mean', 3.25, ...
'V_mean', 0, ...
't_start', Trec_start, ...
'exc_duration', Trec_dur, ...
'sweep_type', 'log', ...
@ -55,7 +59,7 @@ V_sweep_lf = generateSweepExc('Ts', Ts, ...
wL = 0.005*tf(b, a);
V_noise_hf = generateShapedNoise('Ts', 1/Fs, ...
'V_mean', 3.25, ...
'V_mean', 0, ...
't_start', Trec_start, ...
'exc_duration', Trec_dur, ...
'smooth_ends', true, ...
@ -66,7 +70,7 @@ V_noise_hf = generateShapedNoise('Ts', 1/Fs, ...
wL = 0.005*tf(b, a);
V_noise_lf = generateShapedNoise('Ts', 1/Fs, ...
'V_mean', 3.25, ...
'V_mean', 0, ...
't_start', Trec_start, ...
'exc_duration', Trec_dur, ...
'smooth_ends', true, ...
@ -74,35 +78,31 @@ V_noise_lf = generateShapedNoise('Ts', 1/Fs, ...
%% Sinus excitation with increasing amplitude
V_sin = generateSinIncreasingAmpl('Ts', 1/Fs, ...
'V_mean', 3.25, ...
'V_mean', 0, ...
'sin_ampls', [0.1, 0.2, 0.4, 1, 2, 4], ...
'sin_period', 1, ...
'sin_num', 5, ...
't_start', Trec_start, ...
'smooth_ends', true);
%% Zero Excitation
Trec_start = 10; % Start time for Recording [s]
Trec_dur = 10; % Recording Duration [s]
Tsim = 2*Trec_start + Trec_dur; % Simulation Time [s]
%% Offset Voltage for all APA
V_zero = generateShapedNoise('Ts', 1/Fs, ...
'V_mean', 1.25, ...
'V_mean', 3.25, ...
't_start', Trec_start, ...
'exc_duration', Trec_dur, ...
'smooth_ends', true, ...
'V_exc', tf(0));
%% Select the excitation signal
V_exc = timeseries(V_zero(2,:), V_zero(1,:));
%% Select the excitation signal and offset voltage
V_exc = timeseries(V_noise(2,:), V_noise(1,:));
V_off = timeseries(V_zero(2,:), V_zero(1,:));
%% Plot
figure;
tiledlayout(1, 2, 'TileSpacing', 'Normal', 'Padding', 'None');
ax1 = nexttile;
plot(V_exc.Time, squeeze(V_exc.Data));
plot(V_exc.Time, squeeze(V_exc.Data+V_off.Data));
xlabel('Time [s]'); ylabel('Amplitude [V]');
ax2 = nexttile;

Binary file not shown.

View File

@ -9,4 +9,11 @@ Kiff_g1 = (1/(s + 2*pi*40))*... % Low pass filter (provides integral action abov
Kiff = c2d(Kiff_g1, Ts, 'tustin');
%%
save('./frf_data.mat', 'Fs', 'Ts', 'Tsim', 'Trec_start', 'Trec_dur', 'V_exc', 'Kiff');
save('./frf_data.mat', 'Fs', ...
'Ts', ...
'Tsim', ...
'Trec_start', ...
'Trec_dur', ...
'V_exc', ...
'V_off', ...
'Kiff');