esp-sdr-zephyr
Raw I/Q receive and transmit on the ESP32-S3/C6 Wi-Fi radio, for Zephyr
Loading...
Searching...
No Matches
LTE synchronization signals

LTE downlink synchronization signals as a frequency reference, header only, plain C and libm without Zephyr (esp_sdr_lte.h). More...

Data Structures

struct  esp_sdr_lte_iq
struct  esp_sdr_lte_work
struct  esp_sdr_lte_cell
struct  esp_sdr_lte_cand

Macros

#define ESP_SDR_LTE_DF   15000.0
#define ESP_SDR_LTE_SYNC_PERIOD_S   5e-3
#define ESP_SDR_LTE_SSS_LEAD_S   ((2048.0 + 144.0) / 30.72e6)
#define ESP_SDR_LTE_SC   62
#define ESP_SDR_LTE_L_MAX   272
#define ESP_SDR_LTE_RASTER_HZ   100e3
#define ESP_SDR_LTE_WORK_FLOATS(n_fft)

Functions

static void esp_sdr_lte_work_init (struct esp_sdr_lte_work *w, float *mem, uint32_t n_fft)
 Set up the work memory.
static int esp_sdr_lte_k (int idx)
static void esp_sdr_lte_pss (int n_id2, float *re, float *im)
 The PSS Zadoff-Chu sequence of a sector.
static void esp_sdr_lte_sss (int n_id1, int n_id2, int half, float *d)
 The SSS sequence of a cell group (3GPP TS 36.211, 6.11.2), +-1 per subcarrier.
static int esp_sdr_lte_demod (const struct esp_sdr_lte_iq *x, size_t n, double fs, double start, double f_hz, float *yr, float *yi)
 Demodulate the 62 synchronization subcarriers of one symbol.
static float lte_pss_metric (const float *yr, const float *yi, const float *dr, const float *di)
static int esp_sdr_lte_pss_search (const struct esp_sdr_lte_iq *x, size_t n, double fs, double max_offset_hz, struct esp_sdr_lte_work *w, struct esp_sdr_lte_cand *out, int max_out)
 Search the capture for a PSS.
static int esp_sdr_lte_detect (const struct esp_sdr_lte_iq *x, size_t n, double fs, double max_offset_hz, float min_ratio, struct esp_sdr_lte_work *w, struct esp_sdr_lte_cell *cell)
 Find a cell in a capture and measure its carrier offset.
static double esp_sdr_lte_ppb (double lo_hz, double offset_hz, double *raster_hz)
 Crystal error from a measured carrier.

Detailed Description

LTE downlink synchronization signals as a frequency reference, header only, plain C and libm without Zephyr (esp_sdr_lte.h).

Guide: Crystal calibration.

Macro Definition Documentation

◆ ESP_SDR_LTE_DF

#define ESP_SDR_LTE_DF   15000.0

Subcarrier spacing in Hz.

◆ ESP_SDR_LTE_L_MAX

#define ESP_SDR_LTE_L_MAX   272

Longest symbol useful part in samples: sample rates up to 4 MS/s.

◆ ESP_SDR_LTE_RASTER_HZ

#define ESP_SDR_LTE_RASTER_HZ   100e3

Channel raster in Hz.

◆ ESP_SDR_LTE_SC

#define ESP_SDR_LTE_SC   62

The synchronization signals fill 62 subcarriers either side of the unused DC one.

◆ ESP_SDR_LTE_SSS_LEAD_S

#define ESP_SDR_LTE_SSS_LEAD_S   ((2048.0 + 144.0) / 30.72e6)

Time from the SSS symbol's useful part to the PSS symbol's, normal cyclic prefix, in seconds.

◆ ESP_SDR_LTE_SYNC_PERIOD_S

#define ESP_SDR_LTE_SYNC_PERIOD_S   5e-3

Period of the synchronization signals in seconds (twice per 10 ms frame).

◆ ESP_SDR_LTE_WORK_FLOATS

#define ESP_SDR_LTE_WORK_FLOATS ( n_fft)
Value:
(8U * (n_fft))

Floats esp_sdr_lte_work_init() needs for a transform of n_fft.

Function Documentation

◆ esp_sdr_lte_demod()

int esp_sdr_lte_demod ( const struct esp_sdr_lte_iq * x,
size_t n,
double fs,
double start,
double f_hz,
float * yr,
float * yi )
inlinestatic

Demodulate the 62 synchronization subcarriers of one symbol.

Sums the symbol's useful part against the subcarriers of a carrier at f_hz. The subcarrier phase is relative to the symbol start, the carrier phase to the capture start, so the phase between two symbols carries the frequency error of f_hz.

Parameters
xCapture.
nCapture length.
fsSample rate in Hz, 1.92 to 4 MS/s.
startStart of the useful part in samples, fractional.
f_hzCarrier offset to test, from the capture's centre.
yrReal parts of the 62 subcarrier values.
yiImaginary parts.
Return values
0on success, -ERANGE if the symbol is not inside the capture.

◆ esp_sdr_lte_detect()

