Skip to content

Commit

Permalink
Implemented FCD frequency offset functionality (with re-tune on change).
Browse files Browse the repository at this point in the history
  • Loading branch information
jrcutler committed Feb 1, 2012
1 parent cfad8ec commit 6180f8b
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 0 deletions.
1 change: 1 addition & 0 deletions dsp/rx_source_base.h
Expand Up @@ -74,6 +74,7 @@ class rx_source_base : public gr_hier_block2
virtual double get_sample_rate() = 0;
virtual std::vector<double> get_sample_rates() = 0;

virtual void set_freq_corr(int ppm) = 0;
virtual void set_dc_corr(double dci, double dcq) = 0;
virtual void set_iq_corr(double gain, double phase) = 0;
};
Expand Down
7 changes: 7 additions & 0 deletions dsp/rx_source_fcd.cpp
Expand Up @@ -126,6 +126,13 @@ std::vector<double> rx_source_fcd::get_sample_rates()
return d_sample_rates;
}

void rx_source_fcd::set_freq_corr(int ppm)
{
d_fcd_src->set_freq_corr(ppm);
// re-tune after frequency correction
d_fcd_src->set_freq((float) d_freq);
}

void rx_source_fcd::set_dc_corr(double dci, double dcq)
{
d_fcd_src->set_dc_corr(dci, dcq);
Expand Down
1 change: 1 addition & 0 deletions dsp/rx_source_fcd.h
Expand Up @@ -64,6 +64,7 @@ class rx_source_fcd : public rx_source_base
double get_sample_rate();
std::vector<double> get_sample_rates();

void set_freq_corr(int ppm);
void set_dc_corr(double dci, double dcq);
void set_iq_corr(double gain, double phase);

Expand Down
11 changes: 11 additions & 0 deletions mainwindow.cpp
Expand Up @@ -115,6 +115,7 @@ MainWindow::MainWindow(QWidget *parent) :
/* connect signals and slots */
connect(ui->freqCtrl, SIGNAL(NewFrequency(qint64)), this, SLOT(setNewFrequency(qint64)));
connect(uiDockFcdCtl, SIGNAL(lnaGainChanged(float)), SLOT(setRfGain(float)));
connect(uiDockFcdCtl, SIGNAL(freqCorrChanged(int)), this, SLOT(setFreqCorr(int)));
connect(uiDockFcdCtl, SIGNAL(dcCorrChanged(double,double)), this, SLOT(setDcCorr(double,double)));
connect(uiDockFcdCtl, SIGNAL(iqCorrChanged(double,double)), this, SLOT(setIqCorr(double,double)));
connect(uiDockRxOpt, SIGNAL(filterOffsetChanged(qint64)), this, SLOT(setFilterOffset(qint64)));
Expand Down Expand Up @@ -306,6 +307,16 @@ void MainWindow::setRfGain(float gain)
rx->set_rf_gain(gain);
}

/*! \brief Set new frequency offset value.
* \param ppm Frequency correction.
*
* The valid range is between -200 and 200, though this is not checked.
*/
void MainWindow::setFreqCorr(int ppm)
{
qDebug() << "PPM:" << ppm;
rx->set_freq_corr(ppm);
}

/*! \brief Set new DC offset values.
* \param dci I correction.
Expand Down
1 change: 1 addition & 0 deletions mainwindow.h
Expand Up @@ -77,6 +77,7 @@ public slots:
private slots:
void setFilterOffset(qint64 freq_hz);
void setRfGain(float gain);
void setFreqCorr(int ppm);
void setDcCorr(double dci, double dcq);
void setIqCorr(double gain, double phase);
void selectDemod(int index);
Expand Down
8 changes: 8 additions & 0 deletions receiver.cpp
Expand Up @@ -265,6 +265,14 @@ receiver::status receiver::set_filter_shape(filter_shape shape)
}


receiver::status receiver::set_freq_corr(int ppm)
{
src->set_freq_corr(ppm);

return STATUS_OK;
}


receiver::status receiver::set_dc_corr(double dci, double dcq)
{
src->set_dc_corr(dci, dcq);
Expand Down
1 change: 1 addition & 0 deletions receiver.h
Expand Up @@ -104,6 +104,7 @@ class receiver
status set_filter_high(double freq_hz);
status set_filter_shape(filter_shape shape);

status set_freq_corr(int ppm);
status set_dc_corr(double dci, double dcq);
status set_iq_corr(double gain, double phase);

Expand Down

0 comments on commit 6180f8b

Please sign in to comment.