aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTom Tsou <tom@tsou.cc>2014-12-18 15:26:57 -0800
committerAlexander Chemeris <Alexander.Chemeris@gmail.com>2015-05-14 00:15:06 -0400
commita6e2d6f9a109662ff4e95bff1d49dfa00c4b164c (patch)
tree82d91caabe30fb31a2b6192e817395b4eea7fae1
parent456cf7f068e7244c4558c0e6eaa02dcbdfdc210b (diff)
Transceiver52M: Add clipping detection on RACH input
Alert user of overdriven RACH input indicated by a positive threshold detector result. This indication serves as notification that the receive RF gain level is too high for the configured transceiver setup. Signed-off-by: Tom Tsou <tom@tsou.cc>
-rw-r--r--Transceiver52M/Transceiver.cpp10
-rw-r--r--Transceiver52M/sigProcLib.cpp25
-rw-r--r--Transceiver52M/sigProcLib.h8
3 files changed, 38 insertions, 5 deletions
diff --git a/Transceiver52M/Transceiver.cpp b/Transceiver52M/Transceiver.cpp
index 7f3187e..f8ed51a 100644
--- a/Transceiver52M/Transceiver.cpp
+++ b/Transceiver52M/Transceiver.cpp
@@ -523,10 +523,18 @@ SoftVector *Transceiver::pullRadioVector(GSM::Time &wTime, int &RSSI,
else
success = detectRACH(state, *burst, amp, toa);
- if (!success) {
+ if (success == 0) {
state->mNoises.insert(avg);
delete radio_burst;
return NULL;
+ } else if (success < 0) {
+ if (success == -SIGERR_CLIP) {
+ LOG(ALERT) << "Clipping detected on RACH input";
+ } else {
+ LOG(ALERT) << "Unhandled RACH error";
+ }
+ delete radio_burst;
+ return NULL;
}
/* Demodulate and set output info */
diff --git a/Transceiver52M/sigProcLib.cpp b/Transceiver52M/sigProcLib.cpp
index 54dd8fc..8e1593e 100644
--- a/Transceiver52M/sigProcLib.cpp
+++ b/Transceiver52M/sigProcLib.cpp
@@ -34,6 +34,8 @@ extern "C" {
#include "scale.h"
#include "mult.h"
}
+/* Clipping detection threshold */
+#define CLIP_THRESH 30000.0f
using namespace GSM;
@@ -1340,7 +1342,7 @@ static int detectBurst(signalVector &burst,
/* Correlate */
if (!convolve(&burst, sync->sequence, &corr,
CUSTOM, start, len, sps, 0)) {
- return -1;
+ return -SIGERR_INTERNAL;
}
/* Peak detection - place restrictions at correlation edges */
@@ -1369,6 +1371,18 @@ static int detectBurst(signalVector &burst,
return 1;
}
+static int detectClipping(signalVector &burst, float thresh)
+{
+ for (size_t i = 0; i < burst.size(); i++) {
+ if (fabs(burst[i].real()) > thresh)
+ return 1;
+ if (fabs(burst[i].imag()) > thresh)
+ return 1;
+ }
+
+ return 0;
+}
+
/*
* RACH burst detection
*
@@ -1390,7 +1404,10 @@ int detectRACHBurst(signalVector &rxBurst,
CorrelationSequence *sync;
if ((sps != 1) && (sps != 4))
- return -1;
+ return -SIGERR_UNSUPPORTED;
+
+ if (detectClipping(rxBurst, CLIP_THRESH))
+ return -SIGERR_CLIP;
target = 8 + 40;
head = 4;
@@ -1443,7 +1460,7 @@ int analyzeTrafficBurst(signalVector &rxBurst, unsigned tsc, float thresh,
CorrelationSequence *sync;
if ((tsc < 0) || (tsc > 7) || ((sps != 1) && (sps != 4)))
- return -1;
+ return -SIGERR_UNSUPPORTED;
target = 3 + 58 + 16 + 5;
head = 4;
@@ -1459,7 +1476,7 @@ int analyzeTrafficBurst(signalVector &rxBurst, unsigned tsc, float thresh,
delete corr;
if (rc < 0) {
- return -1;
+ return -SIGERR_INTERNAL;
} else if (!rc) {
if (amp)
*amp = 0.0f;
diff --git a/Transceiver52M/sigProcLib.h b/Transceiver52M/sigProcLib.h
index 147c14c..f7f6259 100644
--- a/Transceiver52M/sigProcLib.h
+++ b/Transceiver52M/sigProcLib.h
@@ -28,6 +28,14 @@ enum ConvType {
UNDEFINED,
};
+enum signalError {
+ SIGERR_NONE,
+ SIGERR_BOUNDS,
+ SIGERR_CLIP,
+ SIGERR_UNSUPPORTED,
+ SIGERR_INTERNAL,
+};
+
/** Convert a linear number to a dB value */
float dB(float x);