Archived OpenModelica forums. Posting is disabled.

Alternative forums include GitHub discussions or StackOverflow (make sure to read the Stack Overflow rules; you need to have well-formed questions)


Forgot password? | Forgot username? | Register

Trapezoidal function

Trapezoidal function

I am building a BLDC motor model with 6-step drive. I am having numerical errors in the transitions due to trapezoidal back-emf functions. I tried to use smooth operator but that does not generate a continous differentiable intersections. Is there a way to obtain a trapezoidal shape that is differentiable even in the intersection points (given with a tolerance) to prevent numerical errors in the simulation?

My current shape functions;

Code:

function ShapeFunc

extends Modelica.Icons.Function;
input SI.Angle phi_e;
output Real y;
protected SI.Angle phi_e_wrapped;

algorithm
phi_e_wrapped := Modelica.Math.wrapAngle(phi_e,true) ;

y := smooth(1 ,if (phi_e_wrapped < 2*pi/3) then 1 else
     if (phi_e_wrapped < pi) then 1 - 6/pi*(phi_e_wrapped - 2*pi/3) else
     if (phi_e_wrapped < 5*pi/3) then -1 else
     if (phi_e_wrapped < 2*pi) then -1 + 6/pi*(phi_e_wrapped - 5*pi/3) else 0);

end ShapeFunc;

There are 0 guests and 0 other users also viewing this topic
You are here: