# What's the accuracy of the THD- and the RMS-Block? And how to adjust the fundamental during simulation?

206,479 views
Hi,

To calculate the THD and the RMS value of a periodic signal I want to use both blocks in my model.

How precise are these blocks? I mean till what order of harmonics they calculate the output-values? Does the simulation step time give the upper limit of harmonics which are included in the calculation? In case of a variable step time, which is used from the solver, is the accuracy time-dependent?

Another question: I have different operating points with different fundamental frequencies. Since I have to specify the fundamental for both blocks before simulation start, how to calculate these values during simulation like on the fly?
asked Jul 23, 2021

Both blocks are open subsystems, you can look under the mask and see how they are implemented.

The THD is not limited in the order of harmanics. It calculates the ratio of the first harmonic to the total signal minus first harmonic. Its accuracy is mostly limited by the numeric accuracy of the solver and its tolerance settings.

The calculation of RMS is not based on harmonics.

You can't change parameter values during the simulation. If you need different fundamental frequencies, use different blocks.
answered Jul 31, 2021 by (489 points)
One more thing: While the THD is not limited in harmonics itself, your simulation is if you are using a fixed-step solver. Any harmonics above f_sample/2 cannot be correctly calculated according to Nyquists law.
Thanks for answering, Oliver.

So what different blocks do you suggest for this? I kinda searched through the whole library for possible solutions...

Even with the block 'Discrete Mean Value' or 'Moving Average' I have to specify a fixed fundamental.
When I said "different blocks" I meant multiple THD blocks with different fundamentals.
Okay, let's call this a working workaround for a handful of discrete operating points.

But what do I do if I want to control a voltage-potential with a voltage-ripple based on the mean value? I want to control the mean value (DC) of  the voltage-potential on the neutral point to zero or within a small margin. The frequency of the voltage ripple itself is dependent on the fundamental (3*f_el). A block like 'moving average' is suitable to calculate the mean value (apart from the induced calculation-delay of one averaging period). But just for one fundamental. Imagine I want to slowly increase the fundamental linearly. I hope you get my point...

And I can't imagine a way to control it in a rotating reference dq-frame like we do it for output currents.