Skip to content

Commit

Permalink
Added frequency sweep, gaussian pulse and pwm modulation arbitrary wa…
Browse files Browse the repository at this point in the history
…veform genearion python scripts.
  • Loading branch information
peterska committed Feb 5, 2021
1 parent a3d9a0c commit 7757cbc
Show file tree
Hide file tree
Showing 6 changed files with 6,208 additions and 0 deletions.
20 changes: 20 additions & 0 deletions scripts/frequency-sweep.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/env python

# generata a frequency sweep

import numpy as np
from scipy.signal import chirp
import matplotlib.pyplot as plt

showplot = False
t = np.linspace(0, 1, 2048)
waveform = chirp(t, f0=1, f1=50, t1=1, method='linear')

print("# frequency sweep using scipy.signal.chirp")
for y in waveform:
print(y)

if showplot:
plt.plot(t, waveform, '--')
plt.show()

20 changes: 20 additions & 0 deletions scripts/gaussian-pulse.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/env python

# generata a gaussian pulse

import numpy as np
from scipy.signal import gausspulse
import matplotlib.pyplot as plt

showplot = False
t = np.linspace(-1, 1, 2048)
waveform = gausspulse(t, fc=5)

print("# gaussian pulse using scipy.signal.gausspulse")
for y in waveform:
print(y)

if showplot:
plt.plot(t, waveform, '--')
plt.show()

21 changes: 21 additions & 0 deletions scripts/pwm-modulation.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/env python

# generata pwm modulated signal

import numpy as np
from scipy.signal import square
import matplotlib.pyplot as plt

showplot = False
t = np.linspace(0, 1, 2048)
sig = np.sin(2 * np.pi * t)
waveform = square(2 * np.pi * 25 * t, duty=(sig + 1)/2)

print("# pwm modulation using scipy.signal.square")
for y in waveform:
print(y)

if showplot:
plt.plot(t, waveform, '--')
plt.show()

Loading

0 comments on commit 7757cbc

Please sign in to comment.