Radio Control  Control Software and GUI for the Panoradio SDR, by DC9ST 2016
waterfallddc.h
1 #ifndef WATERFALLDDC_H
2 #define WATERFALLDDC_H
3 
4 #include "../waterfall/waterfallplot.h"
5 #include <fft/fft_avg_complex.h>
6 #include <fft/fft_avg_real.h>
7 #include "stipcores.h"
8 #include <qwt_plot_curve.h>
9 #include <qwt_plot_grid.h>
10 #include <qlabel.h>
11 
15 class WaterfallDDC : public QObject
16 {
17  Q_OBJECT
18 public:
19 
21  WaterfallDDC();
22 
24  ~WaterfallDDC();
25 
26 
33  void init_lo(int address, int memsize, double master_frequency, int phase_width, double init_frequency);
34 
40  void init_cic(int filter_address, int filter_memsize, int bypass_address, int bypass_memsize);
41 
46  void init_iq_capture(int address, int memsize, int capture_size);
47 
52  void init_rf_capture(int address, int memsize, int capture_size);
53 
63  void init_waterfall(WaterfallPlot *waterfall, double max_frequency, double data_range_min, double data_range_max, double span_init, int data_size, int waterfall_depth, double usable_span_frac);
64 
69  void init_fft(int fft_rf_size, int fft_iq_size, int window_type);
70 
72  void init_labels(QLabel *label_zoom, \
73  QLabel *label_resolution, \
74  QLabel *label_bandwidth, \
75  QLabel *label_lo_freq, \
76  QLabel *label_cic_dec, \
77  QLabel *label_fir_dec, \
78  QLabel *label_fft);
79 
80 
83  void init_spectrum_line_plot(QwtPlot *spectrum_line_plot);
84 
85 
87  void set_color_map(QwtLinearColorMap color_map);
88 
90  void set_gain_ddc(int gain_ddc) {gain_ddc_ = gain_ddc;}
91 
93  void set_gain_rf_scaler(int gain_rf_scaler) {gain_rf_scaler_ = gain_rf_scaler;}
94 
96  void set_num_ffts(int num_ffts) {num_ffts_ = num_ffts;}
97 
98 
100  void capture_and_show(fstream &record_file, bool record_data);
101 
103  void correct_waterfall_size() { if (waterfall_initialized_) waterfall_ -> correct_size(); }
104 
106  int get_fft_rf_size() {return fft_rf_size_;}
107 
109  int get_fft_iq_size() {return fft_iq_size_;}
110 
112  int data_size() {return data_size_;}
113 
114 
115 
116  // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
117  // Debug Functions
118 
119 
121  void set_debug(bool debug_en);
122 
124  void debug_set_cic(int dec);
125 
127  void debug_set_lo(double freq);
128 
130  void debug_capture_iq_samples(double samples_i[], double samples_q[], int size);
131 
133  void debug_capture_rf_samples(double samples[], int size);
134 
135 signals:
138  void audio_frequency_clicked(double frequency);
139 
140 
141 private:
142  fft_avg_real *fft_real_;
143  fft_avg_complex *fft_complex_;
144  DDS *local_oscillator_;
145  CIC *cic_filter_;
146  IP_Driver *cic_bypass_;
147  Data_Capture_Dual *iq_capture_module_;
148  WaterfallPlot *waterfall_;
149  Data_Capture *rf_capture_module_;
150 
151  // objects for line spectrum display
152  QwtPlot *spectrum_line_plot_;
153  QwtPlotCurve *spectrum_line_curve_;
154  QwtPlotGrid *spectrum_line_grid_;
155 
156  // QLabel objects for status outputs (optional feature)
157  QLabel *label_zoom_;
158  QLabel *label_resolution_;
159  QLabel *label_bandwidth_;
160  QLabel *label_lo_freq_;
161  QLabel *label_cic_dec_;
162  QLabel *label_fir_dec_;
163  QLabel *label_fft_;
164 
165  // arrays, that hold captured data, fft data and display data
166  double *captured_data_rf_;
167  double *captured_data_i_;
168  double *captured_data_q_;
169  double *spectrum_rf_; // spectrum calculated in full resolution of RF signal
170  double *spectrum_iq_; // spectrum calculated in full resolution of IQ signals
171  double *spectrum_temp_; // decimated spectrum, that needs to be cut out for display (size: 2*data_size_)
172  double *spectrum_data_; // spectrum, that will be displyed in the waterfall
173  double *spectrum_display_;
174 
175  // different block sizes specified for the waterfall ddc
176  int capture_iq_max_size_; // depth of capture ip core memory
177  int capture_rf_max_size_;
178  int fft_rf_size_; // data block length for real fft (fft_rf_size_/2 output bins)
179  int fft_iq_size_; // data block length for complex fft
180  int data_size_; // data block length for display (including the aliasing bins)
181  int display_size_; // size of displayed data block (truncated due to aliasing)
182 
183  // variable, that show which init function has been activated
184  bool lo_initialized_;
185  bool cic_initialized_;
186  bool capture_iq_initialized_;
187  bool capture_rf_initialized_;
188  bool waterfall_initialized_;
189  bool fft_initialized_;
190  bool labels_initialized_; // indiciate if optional feature has been activated
191  bool line_plot_initialized_; // indiciate if optional feature has been activated
192 
193  bool debug_enabled_;
194 
195  double gain_ddc_; // power gain of DDC in dB, that will be subtracted from FFT power bins (without gain of RF scaler)
196  double gain_rf_scaler_; // additional power of RF Scaler in dB, that will be subtracted from FFT power bins
197 
198  int num_ffts_; // number of FFTs for averaging
199 
200  void set_cic(int decimation_rate);
201  double set_lo_frequency(double lo_frequency);
202 
204  void decimate_spectrum(double data_in[], int data_in_size, double data_out[], int data_out_size);
205 
206 };
207 
208 #endif // WATERFALLDDC_H
void init_lo(int address, int memsize, double master_frequency, int phase_width, double init_frequency)
initializes LO IP core, required to run before using the DDC!
Definition: waterfallddc.cpp:69
FFT Class for averaging over multiple FFTs with complex time domain input values. ...
Definition: fft_avg_complex.h:7
void debug_set_cic(int dec)
forces the CIC filter to the given decimation factor (for debug)
Definition: waterfallddc.cpp:592
WaterfallDDC()
constructor
Definition: waterfallddc.cpp:3
void capture_and_show(fstream &record_file, bool record_data)
captures IQ data (after DDC) and shows them as a new line in the waterfall plot
Definition: waterfallddc.cpp:259
void set_num_ffts(int num_ffts)
sets number of FFTs, that are averaged
Definition: waterfallddc.h:96
void set_gain_rf_scaler(int gain_rf_scaler)
sets the RF Scaler gain in dB, that will be subtracted from the FFT power bins
Definition: waterfallddc.h:93
void init_cic(int filter_address, int filter_memsize, int bypass_address, int bypass_memsize)
initializes CIC IP cores (rate prog and bypass), required to run before using the DDC! ...
Definition: waterfallddc.cpp:76
void correct_waterfall_size()
required to call to resize the plot to the data length
Definition: waterfallddc.h:103
void debug_set_lo(double freq)
forces the LO to the given frequency (for debug)
Definition: waterfallddc.cpp:599
void init_spectrum_line_plot(QwtPlot *spectrum_line_plot)
OPTIONAL: initializes support to display the spectrum in an extra line plot (QwtPlot) ...
Definition: waterfallddc.cpp:206
~WaterfallDDC()
destructor
Definition: waterfallddc.cpp:45
int get_fft_rf_size()
get data block length for real fft (fft_rf_size_/2 output bins)
Definition: waterfallddc.h:106
void init_labels(QLabel *label_zoom, QLabel *label_resolution, QLabel *label_bandwidth, QLabel *label_lo_freq, QLabel *label_cic_dec, QLabel *label_fir_dec, QLabel *label_fft)
OPTIONAL: initializes labels for status display in the GUI, in which the WaterfallDDC can write statu...
Definition: waterfallddc.cpp:127
int data_size()
get data block length for complex fft
Definition: waterfallddc.h:112
void set_gain_ddc(int gain_ddc)
sets the DDC gain in dB, that will be subtracted from the FFT power bins (without RF scaler gain) ...
Definition: waterfallddc.h:90
void audio_frequency_clicked(double frequency)
sends the frequency for tuning the audio receiver (when right clicking in the waterfall) ...
void debug_capture_iq_samples(double samples_i[], double samples_q[], int size)
returns IQ captured data (for debug)
Definition: waterfallddc.cpp:607
void init_waterfall(WaterfallPlot *waterfall, double max_frequency, double data_range_min, double data_range_max, double span_init, int data_size, int waterfall_depth, double usable_span_frac)
initializes the Waterfall DDC, required to run before use!
Definition: waterfallddc.cpp:101
FFT Class for averaging over multiple FFTs with real time domain input values.
Definition: fft_avg_real.h:7
void init_rf_capture(int address, int memsize, int capture_size)
initializes the RF capture module, instanciated outside of this class
Definition: waterfallddc.cpp:94
void debug_capture_rf_samples(double samples[], int size)
returns RF captured data (for debug)
Definition: waterfallddc.cpp:614
void decimate_spectrum(double data_in[], int data_in_size, double data_out[], int data_out_size)
converts long spectrum in a shorter one, using simple max operation
Definition: waterfallddc.cpp:559
Class for controlling the Waterfall DDC .
Definition: waterfallddc.h:15
void init_fft(int fft_rf_size, int fft_iq_size, int window_type)
initializes the FFT cores and data arrays for FFT and related processing
Definition: waterfallddc.cpp:140
int get_fft_iq_size()
get data block length for complex fft
Definition: waterfallddc.h:109
Top class for Waterfall Plots ,.
Definition: waterfallplot.h:16
void set_debug(bool debug_en)
enables the debug mode, which stops the waterfall and allows to set the DDC parameters and IP cores d...
Definition: waterfallddc.cpp:586
void init_iq_capture(int address, int memsize, int capture_size)
initializes Dual Capture IP core for IQ data, required to run before using the DDC! ...
Definition: waterfallddc.cpp:87
void set_color_map(QwtLinearColorMap color_map)
sets the color map of the plot (a default is assinged in the constructor)
Definition: waterfallddc.cpp:248