I want to implement the flux observer from matlab ( https://de.mathworks.com/help/mcb/ref/fluxobserver.html ) in c code (for an stm32). In order to do so, I need to calculate the integral for flux calculation. However, since Im a hobbyist, i dont know how to implement this in source code (neither how to calculate it by hand).
ψα= ∫(Vα−IαR)dt− (Ls⋅Iα)
This is the term I am talking about. Any help about this topic is highly recommended.
Thanks
EDIT: Thats what i tried:
if(TimerFlag)
{
TimerFlag = 0;
ClarkTransformation(&ialpha, &ibeta, cur_c, cur_b);
ClarkTransformation(&valpha, &vbeta, vol_c, vol_b);
dt = TimeElapsedS - TimeElapsedSOld;
TimeElapsedSOld = TimeElapsedS;
fluxalpha += ((valpha-ialpha*R)*dt - (Ls*ialpha));
fluxbeta += ((vbeta-ibeta*R)*dt - (Ls*ibeta));
fluxrotor = sqrtf((fluxalpha*fluxalpha) + (fluxbeta*fluxbeta));
torquemotor = (3.0f / 2.0f) * PoleNumber * (fluxalpha*ibeta - fluxbeta*ialpha);
anglemotor = arctan(fluxbeta/fluxalpha);
}
I(t)andV(t)? Do you know what an integral is and how to calculate it numerically?