Skip to content

Commit

Permalink
update l5
Browse files Browse the repository at this point in the history
  • Loading branch information
wulffern committed Feb 1, 2024
1 parent e212c63 commit 231f59f
Show file tree
Hide file tree
Showing 54 changed files with 13,609 additions and 102 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ FILES = l00_diode \
l02_esd \
l03_refbias \
l04_afe \
# l05_sc \
l06_adc \
l05_sc \
# l06_adc \
l07_vreg \
l08_pll \
l09_osc \
Expand Down
50 changes: 50 additions & 0 deletions ex/dt.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#!/usr/bin/env python3
#
import numpy as np
import matplotlib.pyplot as plt

Hann = True

#- Create a time vector
N = 2**13
t = np.linspace(0,N,N)

#- Create the "continuous time" signal with multiple sinusoidal signals and some noise
f1 = 233/N
fd = 1/N*119
x_s = np.sin(2*np.pi*f1*t) + 1/1024*np.random.randn(N) + 0.5*np.sin(2*np.pi*(f1-fd)*t) + 0.5*np.sin(2*np.pi*(f1+fd)*t)

#- Create the sampling vector, and the sampled signal
t_s_unit = [1,1,0,0,0,0,0,0]
t_s = np.tile(t_s_unit,int(N/len(t_s_unit)))
x_sn = x_s*t_s

#- Convert to frequency domain with a hanning window to avoid FFT bin
#- energy spread
if(Hann):
w = np.hanning(N+1)
else:
w = np.ones(N+1)
X_s = np.fft.fftshift(np.fft.fft(np.multiply(w[0:N],x_s)))
X_sn = np.fft.fftshift(np.fft.fft(np.multiply(w[0:N],x_sn)))



plt.subplot(2,2,1)
plt.ylabel("Time Domain")
plt.plot(x_s)
plt.xlabel("Continuous time, continuous value")
plt.subplot(2,2,2)
plt.plot(x_sn)
plt.ylabel("Frequency Domain")
plt.xlabel("Discrete time, continuous value")
plt.subplot(2,2,3)
plt.plot(20*np.log10(np.abs(X_s)))
plt.subplot(2,2,4)
plt.plot(20*np.log10(np.abs(X_sn)))

fig = plt.gcf()
fig.set_size_inches(12, 7)
plt.tight_layout()
plt.savefig(f"l5_dt.pdf")
plt.show()
Loading

0 comments on commit 231f59f

Please sign in to comment.