mirror of
https://github.com/f4exb/sdrangel.git
synced 2025-04-04 10:38:45 -04:00
Frequency tracker (2)
This commit is contained in:
parent
fc650c5fd1
commit
230737cac5
@ -76,6 +76,8 @@ FreqTracker::FreqTracker(DeviceSourceAPI *deviceAPI) :
|
||||
|
||||
m_networkManager = new QNetworkAccessManager();
|
||||
connect(m_networkManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(networkManagerFinished(QNetworkReply*)));
|
||||
|
||||
applyChannelSettings(m_inputSampleRate, m_inputFrequencyOffset, true);
|
||||
}
|
||||
|
||||
FreqTracker::~FreqTracker()
|
||||
@ -157,17 +159,18 @@ void FreqTracker::processOneSample(Complex &ci)
|
||||
}
|
||||
}
|
||||
|
||||
qint16 sample;
|
||||
|
||||
m_squelchOpen = (m_squelchCount >= m_channelSampleRate / 20);
|
||||
|
||||
if (m_squelchOpen)
|
||||
{
|
||||
Real demod;
|
||||
}
|
||||
else
|
||||
{
|
||||
sample = 0;
|
||||
if (m_settings.m_trackerType == FreqTrackerSettings::TrackerFLL)
|
||||
{
|
||||
m_fll.feed(re, im);
|
||||
}
|
||||
else if (m_settings.m_trackerType == FreqTrackerSettings::TrackerPLL)
|
||||
{
|
||||
m_pll.feed(re, im);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -175,6 +178,7 @@ void FreqTracker::start()
|
||||
{
|
||||
qDebug("FreqTracker::start");
|
||||
m_squelchCount = 0;
|
||||
applyChannelSettings(m_inputSampleRate, m_inputFrequencyOffset, true);
|
||||
m_running = true;
|
||||
}
|
||||
|
||||
@ -184,6 +188,19 @@ void FreqTracker::stop()
|
||||
m_running = false;
|
||||
}
|
||||
|
||||
Real FreqTracker::getFrequency() const
|
||||
{
|
||||
if (!m_settings.m_tracking) {
|
||||
return 0;
|
||||
} else if (m_settings.m_trackerType == FreqTrackerSettings::TrackerPLL) {
|
||||
return (m_pll.getFreq() * m_channelSampleRate) / (2.0 * M_PI);
|
||||
} else if (m_settings.m_trackerType == FreqTrackerSettings::TrackerFLL) {
|
||||
return (m_fll.getFreq() * m_channelSampleRate) / (2.0 * M_PI);
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
bool FreqTracker::handleMessage(const Message& cmd)
|
||||
{
|
||||
if (DSPSignalNotification::match(cmd))
|
||||
@ -196,17 +213,18 @@ bool FreqTracker::handleMessage(const Message& cmd)
|
||||
<< " centerFrequency: " << notif.getCenterFrequency();
|
||||
|
||||
configureChannelizer();
|
||||
|
||||
return true;
|
||||
}
|
||||
else if (DownChannelizer::MsgChannelizerNotification::match(cmd))
|
||||
{
|
||||
DownChannelizer::MsgChannelizerNotification& notif = (DownChannelizer::MsgChannelizerNotification&) cmd;
|
||||
m_inputSampleRate = notif.getSampleRate();
|
||||
m_inputFrequencyOffset = notif.getFrequencyOffset();
|
||||
|
||||
qDebug() << "FreqTracker::handleMessage: MsgChannelizerNotification:"
|
||||
<< " inputSampleRate: " << m_inputSampleRate
|
||||
<< " inputFrequencyOffset: " << m_inputFrequencyOffset;
|
||||
<< " inputSampleRate: " << notif.getSampleRate()
|
||||
<< " inputFrequencyOffset: " << notif.getFrequencyOffset();
|
||||
|
||||
applyChannelSettings(notif.getSampleRate(), notif.getFrequencyOffset());
|
||||
setInterpolator();
|
||||
|
||||
return true;
|
||||
@ -225,6 +243,26 @@ bool FreqTracker::handleMessage(const Message& cmd)
|
||||
}
|
||||
}
|
||||
|
||||
void FreqTracker::applyChannelSettings(int inputSampleRate, int inputFrequencyOffset, bool force)
|
||||
{
|
||||
qDebug() << "AMDemod::applyChannelSettings:"
|
||||
<< " inputSampleRate: " << inputSampleRate
|
||||
<< " inputFrequencyOffset: " << inputFrequencyOffset;
|
||||
|
||||
if ((m_inputFrequencyOffset != inputFrequencyOffset) ||
|
||||
(m_inputSampleRate != inputSampleRate) || force)
|
||||
{
|
||||
m_nco.setFreq(-inputFrequencyOffset, inputSampleRate);
|
||||
}
|
||||
|
||||
if ((m_inputSampleRate != inputSampleRate) || force) {
|
||||
setInterpolator();
|
||||
}
|
||||
|
||||
m_inputSampleRate = inputSampleRate;
|
||||
m_inputFrequencyOffset = inputFrequencyOffset;
|
||||
}
|
||||
|
||||
void FreqTracker::applySettings(const FreqTrackerSettings& settings, bool force)
|
||||
{
|
||||
qDebug() << "FreqTracker::applySettings:"
|
||||
@ -248,6 +286,7 @@ void FreqTracker::applySettings(const FreqTrackerSettings& settings, bool force)
|
||||
|
||||
QList<QString> reverseAPIKeys;
|
||||
bool updateChannelizer = false;
|
||||
bool updateInterpolator = false;
|
||||
|
||||
if ((m_settings.m_inputFrequencyOffset != settings.m_inputFrequencyOffset) || force)
|
||||
{
|
||||
@ -261,16 +300,10 @@ void FreqTracker::applySettings(const FreqTrackerSettings& settings, bool force)
|
||||
updateChannelizer = true;
|
||||
}
|
||||
|
||||
if ((m_settings.m_rfBandwidth != settings.m_rfBandwidth) || force) {
|
||||
reverseAPIKeys.append("rfBandwidth");
|
||||
}
|
||||
|
||||
if ((m_settings.m_rfBandwidth != settings.m_rfBandwidth)
|
||||
&& (m_settings.m_log2Decim == settings.m_log2Decim)
|
||||
&& (m_settings.m_inputFrequencyOffset != settings.m_inputFrequencyOffset)
|
||||
&& !force)
|
||||
if ((m_settings.m_rfBandwidth != settings.m_rfBandwidth) || force)
|
||||
{
|
||||
setInterpolator();
|
||||
updateInterpolator = true;
|
||||
reverseAPIKeys.append("rfBandwidth");
|
||||
}
|
||||
|
||||
if ((m_settings.m_squelch != settings.m_squelch) || force)
|
||||
@ -285,15 +318,37 @@ void FreqTracker::applySettings(const FreqTrackerSettings& settings, bool force)
|
||||
if ((m_settings.m_title != settings.m_title) || force) {
|
||||
reverseAPIKeys.append("title");
|
||||
}
|
||||
if ((m_settings.m_tracking != settings.m_tracking) || force) {
|
||||
|
||||
if ((m_settings.m_tracking != settings.m_tracking) || force)
|
||||
{
|
||||
reverseAPIKeys.append("tracking");
|
||||
if (settings.m_tracking)
|
||||
{
|
||||
m_pll.reset();
|
||||
m_fll.reset();
|
||||
}
|
||||
}
|
||||
if ((m_settings.m_trackerType != settings.m_trackerType) || force) {
|
||||
|
||||
if ((m_settings.m_trackerType != settings.m_trackerType) || force)
|
||||
{
|
||||
reverseAPIKeys.append("trackerType");
|
||||
|
||||
if (settings.m_trackerType == FreqTrackerSettings::TrackerFLL) {
|
||||
m_fll.reset();
|
||||
} else if (settings.m_trackerType == FreqTrackerSettings::TrackerPLL) {
|
||||
m_pll.reset();
|
||||
}
|
||||
}
|
||||
if ((m_settings.m_pllPskOrder != settings.m_pllPskOrder) || force) {
|
||||
|
||||
if ((m_settings.m_pllPskOrder != settings.m_pllPskOrder) || force)
|
||||
{
|
||||
reverseAPIKeys.append("pllPskOrder");
|
||||
|
||||
if (settings.m_pllPskOrder < 32) {
|
||||
m_pll.setPskOrder(settings.m_pllPskOrder);
|
||||
}
|
||||
}
|
||||
|
||||
if ((m_settings.m_rrc != settings.m_rrc) || force) {
|
||||
reverseAPIKeys.append("rrc");
|
||||
}
|
||||
@ -313,9 +368,10 @@ void FreqTracker::applySettings(const FreqTrackerSettings& settings, bool force)
|
||||
|
||||
m_settings = settings;
|
||||
|
||||
if (updateChannelizer)
|
||||
{
|
||||
if (updateChannelizer) {
|
||||
configureChannelizer();
|
||||
} else if (updateInterpolator) {
|
||||
setInterpolator();
|
||||
}
|
||||
}
|
||||
|
||||
@ -325,18 +381,22 @@ void FreqTracker::setInterpolator()
|
||||
m_interpolator.create(16, m_inputSampleRate, m_settings.m_rfBandwidth / 2.2f);
|
||||
m_interpolatorDistanceRemain = 0;
|
||||
m_interpolatorDistance = (Real) m_inputSampleRate / (Real) m_channelSampleRate;
|
||||
m_bandpass.create(301, m_channelSampleRate, 300.0, m_settings.m_rfBandwidth / 2.0f);
|
||||
m_settingsMutex.unlock();
|
||||
}
|
||||
|
||||
void FreqTracker::configureChannelizer()
|
||||
{
|
||||
m_channelSampleRate = m_deviceSampleRate / (1<<m_settings.m_log2Decim);
|
||||
|
||||
qDebug() << "FreqTracker::configureChannelizer:"
|
||||
<< " sampleRate: " << m_deviceSampleRate / (1<<m_settings.m_log2Decim)
|
||||
<< " sampleRate: " << m_channelSampleRate
|
||||
<< " inputFrequencyOffset: " << m_settings.m_inputFrequencyOffset;
|
||||
|
||||
m_pll.setSampleRate(m_channelSampleRate);
|
||||
m_fll.setSampleRate(m_channelSampleRate);
|
||||
|
||||
m_channelizer->configure(m_channelizer->getInputMessageQueue(),
|
||||
m_deviceSampleRate / (1<<m_settings.m_log2Decim),
|
||||
m_channelSampleRate,
|
||||
m_settings.m_inputFrequencyOffset);
|
||||
|
||||
if (m_guiMessageQueue)
|
||||
@ -387,12 +447,9 @@ int FreqTracker::webapiSettingsPutPatch(
|
||||
{
|
||||
(void) errorMessage;
|
||||
FreqTrackerSettings settings = m_settings;
|
||||
bool frequencyOffsetChanged = false;
|
||||
|
||||
if (channelSettingsKeys.contains("inputFrequencyOffset"))
|
||||
{
|
||||
if (channelSettingsKeys.contains("inputFrequencyOffset")) {
|
||||
settings.m_inputFrequencyOffset = response.getFreqTrackerSettings()->getInputFrequencyOffset();
|
||||
frequencyOffsetChanged = true;
|
||||
}
|
||||
if (channelSettingsKeys.contains("rfBandwidth")) {
|
||||
settings.m_rfBandwidth = response.getFreqTrackerSettings()->getRfBandwidth();
|
||||
@ -447,13 +504,6 @@ int FreqTracker::webapiSettingsPutPatch(
|
||||
MsgConfigureFreqTracker *msg = MsgConfigureFreqTracker::create(settings, force);
|
||||
m_inputMessageQueue.push(msg);
|
||||
|
||||
if ((settings.m_log2Decim != m_settings.m_log2Decim) || frequencyOffsetChanged || force)
|
||||
{
|
||||
MsgConfigureChannelizer *msg = MsgConfigureChannelizer::create(
|
||||
m_deviceSampleRate / (1<<settings.m_log2Decim), settings.m_inputFrequencyOffset);
|
||||
m_inputMessageQueue.push(msg);
|
||||
}
|
||||
|
||||
qDebug("FreqTracker::webapiSettingsPutPatch: forward to GUI: %p", m_guiMessageQueue);
|
||||
if (m_guiMessageQueue) // forward to GUI if any
|
||||
{
|
||||
|
@ -147,8 +147,8 @@ public:
|
||||
uint32_t getSampleRate() const { return m_channelSampleRate; }
|
||||
double getMagSq() const { return m_magsq; }
|
||||
bool getSquelchOpen() const { return m_squelchOpen; }
|
||||
bool getPllLocked() const { return (m_settings.m_trackerType == FreqTrackerSettings::TrackerPLL) && m_pll.locked(); }
|
||||
Real getPllFrequency() const { return m_pll.getFreq(); }
|
||||
bool getPllLocked() const { return m_settings.m_tracking && (m_settings.m_trackerType == FreqTrackerSettings::TrackerPLL) && m_pll.locked(); }
|
||||
Real getFrequency() const;
|
||||
|
||||
void getMagSqLevels(double& avg, double& peak, int& nbSamples)
|
||||
{
|
||||
@ -217,7 +217,6 @@ private:
|
||||
MagSqLevelsStore m_magSqLevelStore;
|
||||
|
||||
MovingAverageUtil<Real, double, 16> m_movingAverage;
|
||||
Bandpass<Real> m_bandpass;
|
||||
|
||||
static const int m_udpBlockSize;
|
||||
QNetworkAccessManager *m_networkManager;
|
||||
@ -226,6 +225,7 @@ private:
|
||||
QMutex m_settingsMutex;
|
||||
|
||||
void applySettings(const FreqTrackerSettings& settings, bool force = false);
|
||||
void applyChannelSettings(int inputSampleRate, int inputFrequencyOffset, bool force = false);
|
||||
void setInterpolator();
|
||||
void configureChannelizer();
|
||||
void webapiFormatChannelSettings(SWGSDRangel::SWGChannelSettings& response, const FreqTrackerSettings& settings);
|
||||
|
@ -188,7 +188,11 @@ void FreqTrackerGUI::on_trackerType_currentIndexChanged(int index)
|
||||
|
||||
void FreqTrackerGUI::on_pllPskOrder_currentIndexChanged(int index)
|
||||
{
|
||||
m_settings.m_pllPskOrder = index;
|
||||
if ((index < 0) || (index > 5)) {
|
||||
return;
|
||||
}
|
||||
|
||||
m_settings.m_pllPskOrder = 1<<index;
|
||||
applySettings();
|
||||
}
|
||||
|
||||
@ -372,6 +376,12 @@ void FreqTrackerGUI::tick()
|
||||
|
||||
bool squelchOpen = m_freqTracker->getSquelchOpen();
|
||||
|
||||
if (squelchOpen) {
|
||||
ui->squelchLabel->setStyleSheet("QLabel { background-color : green; }");
|
||||
} else {
|
||||
ui->squelchLabel->setStyleSheet("QLabel { background:rgb(50,50,50); }");
|
||||
}
|
||||
|
||||
if (m_settings.m_tracking)
|
||||
{
|
||||
if (m_freqTracker->getPllLocked()) {
|
||||
@ -380,9 +390,13 @@ void FreqTrackerGUI::tick()
|
||||
ui->tracking->setStyleSheet("QToolButton { background:rgb(79,79,79); }");
|
||||
}
|
||||
|
||||
int freq = (m_freqTracker->getPllFrequency() * m_freqTracker->getSampleRate()) / (2.0*M_PI);
|
||||
ui->tracking->setToolTip(tr("PLL for synchronous AM. Freq = %1 Hz").arg(freq));
|
||||
int freq = m_freqTracker->getFrequency();
|
||||
ui->tracking->setToolTip(tr("Tracking on. Freq = %1 Hz").arg(freq));
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->tracking->setToolTip("Tracking off");
|
||||
}
|
||||
|
||||
m_tickCount++;
|
||||
}
|
||||
|
@ -429,6 +429,11 @@
|
||||
<string>16</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>32</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
@ -504,7 +509,7 @@
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="squelchLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_4">
|
||||
<widget class="QLabel" name="squelchLabel">
|
||||
<property name="text">
|
||||
<string>Sq</string>
|
||||
</property>
|
||||
|
@ -38,7 +38,7 @@ void FreqTrackerSettings::resetToDefaults()
|
||||
m_title = "Frequency Tracker";
|
||||
m_tracking = false;
|
||||
m_trackerType = TrackerFLL;
|
||||
m_pllPskOrder = 1;
|
||||
m_pllPskOrder = 2; // BPSK
|
||||
m_rrc = false;
|
||||
m_rrcRolloff = 35;
|
||||
m_useReverseAPI = false;
|
||||
@ -112,8 +112,8 @@ bool FreqTrackerSettings::deserialize(const QByteArray& data)
|
||||
d.readBool(10, &m_tracking, false);
|
||||
d.readS32(12, &tmp, 0);
|
||||
m_trackerType = tmp < 0 ? TrackerFLL : tmp > 1 ? TrackerPLL : (TrackerType) tmp;
|
||||
d.readU32(13, &utmp, 1);
|
||||
m_pllPskOrder = utmp > 4 ? 4 : utmp;
|
||||
d.readU32(13, &utmp, 2);
|
||||
m_pllPskOrder = utmp > 32 ? 32 : utmp;
|
||||
d.readBool(14, &m_rrc, false);
|
||||
d.readU32(15, &utmp, 35);
|
||||
m_rrcRolloff = utmp > 100 ? 100 : utmp;
|
||||
|
Loading…
Reference in New Issue
Block a user