-
Notifications
You must be signed in to change notification settings - Fork 175
Description
The new part Modelica.Electrical.Analog.Ideal.IdealizedOpAmpLimted has a few issues.
A minor issue is that the name has a typo; Limted should be Limited.
A serious bug is that the external supply pins, s_p and s_n, which are enabled when the boolean input useSupply is true, do not work because the equation that controls the output is in terms of Vps and Vns, the parameters, rather than vps and vns, the variables that should have been used.
From a performance viewpoint, the use of smooth(0, min(vps, max(vns, V0*v_in))) to generate the output, while convenient, is not ideal. The smooth(0, .) asserts that the output is continuous. That is not necessarily the case if v_in is not continuous, which can happen if the input is derived from a step signal or the circuit being modeled employs positive feedback. The bigger issue is that the use of smooth with min and max precludes the creation of events which would otherwise improve the engine performance at the transition to limiting. In a typical circuit where the external gain, set by the feedback, is much smaller than the open-loop gain (V0), the change in slope of the controlled signal as the circuit transitions to and from limiting is a few orders of magnitude. Without an event this can be problematic for some integrators to maintain error control. A better solution is to use a condition:
v_out = if AtNegRail then vns elseif AtPosRail then vps else V0*v_in;
where AtNegRail and AtPosRail are boolean variables defined as
Boolean AtNegRail = V0*v_in < vns "True when output is at the negative rail";
Boolean AtPosRail = V0*v_in > vps "True when output is at the positive rail";
The inequalities can be put directly into the conditions of the if-expression, however, declaring them as probeable variables provides a convenient means to detect that the opamp is at the rails, a normally undesirable condition.