Tutorials/k0SDR/Tutorial05: uhd_exp1.rb

File uhd_exp1.rb, 2.2 KB (added by nilanjan, 5 years ago)
Line 
1defProperty('freq',  1500e6, "Starting rx frequency")
2defProperty('dwell', 3, "Number of seconds at each frequency step")
3
4defGroup('txnode', 'node2-2.grid.orbit-lab.org') { |n|
5}
6
7defGroup('rxnode', 'node1-1.grid.orbit-lab.org,node20-20.grid.orbit-lab.org') { |n|
8}
9
10onEvent(:ALL_UP) do |event|
11  info "Give machines some time to warm up" 
12  wait 4
13
14  info "activate"
15  allGroups.uhd.u0.activate                         # starts UHD daemon
16  wait 3
17
18  info "set tx parameters"
19  group("txnode").uhd.u0.txfreq = property.freq     # set tx frequency (Hz)
20  group("txnode").uhd.u0.txrate = "8e6"             # set tx sampling rate
21  group("txnode").uhd.u0.txgain = "30"              # set tx gain (dB)
22  group("txnode").uhd.u0.txampl = "0.7"             # set tx wavform amplitude
23  #group("txnode").uhd.u0.txwavefreq = "1e6"
24  group("txnode").uhd.u0.txwavetype = "CONST"       # set type of waveform to transmit = {CONST, SINE, RAMP}
25  group("txnode").uhd.u0.transmit                   # start transmitting
26
27  group("rxnode").uhd.u0.rxfreq = property.freq     # set rx frequency
28  group("rxnode").uhd.u0.rxrate = "8e6"             # set rx sampling rate
29  group("rxnode").uhd.u0.rxgain = "25"              # set rx gain
30  group("rxnode").uhd.u0.numbins = "128"            # number of fft points
31  group("rxnode").uhd.u0.avgwinlen = "32"           # set averaging window size for each fft bin across time.
32  group("rxnode").uhd.u0.omlfile = "spectrum.grid"  # oml database file name to store fft data
33  group("rxnode").uhd.u0.omlserver = "idb2:3003"    # oml server
34  group("rxnode").uhd.u0.record                     # start recording
35
36  (0..30).each { |i|                      # set up loop   
37    offset = (rand()*4).to_f              # find next transmit frequency
38    cf = property.freq + (offset*1e6)
39    group("txnode").uhd.u0.txfreq = cf    # set new transmit frequency
40    wait property.dwell                   # wait for a few seconds
41  }
42
43
44  allGroups.uhd.u0.stop                             # stop transmitting and stop recording
45  allGroups.uhd.u0.deactivate                       # stop UHD daemon
46
47  info "Finish it." 
48  Experiment.done
49end