🖥️ Computing effective values

Notebook Capytale de cet exercice : 80f6-11678454

With the help of Python, calculate the effective (RMS) values of the following periodic signals.

The function quad from the scipy.integrate module may be useful for performing the necessary integrations. It takes as arguments a function, a lower bound, and an upper bound, and returns the value of the integral over that interval.

1/ 𝑠1(𝑡)=10cos(20𝜋𝑡+𝜋2). Compare your result with the known formula for a sinusoidal signal.

Coup de pouce 1
What is the period of the signal?
Coup de pouce 2
Set up the integral for the effective value calculation.
Coup de pouce 3
Use the quad function to compute the integral.
Corrigé

The period is 𝑇=2𝜋𝜔=2𝜋20𝜋=0,1 s.

from scipy.integrate import quad
import numpy as np
def s1_squared(t):
    return ( 10*np.cos(20*np.pi*t + np.pi/2) )**2
T = 0.1  # period
integral, _ = quad(s1_squared, 0, T) # quad returns a tuple (value, error)
rms_value = np.sqrt(integral / T)
print("RMS value of s1:", rms_value)

2/ 𝑠2(𝑡)=cos2(𝜋𝑡). Compare your result with the known formula for a sinusoidal signal.

Corrigé

The period is 𝑇=2 s.

from scipy.integrate import quad
import numpy as np
def s2_squared(t):
    return np.cos(np.pi * t)**4
T = 2  # period
integral, _ = quad(s2_squared, 0, T) # quad returns a tuple (value, error)
rms_value = np.sqrt(integral / T)
print("RMS value of s2:", rms_value)

3/ A triangular wave centered around zero with a peak value of 5 V and a period of 2⁠ ⁠ms.

Corrigé

The half-period is 1⁠ ⁠ms.

Between 0⁠ ⁠ms and 1⁠ ⁠ms, the signal rises linearly from −5⁠ ⁠V to 5⁠ ⁠V, with a slope of 10 V ms−1=10 000 V s−1 and a y-intercept1 of −5⁠ ⁠V.

Between 1⁠ ⁠ms and 2⁠ ⁠ms, the signal falls linearly back to −5⁠ ⁠V with a slope of −10 V ms−1=−10 000 V s−1 and a y-intercept of 15⁠ ⁠V.

from scipy.integrate import quad
import numpy as np
T = 2e-3
def s3_squared(t):
    t = t % T # wrap around the period
    if 0 <= t < 0.001:
        return (10000 * t - 5)**2  # rising edge
    else:
        return (-10000 * t + 15)**2  # falling edge
integral, _ = quad(s3_squared, 0, T) # quad returns a tuple (value, error)
rms_value = np.sqrt(integral / T)
print("RMS value of s3:", rms_value)
  1. 1″Ordonnée à l’origine“ in french