rework simulink + initialize scripts

This commit is contained in:
Thomas Dehaeze 2021-06-30 23:22:08 +02:00
parent 3a25230498
commit 7a025197fc
7 changed files with 31 additions and 28 deletions

2
.gitignore vendored
View File

@ -1,3 +1,5 @@
sim_data/
auto/ auto/
*.tex *.tex
*.bbl *.bbl

Binary file not shown.

Binary file not shown.

View File

@ -1,19 +0,0 @@
run('identif_setup.m');
%%
Kiff_g1 = (1/(s + 2*pi*40))*... % Low pass filter (provides integral action above 40Hz)
(s/(s + 2*pi*30))*... % High pass filter to limit low frequency gain
(1/(1 + s/2/pi/500))*... % Low pass filter to be more robust to high frequency resonances
eye(6); % Diagonal 6x6 controller
Kiff = c2d(Kiff_g1, Ts, 'tustin');
%%
save('./frf_data.mat', 'Fs', ...
'Ts', ...
'Tsim', ...
'Trec_start', ...
'Trec_dur', ...
'V_exc', ...
'V_off', ...
'Kiff');

7
matlab/init_hac_iff.m Normal file
View File

@ -0,0 +1,7 @@
%% HAC
load('mat/Khac_iff_struts.mat', 'Khac_iff_struts');
save('sim_data/Khac_iff_struts.mat', 'Khac_iff_struts');
%% Jacobian
load('mat/jacobian.mat', 'J');
save('sim_data/J.mat', 'J');

5
matlab/init_iff.m Normal file
View File

@ -0,0 +1,5 @@
%%
load('mat/Kiff.mat', 'Kiff');
%%
save('sim_data/Kiff.mat', 'Kiff');

View File

@ -7,18 +7,18 @@ s = zpk('s');
addpath('./src/'); addpath('./src/');
%% Simulation configuration %% Simulation configuration
Fs = 10e3; % Sampling Frequency [Hz] Fs = 5e3; % Sampling Frequency [Hz]
Ts = 1/Fs; % Sampling Time [s] Ts = 1/Fs; % Sampling Time [s]
%% Data record configuration %% Data record configuration
Trec_start = 5; % Start time for Recording [s] Trec_start = 10; % Start time for Recording [s]
Trec_dur = 100; % Recording Duration [s] Trec_dur = 600; % Recording Duration [s]
Tsim = 2*Trec_start + Trec_dur; % Simulation Time [s] Tsim = 2*Trec_start + Trec_dur; % Simulation Time [s]
%% Security %% Security
u_min = -1; u_min = -1;
u_max = 6; u_max = 7.5;
%% Shaped Noise %% Shaped Noise
V_noise = generateShapedNoise('Ts', 1/Fs, ... V_noise = generateShapedNoise('Ts', 1/Fs, ...
@ -58,7 +58,7 @@ V_sweep_lf = generateSweepExc('Ts', Ts, ...
[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', Ts, ...
'V_mean', 0, ... 'V_mean', 0, ...
't_start', Trec_start, ... 't_start', Trec_start, ...
'exc_duration', Trec_dur, ... 'exc_duration', Trec_dur, ...
@ -85,8 +85,16 @@ V_sin = generateSinIncreasingAmpl('Ts', 1/Fs, ...
't_start', Trec_start, ... 't_start', Trec_start, ...
'smooth_ends', true); 'smooth_ends', true);
%% Offset Voltage for all APA %% Zero Voltage
V_zero = generateShapedNoise('Ts', 1/Fs, ... V_zero = generateShapedNoise('Ts', 1/Fs, ...
'V_mean', 0, ...
't_start', Trec_start, ...
'exc_duration', Trec_dur, ...
'smooth_ends', true, ...
'V_exc', tf(0));
%% Offset Voltage for all APA
V_zero_off = generateShapedNoise('Ts', 1/Fs, ...
'V_mean', 3.25, ... 'V_mean', 3.25, ...
't_start', Trec_start, ... 't_start', Trec_start, ...
'exc_duration', Trec_dur, ... 'exc_duration', Trec_dur, ...
@ -94,8 +102,8 @@ V_zero = generateShapedNoise('Ts', 1/Fs, ...
'V_exc', tf(0)); 'V_exc', tf(0));
%% Select the excitation signal and offset voltage %% Select the excitation signal and offset voltage
V_exc = timeseries(V_noise(2,:), V_noise(1,:)); V_exc = timeseries(V_zero(2,:), V_zero(1,:));
V_off = timeseries(V_zero(2,:), V_zero(1,:)); V_off = timeseries(V_zero_off(2,:), V_zero_off(1,:));
%% Plot %% Plot
figure; figure;
@ -114,4 +122,4 @@ set(gca, 'xscale', 'log'); set(gca, 'yscale', 'log');
xlim([1, Fs/2]); ylim([1e-10, 1e0]); xlim([1, Fs/2]); ylim([1e-10, 1e0]);
%% Save data that will be loaded in the Simulink file %% Save data that will be loaded in the Simulink file
save('./frf_data.mat', 'Fs', 'Ts', 'Tsim', 'Trec_start', 'Trec_dur', 'V_exc'); save('sim_data/data_sim.mat', 'Fs', 'Ts', 'Tsim', 'Trec_start', 'Trec_dur', 'V_exc');