LTE downlink synchronization signals as a frequency reference, header only, plain C and libm without Zephyr (esp_sdr_lte.h).
More...
|
| 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.
|
LTE downlink synchronization signals as a frequency reference, header only, plain C and libm without Zephyr (esp_sdr_lte.h).
Guide: Crystal calibration.
◆ 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 |
◆ 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 | ) |
|
◆ 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
-
| x | Capture. |
| n | Capture length. |
| fs | Sample rate in Hz, 1.92 to 4 MS/s. |
| start | Start of the useful part in samples, fractional. |
| f_hz | Carrier offset to test, from the capture's centre. |
| yr | Real parts of the 62 subcarrier values. |
| yi | Imaginary parts. |
- Return values
-
| 0 | on success, -ERANGE if the symbol is not inside the capture. |
◆ esp_sdr_lte_detect()
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
-
| x | Capture, any gain that does not clip. |
| n | Capture 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. |
| fs | Sample rate in Hz, 1.92 to 4 MS/s. |
| max_offset_hz | Largest carrier offset from the capture centre to look for. |
| min_ratio | Smallest PSS detection ratio to go on with (about 20 for a 1 ms capture). |
| w | Work memory. |
| cell | Result. |
- Return values
-
| 0 | on success; cell->valid tells whether the SSS decoded with margin. |
| -ENOENT | if 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_hz | Frequency the receiver was asked for (the LO it believes it has), in Hz. |
| offset_hz | Measured carrier offset from it. |
| raster_hz | Set 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_id2 | Sector 0 to 2 (roots 25, 29, 34). |
| re | Real parts, ESP_SDR_LTE_SC of them. |
| im | Imaginary parts. |
◆ esp_sdr_lte_pss_search()
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
-
| x | Capture, at least a PSS symbol long. |
| n | Capture length. The search looks at the first n_fft of w less a symbol of it. |
| fs | Sample rate in Hz, 1.92 to 4 MS/s. |
| max_offset_hz | Largest carrier offset to try. |
| w | Work memory. |
| out | Candidates, best demodulated metric first. |
| max_out | Capacity 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_id1 | Cell group 0 to 167. |
| n_id2 | Sector 0 to 2. |
| half | 0 for subframe 0, 1 for subframe 5. |
| d | ESP_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
-
◆ 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.