-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathudoppler.py
54 lines (40 loc) · 1.24 KB
/
udoppler.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import uhd
from uhd import libpyuhd as lib
import numpy as np
import scipy.io
import threading
import matplotlib.pyplot as plt
import time
from timeit import default_timer as timer
from myConstants import *
from myGUI import *
import myUSRP
# USRP selection
usrpTX = myUSRP.Device("serial=30B0CED")
#usrpTX.usrp.set_clock_source('external')
usrpRX = myUSRP.Device("serial=30B0CED")
#usrpRX.usrp.set_clock_source('external')
usrpTX.set_tx_config(fLO, fs, channelsTX, gainTX)
usrpRX.set_rx_config(fLO, fs, channelsRX, gainRX)
tx_buffer = 0.7 * np.array(np.exp(2j*np.pi*np.arange(0,ns)/ndiv), dtype=np.complex64)
usrpTX.start_tx_stream(tx_buffer)
usrpRX.start_rx_stream()
pvals = np.zeros(ns)
dphase = 0
loop_index = 0
while True:
loop_index = loop_index + 1
# Read
(x0,) = usrpRX.get_rx_buffer()
# DSP
X0 = np.fft.fftshift(np.fft.fft(x0, hrf * ns))
S0 = 10 * np.log(np.abs(X0) / np.sqrt(ns))
k = np.argmax(S0)
dphase = 180 / np.pi * np.angle(X0[k])
mplt0i.set_ydata(np.real(x0))
mplt0q.set_ydata(np.imag(x0))
pvals = np.concatenate((dphase, pvals[0:ns-1]), axis=None)
mplt0s.set_ydata(pvals)
refresh()
usrpTX.stop_tx_stream()
usrpRX.stop_rx_stream()