Closed gergelytakacs closed 5 years ago
Some parameters:
Amateur hour: essential questions Q: Can an input to output (u(k)->y(k)) measurement be used in closed loop identification (CLI)? Does the presence of the controller affect the results? How and why?
TLDR; Yes.
A: Yes it can be, it is called direct closed loop identification [01,02,03,04,05] and it is commonly used. It neglects the effect of the controller [01],05], however, may affect the results under certain conditions, since the output is correlated with the input [05] and disturbances. Some identification methods assume this noise is zero, thus shall not be used for closed loop cases [04]. Closed loop identification may be even beneficial, since the point of operation and input spectrum is the same as intended use [02]. About 30 years ago it was thought that closed loop identification should be avoided, however now it is actually preferred [02,05] at least for some situations.
The possible pitfalls of CLI are [02]:
The solution to make direct closed loop identification usable is:
A note on identification methods and target model types:
The alternative to direct closed loop identification is :
Matlab:
model = pem(data, NX, 'dist', 'estimate')
model2 = idss(drss(NX)) % or some other template you created using IDSS command
model2.DisturbanceMOdel = 'estimate'
model2 = pem(data, model2, 'focus', 'prediction')
Notes:
@mgulan The usual model, with simplified electrical response is: After linearisation leading to:
@mgulan If you wish to try grey box (or any other type) of identification, here is a *.mat file of closed loop behavior for identification purposes. MagnetoShield.zip
The columns go: u(k) - input [V], w(k) - injected noise [V], y(k) - position [mm], sampled at Ts=0.004 s.
The linearized state-space models are third-order. A third-order black box model yields fairly sensible results: Given one uses detrended data ("delta") formulation and that is
Options = ssestOptions;
Options.Display = 'on';
Options.WeightingFilter = 'prediction';
Options.InitialState = 'estimate';
Options.N4Horizon = [15 39 39];
ss27 = ssest(Magnetic Levitationd, 3, Options)
Here is the usual nonlinear and linearized model for magnetic levitation: Note, the model structure is the same as here.
Amateur hour: essential questions Q: What is the capacitance of the solenoid? How does the extra capacitor parallel to the solenoid affect the dynamics? A The terminal of the capacitor is in parallel with the inductor, which is a long wire. We can assume that the capacitor is shorted, therefore bypassed - thus can be essentially ignored in the analysis.
Accounting for the permanent magnet shall yield the same linearized model:
Also, according to [Barie and Chiasson] and their references, inductance is distance dependent, so we get a slightly more complex model as follows: From the viewpoint of the linearized model, this adds another term to the last equation, however, I could not make this one converge either.
@mgulan As of 3rd December the 3rd order black-box model seems to be decent, however, I had no luck with linearized and nonlinear first principle models yet. Neither of the latter two converge to anything useful. If you are up for the challenge, yo may try to make them work - the current "skeletons" for the identification are here. I'd probably try the lienarized grey-box at first, the nonlinear is even worse.
@mgulan A sensible black box TF model (1st order!) added to the collection. Maybe it would be fun to use the data (or even the hardware) in the Identification classes:
model =
From input "Solenoid Voltage" to output "Position":
0.02382
---------
s + 46.93
Continuous-time identified transfer function.
Parameterization:
Number of poles: 1 Number of zeros: 0
Number of free coefficients: 2
Use "tfdata", "getpvec", "getcov" for parameters and their uncertainties.
Status:
Estimated using TFEST on time domain data "Magnetic Levitation".
Fit to estimation data: 74.69% (data prefiltered)
FPE: 7.842e-09, MSE: 7.665e-09
@mgulan @erik1392 Amateur hour: Q: If you have an unstable model, testing its time-domain response to input data will necessarily cause an unstable response? A: ? My guess is yes,
@mgulan Successful grey-box linearized TF model:
From input "Solenoid Voltage" to output "Position":
-1.215
----------
s^2 - 2218
Continuous-time identified transfer function.
Parameterization:
Number of poles: 2 Number of zeros: 0
Number of free coefficients: 2
Use "tfdata", "getpvec", "getcov" for parameters and their uncertainties.
Status:
Estimated using TFEST on frequency domain data "dataf".
Fit to estimation data: 88.95%
FPE: 1.465e-09, MSE: 1.46e-09
This conforms to the "classical" model, where the mechanics of the ball are augmented with an U=Ki*I approach
@mgulan Success with linearized grey-box SS:
A =
x1 x2 x3
x1 0 1 0
x2 2145 0 -217.6
x3 0 0 -261.2
B =
Solenoid Vol
x1 0
x2 0
x3 1.48
C =
x1 x2 x3
Position 1 0 0
D =
Solenoid Vol
Position 0
K =
Position
x1 0
x2 0
x3 0
Parameterization:
STRUCTURED form (some fixed coefficients in A, B, C).
Feedthrough: none
Disturbance component: none
Number of free coefficients: 4
Use "idssdata", "getpvec", "getcov" for parameters and their uncertainties.
Status:
Estimated using SSEST on frequency domain data "dataf".
Fit to estimation data: 82.96%
FPE: 4.206e-09, MSE: 4.182e-09
And this actually puts some trust in the model:
---Parameter Comparison---
L (measured): 0.239 [H], L (model): 0.76 H
R (measured): 198.3 [Ohm], R (model): 199 [Ohm]
But since inductance is related to the object, possibly also to its permanent magnetic properites, this difference is not actually that significant.
So, all in all: (Will re-visit nonlinear ID as well).
One thing: when R2 will be ready, we will have a new measured state: coil current. This can make system identification more interesting, let's hope it will make things a bit smoother.
Amateur hour:
Q: Can MATLAB's nlgreyest()
handle unstable models?
I'll just ask.
Hard to find out. Ver. 2018b of Scientific Toolbox provides only few useless information on p. 17-129/130.
Read the manual, but I am no smarter. :) (Scientific Toolbox, really?:)
On Fri, 7 Dec 2018, 16:34 mgulan <notifications@github.com wrote:
Hard to find out. Ver. 2018b of Scientific Toolbox provides only few useless information on p. 17-129/130.
— You are receiving this because you were assigned. Reply to this email directly, view it on GitHub https://github.com/gergelytakacs/AutomationShield/issues/75#issuecomment-445269151, or mute the thread https://github.com/notifications/unsubscribe-auth/Aj6tcM_Y1uTBQwReVaN-iW419uwHOeC6ks5u2opwgaJpZM4YvCmp .
After a quick test none of the first principles models work, have to find out the reason... Haven't tested a lot yet, but it doesn't work "out of the box" as of now.
There is something strange with the TF sys ID...
Could this problem be caused by:
The thing is, that if I put "-model" to the compare, it is still the same. So the ferquency peaks don't have an orientation in this sense.
Don't know where my logic fails.
[Update] That parameter consistently turns out to be positive, not negative. It could be the orientation of the measurement or somehting...
The first principles linearized models are quite cool actually, but there is still no directly identified (or compared) nonlinear model. I will make a new issue out of this,
A first principles model of the MagnetoShield shall be developed. This could be used as a starting point, but remember, that we have an additional attraction between the two permanent magnets! Also, There is a parallel capacitor added there to stabilize the voltage signal, but that could be possibly neglected.