aboutsummaryrefslogtreecommitdiffstats
path: root/Transceiver52M/sigProcLib.cpp
diff options
context:
space:
mode:
authorThomas Tsou <tom@tsou.cc>2013-08-20 21:17:19 -0400
committerThomas Tsou <tom@tsou.cc>2013-10-18 13:10:17 -0400
commit8181b0104acd78f8e4a1ddb6df105cab24bba4c1 (patch)
tree37bd022dc8e8278f08087b3e9fd6dfb1181744fb /Transceiver52M/sigProcLib.cpp
parent9471d7635abeb9b5c87227d64e452890da0e65bd (diff)
Transceiver52M: Disable energy detector
The adaptive energy threshold gating suffers a near-far problem at certain gain levels. This is due to exponential threshold raising, but linear decreases. A large signal level followed by a period low signal level causes (comparatively) weak signals to go undetected. Additionally, the algorithm performs differently at multiple RF gain levels. This patch switches solely to correlation based gating for burst detection. The main computational load with this approach is sub-sample width peak interpolation, which we disable for intial detection and run after threshold passing. Signed-off-by: Thomas Tsou <tom@tsou.cc>
Diffstat (limited to 'Transceiver52M/sigProcLib.cpp')
-rw-r--r--Transceiver52M/sigProcLib.cpp33
1 files changed, 30 insertions, 3 deletions
diff --git a/Transceiver52M/sigProcLib.cpp b/Transceiver52M/sigProcLib.cpp
index a647f84..b0ef21a 100644
--- a/Transceiver52M/sigProcLib.cpp
+++ b/Transceiver52M/sigProcLib.cpp
@@ -653,8 +653,27 @@ complex interpolatePoint(const signalVector &inSig,
return pVal;
}
-
-
+static complex fastPeakDetect(const signalVector &rxBurst, float *index)
+{
+ float val, max = 0.0f;
+ complex amp;
+ int _index = -1;
+
+ for (int i = 0; i < rxBurst.size(); i++) {
+ val = rxBurst[i].norm2();
+ if (val > max) {
+ max = val;
+ _index = i;
+ amp = rxBurst[i];
+ }
+ }
+
+ if (index)
+ *index = (float) _index;
+
+ return amp;
+}
+
complex peakDetect(const signalVector &rxBurst,
float *peakIndex,
float *avgPwr)
@@ -928,12 +947,15 @@ int detectRACHBurst(signalVector &rxBurst,
return -1;
}
- _amp = peakDetect(corr, &_toa, NULL);
+ _amp = fastPeakDetect(corr, &_toa);
+
+ /* Restrict peak-to-average calculations at the edges */
if ((_toa < 3) || (_toa > len - 3))
goto notfound;
peak = corr.begin() + (int) rint(_toa);
+ /* Compute peak-to-average ratio. Reject if we don't have enough values */
for (int i = 2 * sps; i <= 5 * sps; i++) {
if (peak - i >= corr.begin()) {
avg += (peak - i)->norm2();
@@ -953,9 +975,14 @@ int detectRACHBurst(signalVector &rxBurst,
if (par < thresh)
goto notfound;
+ /* Run the full peak detection to obtain interpolated values */
+ _amp = peakDetect(corr, &_toa, NULL);
+
/* Subtract forward tail bits from delay */
if (toa)
*toa = _toa - 8 * sps;
+
+ /* Normalize our channel gain */
if (amp)
*amp = _amp / gRACHSequence->gain;