Skip to main content

Module css

Module css 

Source
Expand description

Chirp spread spectrum: the frequency-shift chirp modulation of LoRa.

§Model

A symbol $a \in {0, \dots, M - 1}$, $M = 2^{\mathrm{SF}}$ with the spreading factor $\mathrm{SF}$, is a chirp of $M$ chips over the bandwidth $B$ whose initial frequency is shifted by $aB/M$ and folded at $B/2$. Its complex envelope over $0 \le t < T_{s} = M/B$ is (M. Chiani and A. Elzanaty, IEEE Internet Things J. 6(5), 2019, eq. (5))

$$x(t; a) = \exp\left\{j 2\pi B t \left(\frac{a}{M} - \frac{1}{2} + \frac{Bt}{2M} - u\left(t - \frac{M - a}{B}\right)\right)\right\},$$

a memoryless continuous-phase modulation. At one sample per chip the fold vanishes and $x_{a}[n] = e^{j2\pi(n^{2}/(2M) + (a/M - 1/2) n)}$ (their eq. (13); eq. (1) of Tapparel et al. 2020, eq. (2) of Afisiadis et al. 2020). Css samples it oversampling times per chip; Waveform also gives, for comparison, the discrete chirp of L. Vangelista, IEEE Signal Process. Lett. 24(12), 2017, eq. (3), $e^{j2\pi((a + n) \bmod M) n/M}$, whose quadratic phase lacks the factor $1/2$ (Chiani and Elzanaty, Sec. II-A), and the FSK of the same cardinality of his eq. (17).

The modulator tabulates the chirp of symbol 0 and the tones $e^{j 2\pi k/(JM)}$ once per call: the sample $n$ of symbol $a$ is the product of the base chirp, the tone $(a n) \bmod JM$ and, after the fold, the conjugate of the tone $(M n) \bmod JM$, within a few units of the last place of the direct evaluation of the phase.

§Demodulation

The receiver multiplies every symbol by the conjugate of the chirp of symbol 0 and takes a DFT (Vangelista, eq. (16)): the dechirped symbol $a$ is a tone in bin $a$ (and, when oversampled, in bin $a - M$ after the fold), so the noncoherent decision is the bin of largest energy, the maximum-likelihood detection of these orthogonal signals with an unknown phase. theory gives its error rates, the spectrum and the effect of a same-SF interferer.

§SNR

The SNR is that of a sample at one sample per chip (the signal power over the noise power in the band $B$), the abscissa of the figures of Vangelista (2017), Afisiadis et al. (2020) and Tapparel et al. (2020); the SNR per symbol is $M$ times larger.

§Trademarks and patents

LoRa is a trademark of Semtech Corporation, and the modulation is covered by patents (F. Sforza, US 8,406,275, 2013; O. B. A. Seller and N. Sornin, US 9,252,834, 2016). This module models the published descriptions above for simulation and research; it is not the code of any vendor nor a certified implementation.

§Verb traits

Css implements Modulate<Labels> and Demodulate<Labels> of comnum-core on one stream of symbol indices (Labels), at its Css::sample_rate (1 Hz by default, time in samples), the demodulator refusing an input at another rate: the slice methods Css::modulate and Css::demodulate (the noncoherent decisions) inside. The soft output, Css::energies, stays a method.

§Examples

use comnum_core::prelude::*;
use comnum_waveform::css::Css;
let css = Css::lora(7)?;
let s = css.modulate(&[0, 5, 127])?;
assert_eq!(s.len(), 3 * 128);
assert!(s.iter().all(|v| (v.norm() - 1.0).abs() < 1e-12));   // constant envelope
assert_eq!(css.demodulate(&s)?, vec![0, 5, 127]);
// the same through the verb traits
let mut css = Css { sample_rate: Hertz(125e3), ..css };
let x = Modulate::modulate(&css, &Labels::from_stream(vec![0, 5, 127])?)?;
assert_eq!((x.stream(0), x.sample_rate()), (&s[..], Hertz(125e3)));
let a: Labels = Demodulate::demodulate(&mut css, &x)?;
assert_eq!(a.stream(0), [0, 5, 127]);

Modules§

theory
The theory of chirp spread spectrum: error rates, cross-correlation, spectrum and same-SF interference.

Structs§

Css
A chirp spread-spectrum link (see the module): a configuration with public fields, built by Css::lora and changed by struct update, checked by Css::check when it is used.

Enums§

Waveform
The family of waveforms (see the module).