From 2fc01539f020c80977a366265c5f9ee4fb3048aa Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jan=20Hamal=20Dvo=C5=99=C3=A1k?= <mordae@anilinux.org>
Date: Wed, 10 Jul 2024 10:20:28 +0200
Subject: [PATCH] grc: fix data workflow

---
 grc/PicoSDR.grc | 112 +++++++++++++++++++++++++++++++++++++++---------
 1 file changed, 91 insertions(+), 21 deletions(-)

diff --git a/grc/PicoSDR.grc b/grc/PicoSDR.grc
index 81987a6..70ffba7 100644
--- a/grc/PicoSDR.grc
+++ b/grc/PicoSDR.grc
@@ -45,11 +45,23 @@ blocks:
     coordinate: [168, 8.0]
     rotation: 0
     state: enabled
-- name: samp_rate
+- name: decimation
   id: variable
   parameters:
     comment: ''
-    value: '50_000'
+    value: '4'
+  states:
+    bus_sink: false
+    bus_source: false
+    bus_structure: null
+    coordinate: [352, 8.0]
+    rotation: 0
+    state: enabled
+- name: rf_rate
+  id: variable
+  parameters:
+    comment: ''
+    value: '200_000'
   states:
     bus_sink: false
     bus_source: false
@@ -57,6 +69,38 @@ blocks:
     coordinate: [264, 8.0]
     rotation: 0
     state: enabled
+- name: samp_rate
+  id: variable
+  parameters:
+    comment: ''
+    value: rf_rate // decimation
+  states:
+    bus_sink: false
+    bus_source: false
+    bus_structure: null
+    coordinate: [456, 8.0]
+    rotation: 0
+    state: enabled
+- name: analog_agc_xx_0
+  id: analog_agc_xx
+  parameters:
+    affinity: ''
+    alias: ''
+    comment: ''
+    gain: '1.0'
+    max_gain: '65536'
+    maxoutbuf: '0'
+    minoutbuf: '0'
+    rate: 1e-4
+    reference: '0.7'
+    type: complex
+  states:
+    bus_sink: false
+    bus_source: false
+    bus_structure: null
+    coordinate: [360, 312.0]
+    rotation: 0
+    state: enabled
 - name: analog_quadrature_demod_cf_0
   id: analog_quadrature_demod_cf
   parameters:
@@ -70,7 +114,7 @@ blocks:
     bus_sink: false
     bus_source: false
     bus_structure: null
-    coordinate: [640, 536.0]
+    coordinate: [768, 616.0]
     rotation: 0
     state: true
 - name: blocks_message_debug_0
@@ -85,7 +129,7 @@ blocks:
     bus_sink: false
     bus_source: false
     bus_structure: null
-    coordinate: [928, 32.0]
+    coordinate: [1056, 112.0]
     rotation: 0
     state: true
 - name: blocks_probe_rate_0
@@ -105,7 +149,7 @@ blocks:
     bus_sink: false
     bus_source: false
     bus_structure: null
-    coordinate: [640, 40.0]
+    coordinate: [768, 120.0]
     rotation: 0
     state: true
 - name: digital_costas_loop_cc_0
@@ -123,9 +167,33 @@ blocks:
     bus_sink: false
     bus_source: false
     bus_structure: null
-    coordinate: [640, 344.0]
+    coordinate: [768, 424.0]
     rotation: 0
     state: true
+- name: low_pass_filter_0
+  id: low_pass_filter
+  parameters:
+    affinity: ''
+    alias: ''
+    beta: '6.76'
+    comment: ''
+    cutoff_freq: samp_rate / 8
+    decim: decimation
+    gain: '1'
+    interp: '1'
+    maxoutbuf: '0'
+    minoutbuf: '0'
+    samp_rate: rf_rate
+    type: fir_filter_ccf
+    width: samp_rate / 8
+    win: window.WIN_HAMMING
+  states:
+    bus_sink: false
+    bus_source: false
+    bus_structure: null
+    coordinate: [520, 284.0]
+    rotation: 0
+    state: enabled
 - name: osmosdr_source_0
   id: osmosdr_source
   parameters:
