Search code examples
simulink

Calculate the RMS for a sinusoidal wave


I want to calculate the RMS value for a sinusoidal wave by taking only 40 samples per cycle. The sampling frequency is 2 KHz and the sine frequency is 50 Hz.

Please, can anyone give me a hint?


Solution

  • I created the simulink model shown in the image, using the following blocks:

    • Sine Wave - Simulink > Sources
    • RMS - Simscape > Power Systems > Specialized Technology > Control & Measurements
    • Mux - Simulink > Signal Routing
    • Scope - Simulink > Sinks

    Simulink model

    In order to configure the Sine Wave block I chose a Sample Based (discrete) Sine type with an Amplitude of 10 V and 40 Samples per period, as you requested. Since you want the sine to have a frequency of 50 Hz, the Sample time must be the period of the signal T = 1/(50 Hz) = 0.02s divided by 40, which yields 5e-4 s. The remaining parameters were left at the default values.

    Sine Wave block parameters

    Then, I configured the RMS block with a Fundamental frequency of 50 Hz to match the frequency of the sine wave, and changed the Initial RMS value to 0 V. The remaining parameters were left at the default values.

    RMS block parameters

    Finally I simulated the model for 0.08 s (4 cycles). Since the sine wave has an amplitude of 10 V, the theoretical RMS value is the amplitude divided by the square root of 2, which yields 7.07 V. The readings obtained from the scope confirm this value (purple line).

    Scope output

    Note how the RMS block requires to wait for one period of the signal to generate the first reading. During this period, the displayed reading is the Initial RMS value that we configured previously at 0 V.