# How to calculate IAE between zero-crossing

4 views (last 30 days)
PAOLO OLIVIERI on 5 Aug 2022
Commented: Sam Chak on 8 Aug 2022
I am studying a load disturbance detection procedure presented by Hagglund.
Through simulink I have calculated the control error (it is an array) and I need to calculate the IAE between two consecutive istances of zero crossings as presented in the formula below In simulink I used a simulation time of 30s and a sampling period of 0.001s.
the question is: how can I calculate the IAE between each zero-crossing and, after each zero-crossing, reset the IAE to 0? Next I need to plot the obtained IAE array.

Sam Chak on 6 Aug 2022
Edited: Sam Chak on 6 Aug 2022
Are you looking for a MATLAB or Simulink solution?
sys = ss([0 1; -1 -1], [0; 1], [1 0], 0);
[y, t] = step(sys, 16);
e = 1 - y;
subplot(2,1,1)
plot(t, e), grid on, xlabel('t'), ylabel('e(t)'), ylim([-0.5 1.01])
ae = abs(e);
subplot(2,1,2)
plot(t, ae), grid on, xlabel('t'), ylabel('|e(t)|'), ylim([-0.5 1.01]) J_IAE = trapz(t, ae)
J_IAE = 1.7122
To reset the IAE to 0 after each zero-crossing detection, you probably need some conditional logics. By the way, what does the reset-IAE imply after each zero-crossing detection?
##### 2 CommentsShowHide 1 older comment
Sam Chak on 8 Aug 2022
Your IAE is increasing over time. This suggests that the error is accumulating and the output did not track the reference signal.