@@ -164,7 +232,7 @@ blocks:
     ant8: ''
     ant9: ''
     args: '"rtl_tcp"'
-    bb_gain0: '20'
+    bb_gain0: '0'
     bb_gain1: '20'
     bb_gain10: '20'
     bb_gain11: '20'
@@ -333,7 +401,7 @@ blocks:
     freq7: 100e6
     freq8: 100e6
     freq9: 100e6
-    gain0: '10'
+    gain0: '0'
     gain1: '10'
     gain10: '10'
     gain11: '10'
@@ -397,7 +465,7 @@ blocks:
     gain_mode7: 'False'
     gain_mode8: 'False'
     gain_mode9: 'False'
-    if_gain0: '20'
+    if_gain0: '0'
     if_gain1: '20'
     if_gain10: '20'
     if_gain11: '20'
@@ -465,7 +533,7 @@ blocks:
     minoutbuf: '0'
     nchan: '1'
     num_mboards: '1'
-    sample_rate: samp_rate
+    sample_rate: rf_rate
     sync: sync
     time_source0: ''
     time_source1: ''
@@ -480,7 +548,7 @@ blocks:
     bus_sink: false
     bus_source: false
     bus_structure: null
-    coordinate: [152, 164.0]
+    coordinate: [104, 244.0]
     rotation: 0
     state: enabled
 - name: qtgui_const_sink_x_0
@@ -572,7 +640,7 @@ blocks:
     bus_sink: false
     bus_source: false
     bus_structure: null
-    coordinate: [928, 328.0]
+    coordinate: [1056, 408.0]
     rotation: 0
     state: true
 - name: qtgui_time_sink_x_0
@@ -669,7 +737,7 @@ blocks:
     bus_sink: false
     bus_source: false
     bus_structure: null
-    coordinate: [640, 232.0]
+    coordinate: [768, 312.0]
     rotation: 0
     state: true
 - name: qtgui_time_sink_x_0_0
@@ -766,7 +834,7 @@ blocks:
     bus_sink: false
     bus_source: false
     bus_structure: null
-    coordinate: [928, 512.0]
+    coordinate: [1056, 592.0]
     rotation: 0
     state: true
 - name: qtgui_time_sink_x_0_1
@@ -863,7 +931,7 @@ blocks:
     bus_sink: false
     bus_source: false
     bus_structure: null
-    coordinate: [928, 400.0]
+    coordinate: [1056, 480.0]
     rotation: 0
     state: true
 - name: qtgui_waterfall_sink_x_0_0
@@ -924,20 +992,22 @@ blocks:
     bus_sink: false
     bus_source: false
     bus_structure: null
-    coordinate: [640, 128.0]
+    coordinate: [768, 208.0]
     rotation: 0
     state: true
 
 connections:
+- [analog_agc_xx_0, '0', low_pass_filter_0, '0']
 - [analog_quadrature_demod_cf_0, '0', qtgui_time_sink_x_0_0, '0']
 - [blocks_probe_rate_0, rate, blocks_message_debug_0, print]
 - [digital_costas_loop_cc_0, '0', qtgui_const_sink_x_0, '0']
 - [digital_costas_loop_cc_0, '0', qtgui_time_sink_x_0_1, '0']
-- [osmosdr_source_0, '0', analog_quadrature_demod_cf_0, '0']
-- [osmosdr_source_0, '0', blocks_probe_rate_0, '0']
-- [osmosdr_source_0, '0', digital_costas_loop_cc_0, '0']
-- [osmosdr_source_0, '0', qtgui_time_sink_x_0, '0']
-- [osmosdr_source_0, '0', qtgui_waterfall_sink_x_0_0, '0']
+- [low_pass_filter_0, '0', analog_quadrature_demod_cf_0, '0']
+- [low_pass_filter_0, '0', blocks_probe_rate_0, '0']
+- [low_pass_filter_0, '0', digital_costas_loop_cc_0, '0']
+- [low_pass_filter_0, '0', qtgui_time_sink_x_0, '0']
+- [low_pass_filter_0, '0', qtgui_waterfall_sink_x_0_0, '0']
+- [osmosdr_source_0, '0', analog_agc_xx_0, '0']
 
 metadata:
   file_format: 1