*** Wartungsfenster jeden ersten Mittwoch vormittag im Monat ***

Skip to content
Snippets Groups Projects
Commit ee454385 authored by Schabbauer, Johannes's avatar Schabbauer, Johannes
Browse files

Added calculation of crest factor (optional)

parent 62fcce33
No related branches found
No related tags found
1 merge request!2Added new spectrum awg card.
......@@ -1008,7 +1008,7 @@ def generate_single_tone(frequency, num_samples, sample_rate = 1.25e9 ):
return np.int16(np.sin(2 * np.pi * frequency * t) * 32767)
def generate_multi_tone(frequencies, amplitudes, phases, num_samples, sample_rate=1.25e9):
def generate_multi_tone(frequencies, amplitudes, phases, num_samples, sample_rate=1.25e9, print_crest_factor=False):
"""
Generates a signal that is the sum of multiple sine waves, with normalization to prevent overflow.
......@@ -1044,4 +1044,8 @@ def generate_multi_tone(frequencies, amplitudes, phases, num_samples, sample_rat
normalization_factor = 32767 / peak_value
signal = signal * normalization_factor
if print_crest_factor:
crest_factor = 32767 / np.sqrt(np.mean(signal**2))
print(f"Crest facor of signal: {crest_factor:.3f}")
return np.int16(signal)
......@@ -92,6 +92,9 @@ class AWGOutput(Output):
amplitudes = np.ones(len(frequencies))
if phases is None:
phases = np.zeros(len(frequencies))
# TODO: for equally spaced frequencies using
# phases = np.pi*np.arange(len(frequencies))**2/len(frequencies)
# are good values.
# Check frequency resolution
freq_sorted = np.sort(frequencies)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment