From 41c9e0f50a565c66e0cc4cfcab12f29affc5660a Mon Sep 17 00:00:00 2001 From: David Michaeli Date: Mon, 3 Jan 2022 16:09:55 +0200 Subject: [PATCH] example file cleaning --- examples/README.md | 7 +++++++ .../iq_calibration/calibrate_freq_indep.py | 0 .../python/{test_soapy.py => soapy_iq_cal.py} | 20 ++++++++++++++----- examples/python/{psd.py => soapy_psd.py} | 19 ++++++++++++++---- examples/python/test.py | 2 -- examples/python/test_numpy.py | 8 -------- firmware/top.v | 6 +++--- 7 files changed, 40 insertions(+), 22 deletions(-) create mode 100644 examples/README.md delete mode 100644 examples/python/iq_calibration/calibrate_freq_indep.py rename examples/python/{test_soapy.py => soapy_iq_cal.py} (98%) rename examples/python/{psd.py => soapy_psd.py} (97%) delete mode 100644 examples/python/test.py delete mode 100644 examples/python/test_numpy.py diff --git a/examples/README.md b/examples/README.md new file mode 100644 index 0000000..e1ff734 --- /dev/null +++ b/examples/README.md @@ -0,0 +1,7 @@ +# CaribouLite Examples +This folder contains examples categorized by programming languages: +- `cpp` - C/C++ examples +- `python` - python applets and example + +# License +Creative Commons License
This work is licensed under a Creative Commons Attribution 4.0 International License. \ No newline at end of file diff --git a/examples/python/iq_calibration/calibrate_freq_indep.py b/examples/python/iq_calibration/calibrate_freq_indep.py deleted file mode 100644 index e69de29..0000000 diff --git a/examples/python/test_soapy.py b/examples/python/soapy_iq_cal.py similarity index 98% rename from examples/python/test_soapy.py rename to examples/python/soapy_iq_cal.py index 539d220..b8eb001 100644 --- a/examples/python/test_soapy.py +++ b/examples/python/soapy_iq_cal.py @@ -1,12 +1,19 @@ +# PySimpleGUI from PySimpleGUI.PySimpleGUI import Canvas, Column -import time -import numpy as np +from PySimpleGUI import Window, WIN_CLOSED, Slider, Button, theme, Text, Radio, Image, InputText, Canvas + +# Numpy import matplotlib.pyplot as plt from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg, NavigationToolbar2Tk +import numpy as np +from numpy.lib.arraypad import pad + +# System +import time + +# Soapy import SoapySDR from SoapySDR import SOAPY_SDR_RX, SOAPY_SDR_TX, SOAPY_SDR_CS16 -from PySimpleGUI import Window, WIN_CLOSED, Slider, Button, theme, Text, Radio, Image, InputText, Canvas -from numpy.lib.arraypad import pad ## ## WINDOW FUNCTIONS @@ -115,7 +122,8 @@ def update_est_graphs(window, freq_diff, g_vec, phi_vec, rssi_vec): draw_figure_with_toolbar(window['params_cv'].TKCanvas, fig, window['controls_params_cv'].TKCanvas) ## -## I/Q Correction Functions +## I/Q Correction Function - Blind correction + def fix_iq_blind(x): z = x - np.mean(x) p_in = np.var(z) @@ -134,6 +142,8 @@ def fix_iq_blind(x): return (z_out, g, phi, p_in, c1, c2) +## +## I/Q Correction Function - single tone correction def fix_iq_imbalance(x): # remove DC and save input power diff --git a/examples/python/psd.py b/examples/python/soapy_psd.py similarity index 97% rename from examples/python/psd.py rename to examples/python/soapy_psd.py index 6a4656d..57d6790 100644 --- a/examples/python/psd.py +++ b/examples/python/soapy_psd.py @@ -1,12 +1,19 @@ +# PySimpleGUI from PySimpleGUI.PySimpleGUI import Canvas, Column -import time -import numpy as np +from PySimpleGUI import Window, WIN_CLOSED, Slider, Button, theme, Text, Radio, Image, InputText, Canvas + +# Numpy import matplotlib.pyplot as plt from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg, NavigationToolbar2Tk +import numpy as np +from numpy.lib.arraypad import pad + +# System +import time + +# Soapy import SoapySDR from SoapySDR import SOAPY_SDR_RX, SOAPY_SDR_TX, SOAPY_SDR_CS16 -from PySimpleGUI import Window, WIN_CLOSED, Slider, Button, theme, Text, Radio, Image, InputText, Canvas -from numpy.lib.arraypad import pad def setup_receiver(sdr, channel, freq_hz): @@ -23,6 +30,10 @@ def update_receiver_freq(sdr, stream, channel, freq_hz): sdr.setFrequency(SOAPY_SDR_RX, channel, freq_hz) +## +## GLOBAL AREA +## + # Data and Source Configuration rx_chan = 0 # 6G = 1 N = 16384 # Number of complex samples per transfer diff --git a/examples/python/test.py b/examples/python/test.py deleted file mode 100644 index 75b17fe..0000000 --- a/examples/python/test.py +++ /dev/null @@ -1,2 +0,0 @@ -a = 5 -print("Hello, World ", a) diff --git a/examples/python/test_numpy.py b/examples/python/test_numpy.py deleted file mode 100644 index c83f022..0000000 --- a/examples/python/test_numpy.py +++ /dev/null @@ -1,8 +0,0 @@ -import numpy as np -import matplotlib.pyplot as plt - -#a = np.arange(15).reshape(3,5) -a = np.arange(15) -plt.plot(a, np.sin(a)) -plt.ylabel('some numbers') -plt.show() diff --git a/firmware/top.v b/firmware/top.v index 7b3219f..c33fe56 100644 --- a/firmware/top.v +++ b/firmware/top.v @@ -27,7 +27,7 @@ module top( input i_iq_rx_clk_p, // Paired with i_iq_rx_clk_n - only the 'B' pins need to be specified // Note: The icestorm (specifically nextpnr) fails to build if both diff pins are constrained - // in the constrain file and the interface herein. Thus we need to take the out so that + // in the constrain file and the interface herein. Thus we need to take them out so that // it will "understand" we actually want an LVDS pair inputs. In addition, the pair is // defined only by the "B" pins in BANK3 and not the "A" pins (which is counter-logical) @@ -294,7 +294,7 @@ module top( .empty_o (w_rx_09_fifo_empty) ); - /*lvds_rx lvds_rx_24_inst + lvds_rx lvds_rx_24_inst ( .i_reset (w_soft_reset), .i_ddr_clk (lvds_clock_buf), @@ -328,7 +328,7 @@ module top( .rd_data_o (w_rx_24_fifo_pulled_data), .full_o (w_rx_24_fifo_full), .empty_o (w_rx_24_fifo_empty) - );*/ + ); smi_ctrl smi_ctrl_ins (