Skip to content

Commit

Permalink
examples/adrv9009_som_fhm_phase: Randomize small and large LO freq jumps
Browse files Browse the repository at this point in the history
skip flushing buffers since we only have one kernel buffer enabled.

Signed-off-by: Michael Hennerich <[email protected]>
  • Loading branch information
mhennerich committed Oct 12, 2023
1 parent ca30737 commit 55a7d90
Showing 1 changed file with 29 additions and 25 deletions.
54 changes: 29 additions & 25 deletions examples/adrv9009_som_fhm_phase.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import matplotlib.pyplot as plt
import numpy as np
from scipy import signal
import random


def measure_phase(chan0, chan1):
Expand All @@ -23,7 +24,7 @@ def measure_phase(chan0, chan1):
fhm = True

# Create radio
sdr = adi.adrv9009_zu11eg(uri="ip:10.44.3.65")
sdr = adi.adrv9009_zu11eg(uri="ip:10.44.3.62")
sdr._rxadc.set_kernel_buffers_count(1)

# Configure properties
Expand All @@ -49,25 +50,27 @@ def measure_phase(chan0, chan1):
print("Setting FHM trigger to SPI")
sdr._ctrl.debug_attrs["adi,fhm-mode-fhm-trigger-mode"].value = "1"
print("Setting FHM init frequency")
sdr._ctrl.debug_attrs["adi,fhm-mode-fhm-init-frequency_hz"].value = "2319000000"
sdr._ctrl.debug_attrs["adi,fhm-mode-fhm-init-frequency_hz"].value = "2450000000"
print("Setting FHM Min frequency")
sdr._ctrl.debug_attrs["adi,fhm-config-fhm-min-freq_mhz"].value = "1000"
sdr._ctrl.debug_attrs["adi,fhm-config-fhm-min-freq_mhz"].value = "200"
print("Setting FHM Max frequency")
sdr._ctrl.debug_attrs["adi,fhm-config-fhm-max-freq_mhz"].value = "5000"
sdr._ctrl.debug_attrs["adi,fhm-config-fhm-max-freq_mhz"].value = "6000"
print("Set MCS+FHM")
sdr._ctrl.debug_attrs["adi,fhm-mode-enable-mcs-sync"].value = "1"
sdr._ctrl.debug_attrs["adi,fhm-config-fhm-gpio-pin"].value = "8"

print("setting up FHM Chip B")
print("Setting FHM trigger to SPI")
sdr._ctrl_b.debug_attrs["adi,fhm-mode-fhm-trigger-mode"].value = "1"
print("Setting FHM init frequency")
sdr._ctrl_b.debug_attrs["adi,fhm-mode-fhm-init-frequency_hz"].value = "2500000000"
sdr._ctrl_b.debug_attrs["adi,fhm-mode-fhm-init-frequency_hz"].value = "2450000000"
print("Setting FHM Min frequency")
sdr._ctrl_b.debug_attrs["adi,fhm-config-fhm-min-freq_mhz"].value = "1000"
sdr._ctrl_b.debug_attrs["adi,fhm-config-fhm-min-freq_mhz"].value = "200"
print("Setting FHM Max frequency")
sdr._ctrl_b.debug_attrs["adi,fhm-config-fhm-max-freq_mhz"].value = "5000"
sdr._ctrl_b.debug_attrs["adi,fhm-config-fhm-max-freq_mhz"].value = "6000"
print("Set MCS+FHM")
sdr._ctrl_b.debug_attrs["adi,fhm-mode-enable-mcs-sync"].value = "1"
sdr._ctrl_b.debug_attrs["adi,fhm-config-fhm-gpio-pin"].value = "8"

print("Syncing")
# this will renitialize both ADRV9009s from reset and sync them together using the jesd204-fsm
Expand All @@ -87,11 +90,11 @@ def measure_phase(chan0, chan1):
sdr.frequency_hopping_mode = nextLO
sdr.frequency_hopping_mode_chip_b = nextLO

sdr.dds_single_tone(200000, 0.8)
sdr.dds_single_tone(500000, 0.8)

# Collect data
M = 30
N = 10
M = 50
N = 1
p1 = np.zeros(M)
p2 = np.zeros(M)
p1v = np.zeros(M)
Expand All @@ -100,45 +103,46 @@ def measure_phase(chan0, chan1):
pf1 = np.zeros(N)
pf2 = np.zeros(N)

next_freq_lj = random.randrange(200000000, 5999000000, 10)
if k % 5 == 0:
next_freq_sj = random.randrange(2000000000, 2001000000, 10000)

if True:
############################
print("RUN #", k)
print("Off tune to ", nextLO)
tobemovedto = sdr.frequency_hopping_mode
# Tell LO to move and set next frequency
sdr.frequency_hopping_mode = 2000000000
sdr.frequency_hopping_mode_chip_b = 2000000000
sdr.frequency_hopping_mode = next_freq_sj
sdr.frequency_hopping_mode_chip_b = next_freq_sj
nextLO = sdr.frequency_hopping_mode
print("Current LO", tobemovedto)
time.sleep(0.1)
############################
print("Tune back to", nextLO)
tobemovedto = sdr.frequency_hopping_mode
# Tell LO to move and set next frequency
sdr.frequency_hopping_mode = 3000000000
sdr.frequency_hopping_mode_chip_b = 3000000000
sdr.frequency_hopping_mode = next_freq_lj
sdr.frequency_hopping_mode_chip_b = next_freq_lj
nextLO = sdr.frequency_hopping_mode
print("Current LO", tobemovedto)
time.sleep(0.1)
############################
print("FH Mode Enable", sdr.frequency_hopping_mode_en)
print("FH Mode Enable Chip B", sdr.frequency_hopping_mode_en_chip_b)
else:
if k % 2 == 0:
nextLO = 2000000000
else:
nextLO = 3000000000

if fhm:
sdr.frequency_hopping_mode = nextLO
sdr.frequency_hopping_mode_chip_b = nextLO
sdr.frequency_hopping_mode = next_freq_sj
sdr.frequency_hopping_mode_chip_b = next_freq_sj
sdr.frequency_hopping_mode = next_freq_lj
sdr.frequency_hopping_mode_chip_b = next_freq_lj
else:
sdr.trx_lo = nextLO
sdr.trx_lo_chip_b = nextLO
sdr.trx_lo = next_freq_sj
sdr.trx_lo_chip_b = next_freq_sj

# Flush
for r in range(N):
x = sdr.rx()
#for r in range(N):
#x = sdr.rx()

for r in range(N):
x = sdr.rx()
Expand Down

0 comments on commit 55a7d90

Please sign in to comment.