mirror of
https://github.com/f4exb/sdrangel.git
synced 2025-04-06 11:39:02 -04:00
DC and IQ correction: added a defiend out integer version (no advantage over floating point)
This commit is contained in:
parent
b9b2c41ba2
commit
1efc509296
@ -183,6 +183,44 @@ void DSPDeviceSourceEngine::iqCorrections(SampleVector::iterator begin, SampleVe
|
||||
|
||||
if (imbalanceCorrection)
|
||||
{
|
||||
#if IMBALANCE_INT
|
||||
// acquisition
|
||||
int64_t xi = (it->m_real - (int32_t) m_iBeta) << 5;
|
||||
int64_t xq = (it->m_imag - (int32_t) m_qBeta) << 5;
|
||||
|
||||
// phase imbalance
|
||||
m_avgII((xi*xi)>>28); // <I", I">
|
||||
m_avgIQ((xi*xq)>>28); // <I", Q">
|
||||
|
||||
if ((int64_t) m_avgII != 0)
|
||||
{
|
||||
int64_t phi = (((int64_t) m_avgIQ)<<28) / (int64_t) m_avgII;
|
||||
m_avgPhi(phi);
|
||||
}
|
||||
|
||||
int64_t corrPhi = (((int64_t) m_avgPhi) * xq) >> 28; //(m_avgPhi.asDouble()/16777216.0) * ((double) xq);
|
||||
|
||||
int64_t yi = xi - corrPhi;
|
||||
int64_t yq = xq;
|
||||
|
||||
// amplitude I/Q imbalance
|
||||
m_avgII2((yi*yi)>>28); // <I, I>
|
||||
m_avgQQ2((yq*yq)>>28); // <Q, Q>
|
||||
|
||||
if ((int64_t) m_avgQQ2 != 0)
|
||||
{
|
||||
int64_t a = (((int64_t) m_avgII2)<<28) / (int64_t) m_avgQQ2;
|
||||
Fixed<int64_t, 28> fA(Fixed<int64_t, 28>::internal(), a);
|
||||
Fixed<int64_t, 28> sqrtA = sqrt((Fixed<int64_t, 28>) fA);
|
||||
m_avgAmp(sqrtA.as_internal());
|
||||
}
|
||||
|
||||
int64_t zq = (((int64_t) m_avgAmp) * yq) >> 28;
|
||||
|
||||
it->m_real = yi >> 5;
|
||||
it->m_imag = zq >> 5;
|
||||
|
||||
#else
|
||||
// DC correction and conversion
|
||||
float xi = (it->m_real - (int32_t) m_iBeta) / SDR_RX_SCALEF;
|
||||
float xq = (it->m_imag - (int32_t) m_qBeta) / SDR_RX_SCALEF;
|
||||
@ -214,6 +252,7 @@ void DSPDeviceSourceEngine::iqCorrections(SampleVector::iterator begin, SampleVe
|
||||
// convert and store
|
||||
it->m_real = zi * SDR_RX_SCALEF;
|
||||
it->m_imag = zq * SDR_RX_SCALEF;
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -102,17 +102,30 @@ private:
|
||||
bool m_dcOffsetCorrection;
|
||||
bool m_iqImbalanceCorrection;
|
||||
double m_iOffset, m_qOffset;
|
||||
|
||||
MovingAverageUtil<int32_t, int64_t, 1024> m_iBeta;
|
||||
MovingAverageUtil<int32_t, int64_t, 1024> m_qBeta;
|
||||
|
||||
#if IMBALANCE_INT
|
||||
// Fixed point DC + IQ corrections
|
||||
MovingAverageUtil<int64_t, int64_t, 128> m_avgII;
|
||||
MovingAverageUtil<int64_t, int64_t, 128> m_avgIQ;
|
||||
MovingAverageUtil<int64_t, int64_t, 128> m_avgPhi;
|
||||
MovingAverageUtil<int64_t, int64_t, 128> m_avgII2;
|
||||
MovingAverageUtil<int64_t, int64_t, 128> m_avgQQ2;
|
||||
MovingAverageUtil<int64_t, int64_t, 128> m_avgAmp;
|
||||
|
||||
#else
|
||||
// Floating point DC + IQ corrections
|
||||
MovingAverageUtil<float, double, 128> m_avgII;
|
||||
MovingAverageUtil<float, double, 128> m_avgIQ;
|
||||
MovingAverageUtil<float, double, 128> m_avgII2;
|
||||
MovingAverageUtil<float, double, 128> m_avgQQ2;
|
||||
MovingAverageUtil<double, double, 128> m_avgPhi;
|
||||
MovingAverageUtil<double, double, 128> m_avgAmp;
|
||||
// MovingAverageUtil<int64_t, int64_t, 1024> m_avgII;
|
||||
// MovingAverageUtil<int64_t, int64_t, 1024> m_avgIQ;
|
||||
qint32 m_iRange;
|
||||
#endif
|
||||
|
||||
qint32 m_iRange;
|
||||
qint32 m_qRange;
|
||||
qint32 m_imbalance;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user