yefj
Advanced Member level 5
Hello, i have build an amplifier which creates an analog signal at DC=1.8 and f=1Mhz with amplitude of 57.106822mV
I have sampled my signal at Ts=2.179398748773332e-08.
I want to do FFT with 1Hz bin so signal_duration = 45.8 million * 2.179398748773332e-08 seconds=1 sec as shown in the directive bellow.
so i expect to see FFT plot 0..45.8MHz(simtric plot)
i extracted the table and built FFT code in python as shown bellow.
As you can see my AC signal is displayed at 2MHz instead f 1MHz
Where did i go wrong?
Thanks.
I have sampled my signal at Ts=2.179398748773332e-08.
I want to do FFT with 1Hz bin so signal_duration = 45.8 million * 2.179398748773332e-08 seconds=1 sec as shown in the directive bellow.
so i expect to see FFT plot 0..45.8MHz(simtric plot)
i extracted the table and built FFT code in python as shown bellow.
As you can see my AC signal is displayed at 2MHz instead f 1MHz
Where did i go wrong?
Thanks.
Code:
from scipy.fftpack import fft
#import plotly
#import chart_studio.plotly as py
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from matplotlib.widgets import Cursor
#%matplotlib qt
dataset_fft=pd.read_table("sinus_1mhz.txt")
array_fft=dataset_fft.values
Ts=array_fft[4][0]-array_fft[3][0];
Fs=1/Ts #Hz
L=np.size(array_fft)
freq_vec=Fs*np.arange(0,1,1/np.size(array_fft))
#L=np.size(freq_vec)/2
fft_y=fft(array_fft[:,1],L)
fig=plt.figure()
ax=fig.subplots()
ax.grid()
cursor=Cursor(ax, horizOn=True,vertOn=True,useblit=True,color='r',linewidth =1)
#ax.plot(array_fft[:,0],array_fft[:,1])
ax.plot(freq_vec,abs(fft_y)/np.size(array_fft))
plt.show()