-
Notifications
You must be signed in to change notification settings - Fork 0
/
tx_am.py
68 lines (52 loc) · 1.4 KB
/
tx_am.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# -*- coding: utf-8 -*-
""" UHD TX example for amplitude modulation
"""
__author__ = "Igor Kim"
__credits__ = ["Igor Kim"]
__maintainer__ = "Igor Kim"
__email__ = "igor.skh@gmail.com"
__status__ = "Development"
__date__ = "101/2020"
__license__ = ""
import random
import uhd
import time
import numpy as np
def mod_am(t, freq, amp=.05):
return amp*np.exp(2j*np.pi*freq*t)
def mod_am1(t, freq, amp=.05):
return amp*np.cos(2*np.pi*freq*t)
addr = "192.168.11.4"
rate = 800e3
wave_freq = 100e3
gain = 0
channels = [0]
freq = 900e6
modulation_index = 1
st_args = uhd.usrp.StreamArgs("fc32", "sc16")
usrp = uhd.usrp.MultiUSRP("addr=%s" % addr)
usrp.set_tx_rate(rate, 0)
usrp.set_tx_freq(uhd.types.TuneRequest(freq), 0)
usrp.set_tx_gain(gain, 0)
streamer = usrp.get_tx_stream(st_args)
max_num_samples = streamer.get_max_num_samps()
print("Max samples: %d" % max_num_samples)
n_samples = max_num_samples
duration = n_samples / rate
t = np.linspace(0, duration, n_samples, dtype=np.complex64)
metadata = uhd.types.TXMetadata()
metadata.start_of_burst = False
metadata.end_of_burst = False
metadata.has_time_spec = False
running = True
smps = 0
step = 0
screen_id = 0
samples_buffer = mod_am1(t, wave_freq)
# samples_buffer = mod_am(t, 100e3) + mod_am(t, -50e3)
while running:
try:
streamer.send(samples_buffer, metadata)
except KeyboardInterrupt:
running = False
print("Exiting...")