- class sdr.OQPSK(sdr.PSK)
Implements offset quadrature phase-shift keying (OQPSK) modulation and demodulation.
Notes¶
Offset QPSK is a linear phase modulation scheme similar to conventional QPSK. One key distinction is that the I and Q channels transition independently, one half symbol apart. This prevents symbol transitions through the origin, which results in a lower peak-to-average power ratio (PAPR).
The modulation order
is a power of 2 and indicates the number of phases used. The input bit stream is taken bits at a time to create decimal symbols . These decimal symbols are then mapped to complex symbols by the equationVariable nomenclature
: Symbol index : Sample index : Decimal symbols Complex symbols : Pulse-shaped complex samples : Received (noisy) pulse-shaped complex samples : Received (noisy) complex symbols : Complex symbol decisions : Decimal symbol decisions
Examples¶
Create a OQPSK modem.
In [1]: oqpsk = sdr.OQPSK(pulse_shape="srrc"); oqpsk Out[1]: sdr.OQPSK(phase_offset=45, symbol_labels='gray') In [2]: plt.figure(); \ ...: sdr.plot.symbol_map(oqpsk); ...:
Generate a random bit stream, convert to 2-bit symbols, and map to complex symbols.
In [3]: bits = np.random.randint(0, 2, 1000); bits[0:8] Out[3]: array([0, 1, 1, 0, 1, 1, 1, 1]) In [4]: symbols = sdr.pack(bits, oqpsk.bps); symbols[0:4] Out[4]: array([1, 2, 3, 3], dtype=uint8) In [5]: complex_symbols = oqpsk.map_symbols(symbols); complex_symbols[0:4] Out[5]: array([-0.70710678+0.j , -0.70710678+0.70710678j, 0.70710678+0.70710678j, 0.70710678-0.70710678j]) In [6]: plt.figure(); \ ...: sdr.plot.constellation(complex_symbols, linestyle="-"); ...:
Modulate and pulse shape the symbols to a complex baseband signal.
In [7]: tx_samples = oqpsk.modulate(symbols) In [8]: plt.figure(); \ ...: sdr.plot.time_domain(tx_samples[0:50*oqpsk.sps]); ...:
Examine the eye diagram of the pulse-shaped transmitted signal. The SRRC pulse shape is not a Nyquist filter, so ISI is present.
In [9]: plt.figure(figsize=(8, 6)); \ ...: sdr.plot.eye(tx_samples[5*oqpsk.sps : -5*oqpsk.sps], oqpsk.sps, persistence=True); \ ...: plt.suptitle("Noiseless transmitted signal with ISI"); ...:
Add AWGN noise such that
dB.In [10]: ebn0 = 30; \ ....: snr = sdr.ebn0_to_snr(ebn0, bps=oqpsk.bps, sps=oqpsk.sps); \ ....: rx_samples = sdr.awgn(tx_samples, snr=snr) ....: In [11]: plt.figure(); \ ....: sdr.plot.time_domain(rx_samples[0:50*oqpsk.sps]); ....:
Manually apply a matched filter. Examine the eye diagram of the matched filtered received signal. The two cascaded SRRC filters create a Nyquist RC filter. Therefore, the ISI is removed.
In [12]: mf = sdr.FIR(oqpsk.pulse_shape); \ ....: mf_samples = mf(rx_samples) ....: In [13]: plt.figure(figsize=(8, 6)); \ ....: sdr.plot.eye(mf_samples[10*oqpsk.sps : -10*oqpsk.sps], oqpsk.sps, persistence=True); \ ....: plt.suptitle("Noisy received and matched filtered signal without ISI"); ....:
Matched filter and demodulate. Note, the first symbol has
and the last symbol has .In [14]: rx_symbols, rx_complex_symbols, _ = oqpsk.demodulate(rx_samples) # The symbol decisions are error-free In [15]: np.array_equal(symbols, rx_symbols) Out[15]: True In [16]: plt.figure(); \ ....: sdr.plot.constellation(rx_complex_symbols); ....:
See the Phase-shift keying example.
Constructors¶
-
OQPSK(phase_offset: float =
45
, ...) Creates a new OQPSK object.
Methods¶
-
ber(ebn0: ArrayLike, diff_encoded: bool =
False
) NDArray[float64] Computes the bit error rate (BER) at the provided
values.
-
ser(esn0: ArrayLike, diff_encoded: bool =
False
) NDArray[float64] Computes the symbol error rate (SER) at the provided
values.
- map_symbols(s: ArrayLike) NDArray[complex128]
Converts the decimal symbols into complex symbols.
- decide_symbols(a_tilde) tuple[NDArray[int_], NDArray[complex128]]
Converts the received complex symbols into MLE symbol decisions.
- modulate(s: ArrayLike) NDArray[complex128]
Modulates the decimal symbols into pulse-shaped complex samples.
- demodulate(...) tuple[NDArray[int_], NDArray[complex128], NDArray[complex128]]
Demodulates the pulse-shaped complex samples.
Properties¶
- property phase_offset : float
The phase offset
in degrees.
- property symbol_map : NDArray[np.complex128]
The symbol map
.
- property pulse_shape : NDArray[np.float64]
The pulse shape
of the modulated signal.
- property tx_filter : Interpolator
The transmit interpolating pulse shaping filter.