int esp_sdr_lte_detect ( const struct esp_sdr_lte_iq * x,
size_t n,
double fs,
double max_offset_hz,
float min_ratio,
struct esp_sdr_lte_work * w,
struct esp_sdr_lte_cell * cell )
inlinestatic

Find a cell in a capture and measure its carrier offset.

Runs esp_sdr_lte_pss_search() on windows of the transform, back to back over the first synchronization period (where every PSS of the capture shows once), until one gives a valid cell: a small transform searches several, each fast, where one large transform would hold the period in slow memory. For each of a window's best few PSS candidates it refines the timing (an eighth of a sample) and frequency (250 Hz), decodes the cell group with the SSS in front of every PSS in the capture and takes the offset from the phase between the SSS and PSS symbols (range +-7 kHz, about 1 kHz accurate). The PSS alone cannot tell the candidates on a Zadoff-Chu ambiguity ridge apart; the one whose SSS matches best wins. The synchronization signals repeat every 5 ms, so a capture of 5 ms or more holds several pairs, which are combined. A decoded cell's reference signals (CRS, 0.5 ms apart) then refine the offset to a few Hz over a capture of 2 ms or more (crs_symbols, crs_metric); where they do not hold together the offset stays the synchronization signals' one.

Parameters
xCapture, any gain that does not clip.
nCapture length, as long as the reference signals should be followed. The PSS is searched for in its first 5 ms and a symbol, in windows of n_fft of w less a symbol.
fsSample rate in Hz, 1.92 to 4 MS/s.
max_offset_hzLargest carrier offset from the capture centre to look for.
min_ratioSmallest PSS detection ratio to go on with (about 20 for a 1 ms capture).
wWork memory.
cellResult.
Return values
0on success; cell->valid tells whether the SSS decoded with margin.
-ENOENTif no PSS stood out, -EINVAL for a capture the work memory cannot hold.

◆ esp_sdr_lte_k()

int esp_sdr_lte_k ( int idx)
inlinestatic

Subcarrier offset in units of 15 kHz of the idx-th of the 62 synchronization subcarriers.

◆ esp_sdr_lte_ppb()

double esp_sdr_lte_ppb ( double lo_hz,
double offset_hz,
double * raster_hz )
inlinestatic

Crystal error from a measured carrier.

The carrier snaps to the 100 kHz raster; the snap is only right while the receiver is off by less than 50 kHz.

Parameters
lo_hzFrequency the receiver was asked for (the LO it believes it has), in Hz.
offset_hzMeasured carrier offset from it.
raster_hzSet to the raster frequency the carrier was taken to be on.
Returns
The error of the receiver's clock in ppb: positive means its LO runs high.

◆ esp_sdr_lte_pss()

void esp_sdr_lte_pss ( int n_id2,
float * re,
float * im )
inlinestatic

The PSS Zadoff-Chu sequence of a sector.

Parameters
n_id2Sector 0 to 2 (roots 25, 29, 34).
reReal parts, ESP_SDR_LTE_SC of them.
imImaginary parts.

◆ esp_sdr_lte_pss_search()

int esp_sdr_lte_pss_search ( const struct esp_sdr_lte_iq * x,
size_t n,
double fs,
double max_offset_hz,
struct esp_sdr_lte_work * w,
struct esp_sdr_lte_cand * out,
int max_out )
inlinestatic

Search the capture for a PSS.

Correlates the three sequences at carrier offsets in steps of about 15 kHz up to max_offset_hz either side, normalised by the energy of each symbol-long window. A Zadoff-Chu sequence trades frequency error for timing error, so a coarse step a few kHz off gives a peak tens of samples from the true start, and several such ridge points can outdo the true one. So the few strongest coarse points are each refined in steps of about 2.5 kHz and the one whose demodulated subcarriers best match the sequence wins.

Parameters
xCapture, at least a PSS symbol long.
nCapture length. The search looks at the first n_fft of w less a symbol of it.
fsSample rate in Hz, 1.92 to 4 MS/s.
max_offset_hzLargest carrier offset to try.
wWork memory.
outCandidates, best demodulated metric first.
max_outCapacity of out.
Returns
The number of candidates, or -EINVAL for a capture or transform under two symbols.

◆ esp_sdr_lte_sss()

void esp_sdr_lte_sss ( int n_id1,
int n_id2,
int half,
float * d )
inlinestatic

The SSS sequence of a cell group (3GPP TS 36.211, 6.11.2), +-1 per subcarrier.

Parameters
n_id1Cell group 0 to 167.
n_id2Sector 0 to 2.
half0 for subframe 0, 1 for subframe 5.
dESP_SDR_LTE_SC values.

◆ esp_sdr_lte_work_init()

void esp_sdr_lte_work_init ( struct esp_sdr_lte_work * w,
float * mem,
uint32_t n_fft )
inlinestatic

Set up the work memory.

Parameters
wWork structure to fill.
memESP_SDR_LTE_WORK_FLOATS(n_fft) floats.
n_fftTransform size, a power of two.

◆ lte_pss_metric()

float lte_pss_metric ( const float * yr,
const float * yi,
const float * dr,
const float * di )
inlinestatic

Normalised correlation of a demodulated PSS with its sequence: 1 for a perfect match.