Update Content - 2024-12-13

This commit is contained in:
Thomas Dehaeze 2024-12-13 22:47:22 +01:00
parent 9487431bb1
commit c43ed48d65
7 changed files with 230 additions and 32 deletions

View File

@ -8,39 +8,174 @@ Tags
: [Modal Analysis]({{< relref "modal_analysis.md" >}})
## SISO Identification {#siso-identification}
## System Identification {#system-identification}
### Problem Description {#problem-description}
### Problem Definition {#problem-definition}
<a id="figure--fig:siso-identification-schematic"></a>
{{< figure src="/ox-hugo/siso_identification_schematic.png" caption="<span class=\"figure-number\">Figure 1: </span>Block diagram of the SISO system identification" >}}
The goal of a system identification is to extract a model (usually a LTI transfer function) from experimental data.
The system is represented in Figure <fig:siso_identification_schematic_simplier> with one input \\(u\\) and one output \\(y\_m\\) affected by some disturbances and noise \\(d\\).
<a id="figure--fig:siso-identification-schematic-simplier"></a>
{{< figure src="/ox-hugo/siso_identification_schematic_simplier.png" caption="<span class=\"figure-number\">Figure 2: </span>Simpler Block diagram of the SISO system identification" >}}
{{< figure src="/ox-hugo/siso_identification_schematic_simplier.png" caption="<span class=\"figure-number\">Figure 1: </span>Simpler Block diagram of the SISO system identification" >}}
<div class="note">
The goal of system identification is to compute the transfer function \\(G\\) from known excitation signal \\(u\\) and from a measure of \\(y\_m\\).
If the open-loop system is unstable, first design a simple controller that stabilizes the system and then identify the closed-loop system.
There are different ways of obtaining a model \\(G\\) of the system summarized in Table <tab:system_identification_model_types>.
For mechatronics systems, _frequency domain identification_ is the norm.
<a id="table--tab:system-identification-model-types"></a>
<div class="table-caption">
<span class="table-number"><a href="#table--tab:system-identification-model-types">Table 1</a>:</span>
Different ways to obtain a model
</div>
| | **Advantages** | **Disadvantages** |
|-------------------------------------|---------------------------------------------------------|-------------------------------------------------|
| Physical Modeling | Understanding dynamics, no measurements | Low accuracy, time consuming |
| Time domain identification | Parametric models, small data sets, non-linearity, MIMO | order/structure selection can be time consuming |
| **Frequency domain identification** | easy, intuitive, user-defined model fitting | fitting MIMO parametric model can be difficult |
### Design of the Excitation Signal {#design-of-the-excitation-signal}
As an example, a second order plant will be used:
```matlab
G = 1/(1 + 0.1*s/(2*pi*40) + s^2/(2*pi*40)^2); % Plant model
```
The sampling time of the recorded digital signal is 1ms.
#### Introduction {#introduction}
### Open-loop identification {#open-loop-identification}
In open-loop identification (Figure <fig:siso_identification_schematic_simplier_open_loop>), a test signal \\(u\\) is used to _excite_ the system in the frequency range of interest.
The signal \\(u\\) can typically be a swept sine, noise or multi-sine.
<a id="figure--fig:siso-identification-schematic-simplier-open-loop"></a>
{{< figure src="/ox-hugo/siso_identification_schematic_simplier_open_loop.png" caption="<span class=\"figure-number\">Figure 2: </span>Open Loop signal identification" >}}
The plant estimate \\(\hat{G}(j\omega)\\) is computed as follows:
\\[ \hat{G}(j\omega) = \frac{\Phi\_{yu}(\omega)}{\Phi\_{u}(\omega)} \\]
with \\(\phi\_{u}(\omega)\\) is the spectrum of \\(u\\) and \\(\Phi\_{yu}(\omega)\\) is the cross-spectrum of \\(u\\) and \\(y\\).
In Matlab, the transfer function can be extracted from the data using:
```matlab
Nfft = floor(1/Ts); % Size of the window [-]
win = hanning(Nfft); % Hanning window
Noverlap = floor(Nfft/2); % Overlap of 50%
% Identified Transfer Functions
[Gm, f] = tfestimate(data.du, data.y, win, Noverlap, Nfft, 1/Ts);
```
Then, the bode plot of the obtained transfer function is compared against the plant model including a 1.5 sample time delay (Figure <fig:system_identification_ol_comp_plant>).
<a id="figure--fig:system-identification-ol-comp-plant"></a>
{{< figure src="/ox-hugo/system_identification_ol_comp_plant.png" caption="<span class=\"figure-number\">Figure 3: </span>Comparison of the plant transfer function with the identified FRF in Open-Loop" >}}
### Verification of the Identification Quality - Coherence {#verification-of-the-identification-quality-coherence}
In order to assess the quality of the obtained FRF, the _coherence_ can be computed using the `mscohere` Matlab function.
```matlab
[coh, f] = mscohere(data.du, data.y, win, Noverlap, Nfft, 1/Ts);
```
The result for the example is shown in Figure <fig:system_identification_ol_coh>.
At high frequency, the measurement noise dominates and the coherence is poor.
<a id="figure--fig:system-identification-ol-coh"></a>
{{< figure src="/ox-hugo/system_identification_ol_coh.png" caption="<span class=\"figure-number\">Figure 4: </span>Comparison of the plant transfer function with the identified FRF in Open-Loop" >}}
### Closed-Loop identification {#closed-loop-identification}
If the open-loop system is unstable, a first simple controller needs to be designed to stabilizes the system.
Then, the plant can be identified from closed-loop system identification (Figure <fig:siso_identification_schematic_simplier_closed_loop>).
<a id="figure--fig:siso-identification-schematic-simplier-closed-loop"></a>
{{< figure src="/ox-hugo/siso_identification_schematic_simplier_closed_loop.png" caption="<span class=\"figure-number\">Figure 5: </span>Closed Loop signal identification" >}}
To perform plant identification in closed-loop:
- Chose \\(d\_u\\) (sweep sine, multi-sine, noise, ...)
- Measure \\(u\\) and \\(y\\)
- Compute the process sensitivity:
\\[ GS(j\omega) = \frac{\Phi\_{yd\_u}(\omega)}{\Phi\_{d\_u}(\omega)} \\]
- Compute the Sensitivity:
\\[ S(j\omega) = \frac{\Phi\_{ud\_u}(\omega)}{\Phi\_{d\_u}(\omega)} \\]
- Then the plan estimate \\(\hat{G}(j\omega)\\) can be computed:
\\[ \hat{G}(j\omega) = \frac{GS(j\omega)}{S(j\omega)} \\]
In Matlab, this can be done with the following code:
```matlab
Nfft = floor(1/Ts); % Size of the window [-]
win = hanning(Nfft); % Hanning window
Noverlap = floor(Nfft/2); % Overlap of 50%
[S, f] = tfestimate(data.du, data.u, win, Noverlap, Nfft, 1/Ts);
[GS, ~] = tfestimate(data.du, data.y, win, Noverlap, Nfft, 1/Ts);
Gm = GS ./ S;
K = (1 ./ S - 1) ./ Gm;
T = 1 - S;
```
### Multi-Input Multi-Output Plant {#multi-input-multi-output-plant}
This can be generalized to a MIMO plant (Figure <fig:siso_identification_schematic_simplier_closed_loop>).
<a id="figure--fig:siso-identification-schematic-simplier-closed-loop"></a>
{{< figure src="/ox-hugo/mimo_identification_schematic_simplier_closed_loop.png" caption="<span class=\"figure-number\">Figure 6: </span>Closed Loop signal identification (MIMO case)" >}}
Suppose a plan with \\(m\\) inputs and \\(n\\) outputs.
\\(\bm{G}\\) is therefore a \\(n \times m\\) plant, and the controller \\(\bm{K}\\) an \\(m \times n\\) system.
Input sensitivity is an \\(m \times m\\) system:
\\[ \bm{S}\_i = (\bm{I}\_{m} + \bm{K}\bm{G})^{-1} \\]
And process sensitivity is an \\(m \times m\\) system:
\\[ \bm{GS} = \bm{G} (I\_m + KG)^{-1} \\]
And the \\(n \times m\\) plant can be computed using:
\\[ GS \cdot S^{-1} = \bm{G} (I\_m + KG)^{-1} (\bm{I}\_{m} + \bm{K}\bm{G}) = G \\]
To estimate the full plant, \\(m\\) separate identification needs to be performed (one for each input):
- Chose the excitation signal for the \\(i^{th}\\) input: \\(d\_{ui}\\) (sweep sine, multi-sine, noise, ...)
- Measure \\(u\_i\\) and \\(\bm{y}\\)
- Compute the \\(i^{th}\\) column of the process sensitivity (\\(j\\) from \\(1\\) to \\(n\\)):
\\[ GS\_{ij}(j\omega) = \frac{\Phi\_{y\_jd\_{ui}}(\omega)}{\Phi\_{d\_{ui}}(\omega)} \\]
- Compute the \\(i^{th}\\) column of the input sensitivity (\\(j\\) from \\(1\\) to \\(n\\)):
\\[ S\_{ij}(j\omega) = \frac{\Phi\_{u\_jd\_{ui}}(\omega)}{\Phi\_{d\_{ui}}(\omega)} \\]
When the complete \\(GS\\) and \\(S\\) matrices are identified, the plan estimate \\(\hat{\bm{G}}(j\omega)\\) can be computed:
\\[ \hat{\bm{G}}(j\omega) = \bm{GS}(j\omega) \bm{S\_i}^{-1}(j\omega) \\]
## Design of the Excitation Signal {#design-of-the-excitation-signal}
<span class="org-target" id="org-target--sec-system-identification-excitation-signal"></span>
### Introduction {#introduction}
There are several choices for excitation signals:
- Impulse, Steps
- Sweep Sinus
- Random noise, Periodic signals
- Random noise, Periodic signals (PRBS)
- Multi-Sine
#### Random noise with specific ASD {#random-noise-with-specific-asd}
### Random noise with specific ASD {#random-noise-with-specific-asd}
The ASD of the measured output is:
@ -82,7 +217,7 @@ u = lsim(G_u, u_norm, t);
```
#### Choose Sampling Frequency and Duration of Excitation {#choose-sampling-frequency-and-duration-of-excitation}
### Choose Sampling Frequency and Duration of Excitation {#choose-sampling-frequency-and-duration-of-excitation}
<div class="important">
@ -134,39 +269,102 @@ T\_{\text{exc}} = \frac{10}{1} = 10\\,s
</div>
### Computation of the Frequency Response Function {#computation-of-the-frequency-response-function}
### Multi-Sine {#multi-sine}
#### Windowing Function {#windowing-function}
#### Example {#example}
`tfestimate`
### `generatemultisine` - Matlab Function {#generatemultisine-matlab-function}
```matlab
[G, f] = tfestimate(u, y, win, [], [], 1/Ts);
```
function y = generate_multisine(Fs, Ns, args)
%% Input parsing
arguments
Fs % Sampling frequency of the generated test signal
Ns % Length of the generated test signal
args.asd double {mustBeNumeric, mustBeNonnegative} = 0
args.type char {mustBeMember(args.type,{'schroeder', 'normal'})} = 'schroeder'
end
%% Find amplitude response
if args.asd == 0
% If magnitude response is zero, set default to "unitary ASD"
mag = (ones(1, Ns)*2*sqrt(Fs)/sqrt(Ns)).^2;
mag(round(Ns/2+1):end) = 0;
else
if length(args.asd) ~= Ns
error('ASD must be of length Ns');
end
### Verification of the Identification Quality {#verification-of-the-identification-quality}
mag = (args.asd*2*sqrt(Fs)/sqrt(Ns)).^2;
end
`mscohere`
if any(mag(round(Ns/2+1):end))
warning('Non-zero magnitude values present outside of frequency limits.');
mag(round(Ns/2+1):end) = 0;
end
```matlab
[coh, f] = mscohere(u, y, win, [], [], 1/Ts);
%% Find phase response
switch args.type
case 'schroeder'
phase = schroederPhases(Ns, mag);
case 'normal'
phase = randn(1, Ns);
otherwise
error('type must be "Schroeder" or "normal"');
end
%% Generate multisine signal
% Frequency domain representation
Y = sqrt(mag/2).*exp(sqrt(-1).*phase);
% IFFT to time domain
y = ifft(forceFFTSymmetry(Y))*(Ns/2);
%% Find zero crossing closest to zero
% Heuristic method of finding minimum gradient zero crossing
ySign = y>0;
zeroInds = find((ySign(2:end) ~= ySign(1:end-1)));
% Find the index with the smallest gradient around the zero crossing.
zeroGrad = zeros(1,length(zeroInds));
for nn=1:length(zeroInds)
zeroGrad(nn) = abs(y(zeroInds(nn)) - y(zeroInds(nn)+1));
end
[~, minInd] = min(zeroGrad);
yWrapped = [y(zeroInds(minInd):end) y(1:zeroInds(minInd)-1)];
y = yWrapped;
end
%% Generate phases as defined in "Synthesis of Low-Peak-Factor Signals and
% Binary Sequences With Low Autocorrelation" by M. R. Schroeder
function phase = schroederPhases(Ns, mag)
rel_mag = mag./sum(mag); % Normalize magnitude for Schroeder's algorithm
sum(rel_mag)
phase = zeros(1, Ns);
for nn=2:floor(Ns/2+1)
ll=1:(nn-1);
phase(nn) = -2*pi*sum((nn-ll).*rel_mag(ll));
end
end
%% forceFFTSymmetry A function to force conjugate symmetry on an FFT such that when an
% IFFT is performed the result is a real signal.
% The function has been written to replace MATLAB's ifft(X,'symmetric'), as this function
% is not compatible with MATLAB Coder.
function Y = forceFFTSymmetry(X)
Y = X;
XStartFlipped = fliplr(X(2:floor(end/2)));
Y(ceil(end/2)+2:end) = real(XStartFlipped) - sqrt(complex(-1))*imag(XStartFlipped);
end
```
## Reference Books {#reference-books}
- (<a href="#citeproc_bib_item_1">Pintelon and Schoukens 2012</a>)
- (<a href="#citeproc_bib_item_2">Schoukens, Pintelon, and Rolain 2012</a>)
- <pintelon12_system_ident>
- <schoukens12_master>
## Bibliography {#bibliography}
<style>.csl-entry{text-indent: -1.5em; margin-left: 1.5em;}</style><div class="csl-bib-body">
<div class="csl-entry"><a id="citeproc_bib_item_1"></a>Pintelon, Rik, and Johan Schoukens. 2012. <i>System Identification : a Frequency Domain Approach</i>. Hoboken, N.J. Piscataway, NJ: Wiley IEEE Press. doi:<a href="https://doi.org/10.1002/9781118287422">10.1002/9781118287422</a>.</div>
<div class="csl-entry"><a id="citeproc_bib_item_2"></a>Schoukens, Johan, Rik Pintelon, and Yves Rolain. 2012. <i>Mastering System Identification in 100 Exercises</i>. John Wiley &#38; Sons.</div>
</div>
<./biblio/references.bib>

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 98 KiB