- Index
- » Programming
- » Modelica Language
- » Trapezoidal function
Page Start Prev 1 Next End
Trapezoidal function
Trapezoidal function
Oct-14-19 09:02:57
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;
Page Start Prev 1 Next End
- Index
- » Programming
- » Modelica Language
- » Trapezoidal function
There are 0 guests and 0 other users also viewing this topic