Effacer les filtres
Effacer les filtres

How to identify transfer function of a motor with IODelay?

18 vues (au cours des 30 derniers jours)
Erik Batschkun
Erik Batschkun le 14 Sep 2023
Commenté : Paul le 22 Sep 2023
I have a measurement series containing RPM measurements and their specific timestamps.
I tried to measure a step response, so the motors were starting from idle state.
My step was a setpoint of -250 RPM.
Looking at my measurement series I can see the first changes in RPM values after 117 samples (following the recorded timestamps a period of ~932ms)
Here you can look at the curve progression of the actual RPM:
Now I have done three different things to get my transfer function using tfest:
  1. cutting off all samples before first change could be seen (deleting the first 115 samples)
  2. using complete measurement series and adding an IODelay to tfest (115 as it is a discrete system)
  3. letting matlab decide on my iodelay by using NaN as IODelay
I received three different transfer functions.
First result:
I received a transfer function that seems to behave linear.
I am not sure if this is correct to use since I cut off the first samples.
However I'd like to see this as correct since the behaviour is linear.
Additionally I am concerned because of the results of my third approach - more on this later.
Second result:
I am not sure if I understood the documentation correctly but I thought giving the number of samples as input delay works.
Obviously this is not what you want to receive as a transfer function
Third result:
This seems to fit to my measurement series relating to the IODelay.
Somehow the behaviour turned nonlinear.
The IODelay is at about 0.23s. Actually this is what I wanted to see since I expect a delay of 200ms because of some mechanism in the code.
However I am really worried about the nonlinear behaviour and how MATLAB decided to use a IODelay of 0.23s since my measurement series shows first measureable reactions to the RPM at around 932ms.
This is the short snippet I used:
motor_right = iddata(right, right_setpoint, 0.008);
data_est = set(motor_right, 'InputName', 'u2', 'OutputName', 'y2');
tf_motor_right = tfest(data_est, 2, 1); %tfest(data_est, 2, 1, 115); tfest(data_est, 2, 1, NaN);
motor_right_zpk = zpk(tf_motor_right);
If you want to see the equations for the tf please let me know.
Now I dont really know how to trust my results.
Can anyone please help me evaluating these different results?
Thank you alot in advance!
  2 commentaires
Paul
Paul le 14 Sep 2023
Hi Erik,
If you're willing, you should attach the data file (.mat file is fine) using the paperclip icon in the Insert menu. That way others can try to recreate and then modify your results.
I think you meant non-minimum phase, rather than nonlinear.
Erik Batschkun
Erik Batschkun le 15 Sep 2023
Modifié(e) : Erik Batschkun le 15 Sep 2023
I added a .mat and a short matlab script to this answer.
I am not really sure how to name it.
The poles and zeros are not in or on the unit circle, so it could be a non-minimum phase system.
I meant nonlinear because of the following two tfs I got from some other measurements.
These are both tfs I generated using the same script.
Maybe I did some mistake and thats why it came out like this but I dont know about that yet.
The step was -500 RPM for both diagrams below. For both I cut off the leading zeros in my measurements.

Connectez-vous pour commenter.

Réponse acceptée

Paul
Paul le 16 Sep 2023
Hi Erik,
Here's what I tried:
Load the data
load forum.mat
Run the script so I can operate on the same variables. Take note of the warnings ...
identify_motor_behaviour
Warning: For transient data (step or impulse experiment), make sure that the change in input signal does not happen too early relative to the order of the desired model. You can achieve this by prepending sufficient number of zeros (equilibrium values) to the input and output signals. For example, a step input must be represented as [zeros(nx,1); ones(N,1)] rather than ones(N,1), such that nx > model order.
Warning: For transient data (step or impulse experiment), make sure that the change in input signal does not happen too early relative to the order of the desired model. You can achieve this by prepending sufficient number of zeros (equilibrium values) to the input and output signals. For example, a step input must be represented as [zeros(nx,1); ones(N,1)] rather than ones(N,1), such that nx > model order.
Assign a time vector using the sampling period, Ts, used to create the iddata objects
t = (0:numel(right_setpoint)-1)*0.008;
Here is the object created by tfest (after changing to zpk form). Note that it is a continous-time system
motor_right_zpk
motor_right_zpk = From input "u2" to output "y2": -2.9206 (s-2.224) ---------------------- (s^2 + 3.158s + 6.543) Continuous-time zero/pole/gain model.
Try tfest again, but specify the delay. Use the 116th element of the t vector. Might want to revisit the setpoint vector based on the warning, but we'll leave it for now.
motor_right_zpk_new = zpk(tfest(data_est,2,1,t(116)))
Warning: For transient data (step or impulse experiment), make sure that the change in input signal does not happen too early relative to the order of the desired model. You can achieve this by prepending sufficient number of zeros (equilibrium values) to the input and output signals. For example, a step input must be represented as [zeros(nx,1); ones(N,1)] rather than ones(N,1), such that nx > model order.
motor_right_zpk_new = From input "u2" to output "y2": 11.735 (s+22.61) exp(-0.92*s) * ---------------------- (s^2 + 12.49s + 266.2) Continuous-time zero/pole/gain model.
Simulate output for original and new systems
y = lsim(motor_right_zpk,right_setpoint,t);
ynew = lsim(motor_right_zpk_new,right_setpoint,t);
Plot and compare
figure
plot(t,right,t,y,t,ynew)
xline(t(116))
legend('data','y','ynew')
ynew looks pretty good.
Again, I'll note that y is NOT the output of a nonlinear system (after all, a zpk object is a representation of a linear system, by definition). It is the output of nonminimum phase system, i.e., motor_right_zpk as a zero in the righthalf plane, which casues the initial "wrong way" response in y.
  8 commentaires
Erik Batschkun
Erik Batschkun le 21 Sep 2023
Tank you very much for all your help!
I do have a question that may not directly fit to my question but I would be very happy to know about it.
Maybe I am able to recover the actual number of leading zero samples.
If i am:
The motors are drives for a vehicle.
Is it somehow possible to derive the inertia of the whole system/(mechanical load) from the count of leading zero samples?
I also have some other variables measured (regarding the positioning of the system) so I could maybe use them aswell.
Paul
Paul le 22 Sep 2023
You're quite welcome.
I'm afraid I can't offer any insight into deriving the inertia.
Good luck with your project!

Connectez-vous pour commenter.

Plus de réponses (0)

Produits


Version

R2023a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by