Message Boards Message Boards

0
|
7350 Views
|
5 Replies
|
2 Total Likes
View groups...
Share
Share this post:
GROUPS:

About rootMeanSquare block

Colleagues,

In my area, power systems, the possibility of measuring/calculating instantaneous values such RMS and harmonic components is of great interest. To obtain some of these values I have been using the block rootMeanSquare. For a signals that vary smoothly in amplitude, for instance, the result in WSM is an staircase function of time which I believe is rather an approximation. I wonder how the block Mean used in rootMeanSquare is implemented, Could any of you help me to understand this?

Regards

Jesus

5 Replies

Thanks Jesus!

POSTED BY: Jan Brugard

Jan, I think using an sliding window of width one period (T) is a better way to calculate means. That way, instantaneous means may be also used to detect inter-cycle changes. I think simulink follows this approach. In the attached file, the fundamental component of the trigonometric series is calculated at each time step.

regards Jesus

Attachments:

What would you prefer in order to calculate instantaneous mean?

Note that the Modelica Standard Library is an open source library maintained by the Modelica Association (see www.modelica.org) and anyone that likes can influence the decisions there in order to improve the libraries.

If you have Mathematica too, you could do the calculations there too of course. A small example relating to your question can be found in the documentation. See the applications section here: http://reference.wolfram.com/system-modeler/WSMLink/ref/WSMSimulationData.html (there's a sub section on different norms).

POSTED BY: Jan Brugard

Jan, It is great to be able to see the actual code. I am not sure, it is a "good" way to calculate instantaneous mean but then we have the possibility of doing in our own way.

Thanks

Jesus

If you right click on the Mean component in the model diagram of rootMeanSquare, you can select "Open Class". You can access the documentationof the component by clicking the "i"-button in the menu bar:

This block calculates the mean of the input signal u over the given period 1/f:
1 T
- ? u(t) dt
T 0
Note: The output is updated after each period defined by 1/f.
If parameter yGreaterOrEqualZero in the Advanced tab is true (default = false), then the modeller provides the information that the mean of the input signal is guaranteed to be ? 0 for the exact solution. However, due to inaccuracies in the numerical integration scheme, the output might be slightly negative. If this parameter is set to true, then the output is explicitly set to 0.0, if the mean value results in a negative value.

You can also get access to the actual code by changing from the "diagram view" to the "text view". To do this click on the document icon (the one with lines) in the menu bar:

block Mean "Calculate mean over period 1/f"
  extends Modelica.Blocks.Interfaces.SISO;
  parameter Modelica.SIunits.Frequency f(start = 50) "Base frequency";
  parameter Real x0 = 0 "Start value of integrator state";
  parameter Boolean yGreaterOrEqualZero = false "=true, if output y is guaranteed to be >= 0 for the exact solution" annotation(Evaluate = true, Dialog(tab = "Advanced"));
protected
  parameter Modelica.SIunits.Time t0(fixed = false) "Start time of simulation";
  Real x "Integrator state";
initial equation
  t0 = time;
  x = x0;
  y = 0;
equation
  der(x) = u;
  when sample(t0 + 1 / f, 1 / f) then
    y = if not yGreaterOrEqualZero then f * pre(x) else max(0.0, f * pre(x));
    reinit(x, 0);
  end when;
end Mean;

If you would like to create your own version you can simply make a copy of the component you want to modify and make the changes you like. Hope this helps.

POSTED BY: Jan Brugard
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract