This is merely a historical archive of years 2008-2021, before the migration to mailman3.
A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.
pespin gerrit-no-reply at lists.osmocom.orgHello tnt, I'd like you to do a code review. Please visit https://gerrit.osmocom.org/c/osmo-trx/+/14674 to review the following change. Change subject: Add C/I computation ...................................................................... Add C/I computation Change-Id: Ib4ceec553f2e5f77bf3f6777724968456a180f5e Signed-off-by: Sylvain Munaut <tnt at 246tNt.com> --- M Transceiver52M/Transceiver.cpp M Transceiver52M/sigProcLib.cpp M Transceiver52M/sigProcLib.h 3 files changed, 34 insertions(+), 5 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-trx refs/changes/74/14674/1 diff --git a/Transceiver52M/Transceiver.cpp b/Transceiver52M/Transceiver.cpp index 32297b6..f90decd 100644 --- a/Transceiver52M/Transceiver.cpp +++ b/Transceiver52M/Transceiver.cpp @@ -621,7 +621,7 @@ bi->modulation = (type == EDGE) ? MODULATION_8PSK : MODULATION_GMSK; bi->tss = 0; /* TODO: we only support tss 0 right now */ bi->tsc = 0; - bi->ci = 0; /* TODO: calculate C/I and assign the value here, see branch tnt/ci. */ + bi->ci = 0; /* Select the diversity channel with highest energy */ for (size_t i = 0; i < radio_burst->chans(); i++) { @@ -670,6 +670,7 @@ type = (CorrType) rc; bi->toa = ebp.toa; bi->tsc = ebp.tsc; + bi->ci = (int16_t) ebp.ci; rxBurst = demodAnyBurst(*burst, mSPSRx, ebp.amp, ebp.toa, type); /* EDGE demodulator returns 444 (gSlotLen * 3) bits */ diff --git a/Transceiver52M/sigProcLib.cpp b/Transceiver52M/sigProcLib.cpp index c22009a..a65ea5e 100644 --- a/Transceiver52M/sigProcLib.cpp +++ b/Transceiver52M/sigProcLib.cpp @@ -1453,6 +1453,28 @@ return out; }; +static float computeCI(const signalVector *burst, CorrelationSequence *sync, + float toa, int start, complex xcorr) +{ + float S, C; + int ps; + + /* Integer position where the sequence starts */ + ps = start + 1 - sync->sequence->size() + (int)roundf(toa); + + /* Estimate Signal power */ + S = 0.0f; + for (int i=0, j=ps; i<(int)sync->sequence->size(); i++,j++) + S += (*burst)[j].norm2(); + S /= sync->sequence->size(); + + /* Esimate Carrier power */ + C = xcorr.norm2() / ((sync->sequence->size() - 1) * sync->gain.abs()); + + /* Interference = Signal - Carrier, so C/I = C / (S - C) */ + return 3.0103f * log2f(C / (S - C)); +} + /* * Detect a burst based on correlation and peak-to-average ratio * @@ -1468,6 +1490,7 @@ { const signalVector *corr_in; signalVector *dec = NULL; + complex xcorr; if (sps == 4) { dec = downsampleBurst(burst); @@ -1495,15 +1518,18 @@ if ((ebp->toa < 3 * sps) || (ebp->toa > len - 3 * sps)) return 0; - /* Peak -to-average ratio */ + /* Peak-to-average ratio */ if (computePeakRatio(&corr, sps, ebp->toa, ebp->amp) < thresh) return 0; - /* Compute peak-to-average ratio. Reject if we don't have enough values */ - ebp->amp = peakDetect(corr, &ebp->toa, NULL); + /* Refine TOA and correlation value */ + xcorr = peakDetect(corr, &ebp->toa, NULL); + + /* Compute C/I */ + ebp->ci = computeCI(corr_in, sync, ebp->toa, start, xcorr); /* Normalize our channel gain */ - ebp->amp = ebp->amp / sync->gain; + ebp->amp = xcorr / sync->gain; /* Compensate for residuate time lag */ ebp->toa = ebp->toa - sync->toa; @@ -1563,6 +1589,7 @@ } else if (!rc) { ebp->amp = 0.0f; ebp->toa = 0.0f; + ebp->ci = 0.0f; return clipping?-SIGERR_CLIP:SIGERR_NONE; } diff --git a/Transceiver52M/sigProcLib.h b/Transceiver52M/sigProcLib.h index 6d4ca9b..fd9a5f0 100644 --- a/Transceiver52M/sigProcLib.h +++ b/Transceiver52M/sigProcLib.h @@ -111,6 +111,7 @@ complex amp; float toa; uint8_t tsc; + float ci; }; /** 8-PSK/GMSK/RACH burst detector -- To view, visit https://gerrit.osmocom.org/c/osmo-trx/+/14674 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-trx Gerrit-Branch: master Gerrit-Change-Id: Ib4ceec553f2e5f77bf3f6777724968456a180f5e Gerrit-Change-Number: 14674 Gerrit-PatchSet: 1 Gerrit-Owner: pespin <pespin at sysmocom.de> Gerrit-Reviewer: tnt <tnt at 246tNt.com> Gerrit-MessageType: newchange -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20190704/74326a1a/attachment.htm>