Exemplo n.º 1
0
plt.show()

#freqs = np.array([0.01, 0.02, 0.05, 0.1, 0.15, 0.2, 0.25, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1, 1.5, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 22, 25, 27, 30, 33, 35, 37, 40, 43, 45, 47, 50, 53, 55, 57, 60, 63, 65, 67, 70, 73, 75, 77, 80, 83, 85, 87, 90, 93, 95, 97, 100, 103, 105, 107, 110, 113, 115, 117, 120, 123, 124]) * 1e6

freqs = np.linspace(0.01e6, 40e6,num=200)
freqs = np.round(freqs / fs * n_pts) * fs / n_pts

hd1 = 0.0 * freqs
hd2 = 0.0 * freqs
hd3 = 0.0 * freqs

snr = 0.0 * freqs

for i, freq in enumerate(freqs):
    n = np.uint32(freq / fs * n_pts)
    driver.set_dds_freq(0, freq)
    time.sleep(0.5)
    psd = driver.read_psd()
    psd_db = 10*np.log10(psd)

    snr[i] = 10*np.log10(psd[n-1] / (np.sum(psd) - psd[n-1]))

    hd1[i] = psd_db[n-1]

    if 2*(n-1) < n_pts/2:
        hd2[i] = psd_db[2*n-1] - hd1[i]
    else:
        hd2[i] = psd_db[n_pts - (2*n) - 1] - hd1[i]

    if 3*(n-1) < n_pts/2:
        hd3[i] = psd_db[3*n-1] - hd1[i]
Exemplo n.º 2
0
'''

import numpy as np
import os
import time
import matplotlib.pyplot as plt

from fft import FFT
from koheron import connect

host = os.getenv('HOST', '192.168.1.16')
client = connect(host, 'fft', restart=False)
driver = FFT(client)

driver.set_fft_window(0)
driver.set_dds_freq(0, 0)

fig = plt.figure(figsize=(6,6))
ax = fig.add_subplot(111)
ax.set_xlim([0, 125])
ax.set_ylim([0, 40])

freqs = np.arange(driver.n_pts/2) * 250. / 8192

raw_input("Terminate ADC0 with 50 Ohm")
psd = driver.read_psd()
ax.plot(freqs, np.sqrt(50 * psd) * 1e9, label='ADC0 terminated with 50 Ohm')

raw_input("Connect DAC0 to ADC0")
psd = driver.read_psd()
ax.plot(freqs, np.sqrt(50 * psd) * 1e9, label='ADC0 connected to DAC0')
Exemplo n.º 3
0
import numpy as np
import matplotlib
matplotlib.use('GTKAgg')
from matplotlib import pyplot as plt

from scipy import signal
import os, time
from koheron import connect
from fft import FFT

if __name__ == "__main__":
    host = os.getenv('HOST', '192.168.1.16')
    client = connect(host, 'fft')
    driver = FFT(client)

    driver.set_dds_freq(0, 50e6)

    n = 4096
    fs = 250e6
    cic_rate = 500

    ffft = np.fft.fftfreq(n) * fs / (cic_rate * 2)

    # Dynamic plot
    fig = plt.figure()
    ax = fig.add_subplot(111)
    x = np.arange(n)
    y = np.zeros(n)

    li, = ax.plot(np.fft.fftshift(ffft), y)
    ax.set_ylim((-1000, 1000))
Exemplo n.º 4
0
freqs = np.linspace(fmin, fmax, num=100)
freqs = np.round(freqs / fs * n_pts) * fs / n_pts

crosstalk = np.zeros((2, np.size(freqs)))

fig = plt.figure(figsize=(6, 6))
ax = fig.add_subplot(111)

ax.set_xlabel('Frequency (MHz)')
ax.set_ylabel('Crosstalk (dB)')

raw_input("Connect DAC0 to ADC0")
raw_input("Connect DAC1 to ADC1")

driver.set_dds_freq(1, 0)

for i, freq in enumerate(freqs):
    n = np.uint32(freq / fs * n_pts)
    driver.set_dds_freq(0, freq)

    driver.set_input_channel(0)
    time.sleep(0.5)
    psd0 = driver.read_psd()

    driver.set_input_channel(1)
    time.sleep(0.5)
    psd1 = driver.read_psd()

    crosstalk[0, i] = 10 * np.log10(psd1[n - 1] / psd0[n - 1])