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 %% Load measurement data for APA number 1
strut_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_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: % Compute transfer functions:
@ -21,7 +21,7 @@ Fs = 1/Ts;
win = hanning(ceil(1*Fs)); % Hannning Windows win = hanning(ceil(1*Fs)); % Hannning Windows
%% DVF %% DVF
[G_dvf, f] = tfestimate(Va, de, win, [], [], 1/Ts); [G_dvf, f] = tfestimate(Vexc, de, win, [], [], 1/Ts);
figure; figure;
tiledlayout(3, 1, 'TileSpacing', 'None', 'Padding', 'None'); 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] de = data(:, 1:6); % Measurment displacement (encoder) [m]
Vs = data(:, 7:12); % Measured voltage (force sensor) [V] 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] t = data(:, end); % Time [s]
% And we save this to a =mat= file: % And we save this to a =mat= file:
strut_number = 6; strut_number = 6;
% save(sprintf('mat/frf_data_exc_strut_%i_noise.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', 'Va', 'Vs', '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', 'Va', 'Vs', 'de'); % save(sprintf('mat/frf_data_exc_strut_%i_sweep.mat', strut_number), 't', 'u', 'Vs', 'de');
save(sprintf('mat/frf_data_exc_strut_%i_noise_hf.mat', strut_number), 't', 'Va', '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', 'Va', 'Vs', 'de'); % save(sprintf('mat/frf_data_exc_strut_%i_add_mass_closed_circuit.mat', strut_number), 't', 'u', 'Vs', 'de');

View File

@ -16,13 +16,17 @@ Trec_dur = 100; % Recording Duration [s]
Tsim = 2*Trec_start + Trec_dur; % Simulation Time [s] Tsim = 2*Trec_start + Trec_dur; % Simulation Time [s]
%% Security
u_min = -1;
u_max = 6;
%% Shaped Noise %% Shaped Noise
V_noise = generateShapedNoise('Ts', 1/Fs, ... V_noise = generateShapedNoise('Ts', 1/Fs, ...
'V_mean', 3.25, ... 'V_mean', 0, ...
't_start', Trec_start, ... 't_start', Trec_start, ...
'exc_duration', Trec_dur, ... 'exc_duration', Trec_dur, ...
'smooth_ends', true, ... 'smooth_ends', true, ...
'V_exc', 0.05/(1 + s/2/pi/10)); 'V_exc', 0.05/(1 + s/2/pi/10));
%% Sweep Sine %% Sweep Sine
gc = 0.1; gc = 0.1;
@ -33,76 +37,72 @@ wn = 2*pi*92.7;
G_sweep = 0.2*(s^2 + 2*gc*xi*wn*s + wn^2)/(s^2 + 2*xi*wn*s + wn^2); 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, ... V_sweep = generateSweepExc('Ts', Ts, ...
'f_start', 10, ... 'f_start', 10, ...
'f_end', 400, ... 'f_end', 400, ...
'V_mean', 3.25, ... 'V_mean', 0, ...
't_start', Trec_start, ... 't_start', Trec_start, ...
'exc_duration', Trec_dur, ... 'exc_duration', Trec_dur, ...
'sweep_type', 'log', ... 'sweep_type', 'log', ...
'V_exc', G_sweep*1/(1 + s/2/pi/500)); 'V_exc', G_sweep*1/(1 + s/2/pi/500));
V_sweep_lf = generateSweepExc('Ts', Ts, ... V_sweep_lf = generateSweepExc('Ts', Ts, ...
'f_start', 0.1, ... 'f_start', 0.1, ...
'f_end', 10, ... 'f_end', 10, ...
'V_mean', 3.25, ... 'V_mean', 0, ...
't_start', Trec_start, ... 't_start', Trec_start, ...
'exc_duration', Trec_dur, ... 'exc_duration', Trec_dur, ...
'sweep_type', 'log', ... 'sweep_type', 'log', ...
'V_exc', 0.2); 'V_exc', 0.2);
%% High Frequency Shaped Noise %% High Frequency Shaped Noise
[b,a] = cheby1(10, 2, 2*pi*[240 2e3], 'bandpass', 's'); [b,a] = cheby1(10, 2, 2*pi*[240 2e3], 'bandpass', 's');
wL = 0.005*tf(b, a); wL = 0.005*tf(b, a);
V_noise_hf = generateShapedNoise('Ts', 1/Fs, ... V_noise_hf = generateShapedNoise('Ts', 1/Fs, ...
'V_mean', 3.25, ... 'V_mean', 0, ...
't_start', Trec_start, ... 't_start', Trec_start, ...
'exc_duration', Trec_dur, ... 'exc_duration', Trec_dur, ...
'smooth_ends', true, ... 'smooth_ends', true, ...
'V_exc', wL); 'V_exc', wL);
%% Low Frequency Shaped Noise %% Low Frequency Shaped Noise
[b,a] = cheby1(10, 2, 2*pi*[10 260], 'bandpass', 's'); [b,a] = cheby1(10, 2, 2*pi*[10 260], 'bandpass', 's');
wL = 0.005*tf(b, a); wL = 0.005*tf(b, a);
V_noise_lf = generateShapedNoise('Ts', 1/Fs, ... V_noise_lf = generateShapedNoise('Ts', 1/Fs, ...
'V_mean', 3.25, ... 'V_mean', 0, ...
't_start', Trec_start, ... 't_start', Trec_start, ...
'exc_duration', Trec_dur, ... 'exc_duration', Trec_dur, ...
'smooth_ends', true, ... 'smooth_ends', true, ...
'V_exc', wL); 'V_exc', wL);
%% Sinus excitation with increasing amplitude %% Sinus excitation with increasing amplitude
V_sin = generateSinIncreasingAmpl('Ts', 1/Fs, ... 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_ampls', [0.1, 0.2, 0.4, 1, 2, 4], ...
'sin_period', 1, ... 'sin_period', 1, ...
'sin_num', 5, ... 'sin_num', 5, ...
't_start', Trec_start, ... 't_start', Trec_start, ...
'smooth_ends', true); '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_zero = generateShapedNoise('Ts', 1/Fs, ...
'V_mean', 1.25, ... 'V_mean', 3.25, ...
't_start', Trec_start, ... 't_start', Trec_start, ...
'exc_duration', Trec_dur, ... 'exc_duration', Trec_dur, ...
'smooth_ends', true, ... 'smooth_ends', true, ...
'V_exc', tf(0)); 'V_exc', tf(0));
%% Select the excitation signal %% Select the excitation signal and offset voltage
V_exc = timeseries(V_zero(2,:), V_zero(1,:)); V_exc = timeseries(V_noise(2,:), V_noise(1,:));
V_off = timeseries(V_zero(2,:), V_zero(1,:));
%% Plot %% Plot
figure; figure;
tiledlayout(1, 2, 'TileSpacing', 'Normal', 'Padding', 'None'); tiledlayout(1, 2, 'TileSpacing', 'Normal', 'Padding', 'None');
ax1 = nexttile; 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]'); xlabel('Time [s]'); ylabel('Amplitude [V]');
ax2 = nexttile; 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'); 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');