- refactored
- added AWGN git-svn-id: http://moon:8086/svn/software/trunk/projects/mpsk_rx_gui@1099 b431acfa-c32f-4a4a-93f1-934dc6c82436
This commit is contained in:
+29
-14
@@ -1,12 +1,15 @@
|
|||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
#include "Receiver.hpp"
|
#include "Receiver.hpp"
|
||||||
#include "MinMaxLemire.h"
|
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
#include <radio/ComplexVector.hpp>
|
#include <radio/ComplexVector.hpp>
|
||||||
#include <radio/RealVector.hpp>
|
#include <radio/RealVector.hpp>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
/***************************************************************/
|
/***************************************************************/
|
||||||
const uint32_t LPF_OVERSAMPLING = 16; // Arm-Filter: oversampling
|
const uint32_t LPF_OVERSAMPLING = 16; // Arm-Filter: oversampling
|
||||||
const radio_float_t LPF_OMEGA = (radio_float_t)0.48; // Arm-Filter: RC Roll-off
|
const radio_float_t LPF_OMEGA = (radio_float_t)0.48; // Arm-Filter: RC Roll-off
|
||||||
@@ -16,7 +19,7 @@ const uint32_t RCF_NUM_PHASES = 256; // RCF_TYPE_POLYPHASE_DISCRETE:
|
|||||||
|
|
||||||
const radio_float_t CPR_GAIN_LEAD_AQU = (radio_float_t)5.00E-5; // 3E-5
|
const radio_float_t CPR_GAIN_LEAD_AQU = (radio_float_t)5.00E-5; // 3E-5
|
||||||
const radio_float_t CPR_GAIN_LAG_AQU = (radio_float_t)0.40E-6; // 1E-6
|
const radio_float_t CPR_GAIN_LAG_AQU = (radio_float_t)0.40E-6; // 1E-6
|
||||||
const radio_float_t CPR_GAIN_LEAD_TRK = (radio_float_t)5.00E-6; // 1E-5
|
const radio_float_t CPR_GAIN_LEAD_TRK = (radio_float_t)2.00E-6; // 1E-5
|
||||||
const radio_float_t CPR_GAIN_LAG_TRK = (radio_float_t)1.00E-9; // 5E-7
|
const radio_float_t CPR_GAIN_LAG_TRK = (radio_float_t)1.00E-9; // 5E-7
|
||||||
|
|
||||||
const radio_float_t STR_GAIN_LEAD_AQU = (radio_float_t)4.00E-4; // 2E-3
|
const radio_float_t STR_GAIN_LEAD_AQU = (radio_float_t)4.00E-4; // 2E-3
|
||||||
@@ -53,9 +56,9 @@ Receiver::Receiver(LogHandler *pLogHandler)
|
|||||||
m_params.samplerate = 48000;
|
m_params.samplerate = 48000;
|
||||||
m_params.symbolrate = m_params.samplerate/4;
|
m_params.symbolrate = m_params.samplerate/4;
|
||||||
m_params.ddc_freq = m_params.samplerate/4;
|
m_params.ddc_freq = m_params.samplerate/4;
|
||||||
m_params.CPR_phase = 0;
|
|
||||||
|
|
||||||
startTimer (1000 / 10);
|
startTimer (1000 / 10);
|
||||||
|
Noise_Init(&m_noise, 0x12345678);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -75,7 +78,7 @@ void Receiver::addDataListener(ReceiverDataListener *pListener)
|
|||||||
m_pDataListener = pListener;
|
m_pDataListener = pListener;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Receiver::setBufSize(uint32 size)
|
void Receiver::setBufSize(size_t size)
|
||||||
{
|
{
|
||||||
|
|
||||||
const ScopedLock sl (m_lock);
|
const ScopedLock sl (m_lock);
|
||||||
@@ -117,7 +120,7 @@ void Receiver::initDefaultParams()
|
|||||||
{
|
{
|
||||||
|
|
||||||
m_params.CPR_phase = 0;
|
m_params.CPR_phase = 0;
|
||||||
|
m_params.awgn_dB = -60;
|
||||||
m_params.agc_state = agc_state_acquisition;
|
m_params.agc_state = agc_state_acquisition;
|
||||||
m_params.agc_mode = agc_mode_disabled;
|
m_params.agc_mode = agc_mode_disabled;
|
||||||
m_params.agcMu[0] = AGC_ADAPTION_RATE_ACQ;
|
m_params.agcMu[0] = AGC_ADAPTION_RATE_ACQ;
|
||||||
@@ -350,11 +353,11 @@ void Receiver::timerCallback()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Receiver::processPassband(RVec const &rf, uint32_t len)
|
void Receiver::processPassband(RVec const &rf, size_t len)
|
||||||
{
|
{
|
||||||
const ScopedLock sl (m_lock);
|
const ScopedLock sl (m_lock);
|
||||||
|
|
||||||
uint32_t len_down;
|
size_t len_down;
|
||||||
radio_float_t test4normal;
|
radio_float_t test4normal;
|
||||||
|
|
||||||
if (!m_ReceiverEnable)
|
if (!m_ReceiverEnable)
|
||||||
@@ -363,7 +366,7 @@ void Receiver::processPassband(RVec const &rf, uint32_t len)
|
|||||||
}
|
}
|
||||||
|
|
||||||
test4normal = 0;
|
test4normal = 0;
|
||||||
for (uint32_t i=0; i < len; i++)
|
for (size_t i=0; i < len; i++)
|
||||||
{
|
{
|
||||||
test4normal += rf[i];
|
test4normal += rf[i];
|
||||||
}
|
}
|
||||||
@@ -376,13 +379,25 @@ void Receiver::processPassband(RVec const &rf, uint32_t len)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RVec rf_noise(rf);
|
||||||
|
radio_float_t k_awgn = 0;
|
||||||
|
if (m_params.awgn_dB > -1000)
|
||||||
|
{
|
||||||
|
k_awgn = pow(10.0, m_params.awgn_dB/20.0);
|
||||||
|
}
|
||||||
|
for (size_t i=0; i < len; i++)
|
||||||
|
{
|
||||||
|
radio_float_t n = Noise_Gaussian(&m_noise, 0, k_awgn);
|
||||||
|
rf_noise[i] += n;
|
||||||
|
}
|
||||||
|
|
||||||
#ifndef DISABLE_UNUSED_STATISTICS
|
#ifndef DISABLE_UNUSED_STATISTICS
|
||||||
SlidingVarProcessV(&m_statistics.RF, rf.data(), len);
|
SlidingVarProcessV(&m_statistics.RF, rf_noise.data(), len);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Digital Down Converter
|
// Digital Down Converter
|
||||||
// @samplerate
|
// @samplerate
|
||||||
m_nco_ddc.mixRealComplexV(m_passbandBuffer, rf, RealScalar(2)/*m_params.agcGain[0]*/, len);
|
m_nco_ddc.mixRealComplexV(m_passbandBuffer, rf_noise, RealScalar(2)/*m_params.agcGain[0]*/, len);
|
||||||
|
|
||||||
// Arm Filtering and downsampling
|
// Arm Filtering and downsampling
|
||||||
len_down = m_firArmDown.process(m_basebandBuffer, m_passbandBuffer, len);
|
len_down = m_firArmDown.process(m_basebandBuffer, m_passbandBuffer, len);
|
||||||
@@ -391,9 +406,9 @@ void Receiver::processPassband(RVec const &rf, uint32_t len)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Receiver::processBaseband(radio_float_t *pI, radio_float_t *pQ, uint32_t len)
|
void Receiver::processBaseband(radio_float_t *pI, radio_float_t *pQ, size_t len)
|
||||||
{
|
{
|
||||||
for (uint32_t i=0; i < len/2; i++)
|
for (size_t i=0; i < len/2; i++)
|
||||||
{
|
{
|
||||||
m_basebandBuffer[i] = ComplexScalar(pI[2*i], pQ[2*i]);
|
m_basebandBuffer[i] = ComplexScalar(pI[2*i], pQ[2*i]);
|
||||||
}
|
}
|
||||||
@@ -401,13 +416,13 @@ void Receiver::processBaseband(radio_float_t *pI, radio_float_t *pQ, uint32_t le
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Baseband processing
|
// Baseband processing
|
||||||
void Receiver::processBaseband(CVec const &iq, uint32_t len)
|
void Receiver::processBaseband(CVec const &iq, size_t len)
|
||||||
{
|
{
|
||||||
const ScopedLock sl (m_lock);
|
const ScopedLock sl (m_lock);
|
||||||
|
|
||||||
static cpx_t IQ_hard_last;
|
static cpx_t IQ_hard_last;
|
||||||
|
|
||||||
uint32_t n;
|
size_t n;
|
||||||
static cpx_t IQ_mf = {0,0};
|
static cpx_t IQ_mf = {0,0};
|
||||||
cpx_t IQ_agc = {0,0};
|
cpx_t IQ_agc = {0,0};
|
||||||
cpx_t IQ_cpr = {0,0};
|
cpx_t IQ_cpr = {0,0};
|
||||||
|
|||||||
+10
-7
@@ -21,6 +21,7 @@
|
|||||||
#include <cpp/radio/metrics/Tracker.hpp>
|
#include <cpp/radio/metrics/Tracker.hpp>
|
||||||
|
|
||||||
#include <cpp/radio/Nco.hpp>
|
#include <cpp/radio/Nco.hpp>
|
||||||
|
#include <noise/noise.h>
|
||||||
|
|
||||||
#ifdef _WINDOWS
|
#ifdef _WINDOWS
|
||||||
#include <float.h>
|
#include <float.h>
|
||||||
@@ -165,6 +166,7 @@ typedef struct _params_t
|
|||||||
radio_float_t samplerate;
|
radio_float_t samplerate;
|
||||||
radio_float_t ddc_freq;
|
radio_float_t ddc_freq;
|
||||||
radio_float_t CPR_phase;
|
radio_float_t CPR_phase;
|
||||||
|
radio_float_t awgn_dB;
|
||||||
bool dfeAutoUpdateEnable;
|
bool dfeAutoUpdateEnable;
|
||||||
bool strAutoControlEnable;
|
bool strAutoControlEnable;
|
||||||
bool cprAutoControlEnable;
|
bool cprAutoControlEnable;
|
||||||
@@ -332,9 +334,9 @@ public:
|
|||||||
~Receiver(void);
|
~Receiver(void);
|
||||||
void init();
|
void init();
|
||||||
void free();
|
void free();
|
||||||
void processBaseband(radio_float_t *pI, radio_float_t *pQ, uint32_t len);
|
void processBaseband(radio_float_t *pI, radio_float_t *pQ, size_t len);
|
||||||
void processPassband(RVec const &rf, uint32_t len);
|
void processPassband(RVec const &rf, size_t len);
|
||||||
void setBufSize(uint32 size);
|
void setBufSize(size_t size);
|
||||||
Processor::Buffer<sym_err_t>& getSoftSyms();
|
Processor::Buffer<sym_err_t>& getSoftSyms();
|
||||||
void initDefaultParams();
|
void initDefaultParams();
|
||||||
void addStatusListener(ReceiverStatusListener *pListener);
|
void addStatusListener(ReceiverStatusListener *pListener);
|
||||||
@@ -405,9 +407,12 @@ private:
|
|||||||
Processor::Buffer<ComplexScalar> m_buffer_agc;
|
Processor::Buffer<ComplexScalar> m_buffer_agc;
|
||||||
Processor::Buffer<ComplexScalar> m_buffer_ip;
|
Processor::Buffer<ComplexScalar> m_buffer_ip;
|
||||||
|
|
||||||
|
// Noise
|
||||||
|
noise_gen_t m_noise;
|
||||||
|
trace_t m_trace;
|
||||||
|
|
||||||
void timerCallback();
|
void timerCallback();
|
||||||
void processBaseband(CVec const &iq, uint32_t len);
|
void processBaseband(CVec const &iq, size_t len);
|
||||||
void minMaxInit(minmax_t *pObj, radio_float_t min_initial, radio_float_t max_initial)
|
void minMaxInit(minmax_t *pObj, radio_float_t min_initial, radio_float_t max_initial)
|
||||||
{
|
{
|
||||||
pObj->min = min_initial;
|
pObj->min = min_initial;
|
||||||
@@ -478,8 +483,6 @@ private:
|
|||||||
{
|
{
|
||||||
return m_dfe_off2.getWeights();
|
return m_dfe_off2.getWeights();
|
||||||
}
|
}
|
||||||
|
|
||||||
trace_t m_trace;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // _RECEIVER_H_
|
#endif // _RECEIVER_H_
|
||||||
|
|||||||
Reference in New Issue
Block a user