From 8d39eeb03b638ed5e6d4236a59d7ef09ee9d03ba Mon Sep 17 00:00:00 2001 From: Carl Laufer Date: Mon, 3 Jan 2022 04:39:37 +0000 Subject: add individual gain settings for 2ch PR --- _UI/_web_interface/kraken_web_interface.py | 92 +++++++++++++++++------------- _UI/save_settings.py | 4 ++ _receiver/krakenSDR_receiver.py | 12 +++- settings.json | 2 +- 4 files changed, 67 insertions(+), 43 deletions(-) diff --git a/_UI/_web_interface/kraken_web_interface.py b/_UI/_web_interface/kraken_web_interface.py index 7c1c90a..3f14440 100755 --- a/_UI/_web_interface/kraken_web_interface.py +++ b/_UI/_web_interface/kraken_web_interface.py @@ -119,13 +119,13 @@ class webInterface(): # Instantiate and configure Kraken SDR modules self.module_receiver = ReceiverRTLSDR(data_que=self.rx_data_que, data_interface=settings.data_interface, logging_level=settings.logging_level*10) self.module_receiver.daq_center_freq = settings.center_freq*10**6 - self.module_receiver.daq_rx_gain = settings.uniform_gain + self.module_receiver.daq_rx_gain = [settings.gain_1, settings.gain_2] #self.module_receiver.daq_squelch_th_dB = settings.squelch_threshold_dB self.module_receiver.rec_ip_addr = settings.default_ip self.module_signal_processor = SignalProcessor(data_que=self.sp_data_que, module_receiver=self.module_receiver, logging_level=settings.logging_level*10) #self.module_signal_processor.DOA_ant_alignment = settings.ant_arrangement - #self.module_signal_processor.DOA_inter_elem_space = settings.ant_spacing + #self.module_signal_processor.DOA_inter_elem_space = settings.ant_spacing self.module_signal_processor.en_PR = settings.en_pr self.module_signal_processor.PR_clutter_cancellation = settings.clutter_cancel_algo self.module_signal_processor.max_bistatic_range = settings.max_bistatic_range @@ -224,7 +224,9 @@ class webInterface(): # DAQ Configuration data["center_freq"] = self.module_receiver.daq_center_freq/10**6 - data["uniform_gain"] = self.module_receiver.daq_rx_gain + #data["uniform_gain"] = self.module_receiver.daq_rx_gain + data["gain_1"] = self.module_receiver.daq_rx_gain[0] + data["gain_2"] = self.module_receiver.daq_rx_gain[1] data["data_interface"] = settings.data_interface data["default_ip"] = settings.default_ip @@ -332,7 +334,8 @@ class webInterface(): webInterface_inst.logger.info("Updating receiver parameters") webInterface_inst.logger.info("Center frequency: {:f} MHz".format(f0)) - webInterface_inst.logger.info("Gain: {:f} dB".format(gain)) + #webInterface_inst.logger.info("Gain: {:f} dB".format(gain)) + webInterface_inst.logger.info("Gain: " + ' '.join(str(x) for x in gain) + " dB") @@ -650,6 +653,38 @@ def generate_config_page_layout(webInterface_inst): if daq_cfg_params[18] == 0: #If set to no tracking cfg_recal_interval = 1 + gain_list = [ + {'label': '0 dB', 'value': 0}, + {'label': '0.9 dB', 'value': 0.9}, + {'label': '1.4 dB', 'value': 1.4}, + {'label': '2.7 dB', 'value': 2.7}, + {'label': '3.7 dB', 'value': 3.7}, + {'label': '7.7 dB', 'value': 7.7}, + {'label': '8.7 dB', 'value': 8.7}, + {'label': '12.5 dB', 'value': 12.5}, + {'label': '14.4 dB', 'value': 14.4}, + {'label': '15.7 dB', 'value': 15.7}, + {'label': '16.6 dB', 'value': 16.6}, + {'label': '19.7 dB', 'value': 19.7}, + {'label': '20.7 dB', 'value': 20.7}, + {'label': '22.9 dB', 'value': 22.9}, + {'label': '25.4 dB', 'value': 25.4}, + {'label': '28.0 dB', 'value': 28.0}, + {'label': '29.7 dB', 'value': 29.7}, + {'label': '32.8 dB', 'value': 32.8}, + {'label': '33.8 dB', 'value': 33.8}, + {'label': '36.4 dB', 'value': 36.4}, + {'label': '37.2 dB', 'value': 37.2}, + {'label': '38.6 dB', 'value': 38.6}, + {'label': '40.2 dB', 'value': 40.2}, + {'label': '42.1 dB', 'value': 42.1}, + {'label': '43.4 dB', 'value': 43.4}, + {'label': '43.9 dB', 'value': 43.9}, + {'label': '44.5 dB', 'value': 44.5}, + {'label': '48.0 dB', 'value': 48.0}, + {'label': '49.6 dB', 'value': 49.6}, + ] + #for preconfig in preconfigs: # print(preconfig[0]) @@ -668,39 +703,17 @@ def generate_config_page_layout(webInterface_inst): html.Div([ html.Div("Receiver gain", className="field-label"), dcc.Dropdown(id='daq_rx_gain', - options=[ - {'label': '0 dB', 'value': 0}, - {'label': '0.9 dB', 'value': 0.9}, - {'label': '1.4 dB', 'value': 1.4}, - {'label': '2.7 dB', 'value': 2.7}, - {'label': '3.7 dB', 'value': 3.7}, - {'label': '7.7 dB', 'value': 7.7}, - {'label': '8.7 dB', 'value': 8.7}, - {'label': '12.5 dB', 'value': 12.5}, - {'label': '14.4 dB', 'value': 14.4}, - {'label': '15.7 dB', 'value': 15.7}, - {'label': '16.6 dB', 'value': 16.6}, - {'label': '19.7 dB', 'value': 19.7}, - {'label': '20.7 dB', 'value': 20.7}, - {'label': '22.9 dB', 'value': 22.9}, - {'label': '25.4 dB', 'value': 25.4}, - {'label': '28.0 dB', 'value': 28.0}, - {'label': '29.7 dB', 'value': 29.7}, - {'label': '32.8 dB', 'value': 32.8}, - {'label': '33.8 dB', 'value': 33.8}, - {'label': '36.4 dB', 'value': 36.4}, - {'label': '37.2 dB', 'value': 37.2}, - {'label': '38.6 dB', 'value': 38.6}, - {'label': '40.2 dB', 'value': 40.2}, - {'label': '42.1 dB', 'value': 42.1}, - {'label': '43.4 dB', 'value': 43.4}, - {'label': '43.9 dB', 'value': 43.9}, - {'label': '44.5 dB', 'value': 44.5}, - {'label': '48.0 dB', 'value': 48.0}, - {'label': '49.6 dB', 'value': 49.6}, - ], - value=webInterface_inst.module_receiver.daq_rx_gain, clearable=False, className="field-body"), + options=gain_list, + value=webInterface_inst.module_receiver.daq_rx_gain[0], clearable=False, className="field-body"), + #], className="field"), + + html.Div("Receiver 2 gain", className="field-label"), + dcc.Dropdown(id='daq_rx_gain_2', + options=gain_list, + value=webInterface_inst.module_receiver.daq_rx_gain[1], clearable=False, className="field-body"), ], className="field"), + + html.Div([ html.Button('Update Receiver Parameters', id='btn-update_rx_param', className="btn"), ], className="field"), @@ -1274,13 +1287,14 @@ def update_daq_status(): Output(component_id="placeholder_update_freq", component_property="children"), [Input(component_id ="btn-update_rx_param" , component_property="n_clicks")], [State(component_id ="daq_center_freq" , component_property='value'), - State(component_id ="daq_rx_gain" , component_property='value')], + State(component_id ="daq_rx_gain" , component_property='value'), + State(component_id ="daq_rx_gain_2" , component_property='value')], ) -def update_daq_params(input_value, f0, gain): +def update_daq_params(input_value, f0, gain, gain_2): #if input_value is None: # raise PreventUpdate webInterface_inst.daq_center_freq = f0 - webInterface_inst.config_daq_rf(f0,gain) + webInterface_inst.config_daq_rf(f0, [gain, gain_2] ) # CARL: TO CHANGE THIS TO AUTO POPULATE EACH GAIN UP TO M RECEIVERS? return 1 @app.callback([Output("page-content" , "children"), diff --git a/_UI/save_settings.py b/_UI/save_settings.py index 287bf7d..0799a64 100755 --- a/_UI/save_settings.py +++ b/_UI/save_settings.py @@ -20,6 +20,8 @@ if os.path.exists(settings_file_path): # DAQ Configuration center_freq = settings.get("center_freq", 100.0) uniform_gain = settings.get("uniform_gain", 1.4) +gain_1 = settings.get("gain_1", 1.4) +gain_2 = settings.get("gain_2", 1.4) data_interface = settings.get("data_interface", "eth") default_ip = settings.get("default_ip", "0.0.0.0") @@ -68,6 +70,8 @@ def write(data = None): # DAQ Configuration data["center_freq"] = center_freq data["uniform_gain"] = uniform_gain + data["gain_1"] = gain_1 + data["gain_2"] = gain_2 data["data_interface"] = data_interface data["default_ip"] = default_ip diff --git a/_receiver/krakenSDR_receiver.py b/_receiver/krakenSDR_receiver.py index a9e2d63..2f9c761 100755 --- a/_receiver/krakenSDR_receiver.py +++ b/_receiver/krakenSDR_receiver.py @@ -56,7 +56,7 @@ class ReceiverRTLSDR(): # These values are used by default to configure the DAQ through the configuration interface # Values are configured externally upon configuration request self.daq_center_freq = 100 # MHz - self.daq_rx_gain = 0 # [dB] + self.daq_rx_gain = [0] * 100 # [dB] self.daq_squelch_th_dB = 0 # UI interface @@ -197,6 +197,7 @@ class ReceiverRTLSDR(): # Inititalization from header - Set channel numbers if self.M == 0: self.M = self.iq_header.active_ant_chs + self.daq_rx_gain = [0] * self.M incoming_payload_size = self.iq_header.cpi_length*self.iq_header.active_ant_chs*2*int(self.iq_header.sample_bit_depth/8) if incoming_payload_size > 0: @@ -354,10 +355,15 @@ class ReceiverRTLSDR(): """ if self.receiver_connection_status: # Check connection self.daq_rx_gain = gain - + # Set center frequency cmd="GAIN" - gain_list=[297, 37] #[int(gain*10)]*self.M + + gain_list = [] + for i in range(0, self.M): + gain_list.append(int(gain[i]*10)) + + #gain_list=[297, 37] #[int(gain*10)]*self.M gain_bytes=pack("I"*self.M, *gain_list) msg_bytes=(cmd.encode()+gain_bytes+bytearray(128-(self.M+1)*4)) try: diff --git a/settings.json b/settings.json index 8ec14fd..ca1263c 100755 --- a/settings.json +++ b/settings.json @@ -1 +1 @@ -{"center_freq": 569.0, "uniform_gain": 7.7, "data_interface": "shmem", "default_ip": "0.0.0.0", "en_pr": true, "clutter_cancel_algo": "Wiener MRE", "max_bistatic_range": 128, "max_doppler": 256, "en_pr_persist": true, "pr_persist_decay": 0.99, "pr_dynrange_min": -20, "pr_dynrange_max": 10, "en_hw_check": 0, "en_advanced_daq_cfg": false, "logging_level": 5, "disable_tooltips": 0} \ No newline at end of file +{"center_freq": 569.0, "gain_1": 25.4, "gain_2": 7.7, "data_interface": "shmem", "default_ip": "0.0.0.0", "en_pr": true, "clutter_cancel_algo": "Wiener MRE", "max_bistatic_range": 128, "max_doppler": 256, "en_pr_persist": true, "pr_persist_decay": 0.99, "pr_dynrange_min": -20, "pr_dynrange_max": 10, "en_hw_check": 0, "en_advanced_daq_cfg": [], "logging_level": 5, "disable_tooltips": 0} \ No newline at end of file -- cgit v1.2.3