Skip to main content

OFDM transmitter and receiver

Project description

Features: Nyquist quadrature modulator, pilot tones and cyclic prefix.

The module codec contains the class OFDM to encode, decode, modulate demodualte and to find the start of the symbol.

OFDM class

Constructor: OFDM(nFreqSamples=64, pilotIndices=[-21, -7, 7, 21], pilotAmplitude=1, nData=12, fracCyclic=0.25, mQAM=2)

OFDM encoder and decoder. The data is encoded as QAM using the komm package. Energy dispersal is done with a pre-seeded random number generator. Both pilot tones and the cyclic prefix are added so that the start of the symbol can be detected at the receiver. The complex time series after the inverse Fourier Transform can be modulated into a real valued stream with a Nyquist quadrature modulator for baseband. On the receiver side the start of the symbol is detected by first doing a coarse search with the cyclic prefix and then a precision alignment with the pilots.

nFreqSamples sets the number of frequency coefficients of the FFT. Pilot tones are injected at pilotIndices. The real valued pilot amplitude is pilotAmplitude. For transmission nData bytes are expected in an array. The relative length of the Cyclic prefix is fracCyclic. Number of QAM symbols = 2**mQAM, giving mQAM bits per QAM symbol. Average power is normalised to unity. Default example correspond to 802.11a wifi modulation.

decode(self, randomSeed=1)

Decodes one symbol and returns a byte array of the data and the sum of the squares of the imaginary parts of the pilot tones. The smaller that value the better the symbol start detection, the reception and the jitter (theoretically zero at perfect reception).

encode(self, data, randomSeed=1)

Creates an OFDM symbol using QAM. The signal is a complex valued numpy array where the encoded data-stream is appended. The data is an array of bytes. The random seed sets the pseudo random number generator for the energy dispersal.

findSymbolStartIndex(self, signal, searchrangecoarse=None, searchrangefine=25)

Finds the start of the symbol by 1st doing a cross correlation @nIFFT with the cyclic prefix and then it uses the pilot tones. Arguments: the real valued reception signal, the coarse searchrange for the cyclic prefix and the fine one for the pilots. Returns the cross correlation value array from the cyclic prefix, the squared values of the imaginary parts of the pilots and the index of the symbol start relative to the signal.

initDecode(self, signal, offset)

Starts a decoding process. The signal is the real valued received signal and the decoding start at the index specified by offset.

Periodic pilots

The module codec contains a function which generates evenly spaced pilots. Call the function with the same values for nData and mQAM:

setpilotindex(nData, mQAM, pilotspacing)

Nyquist modulator and demodulator

These are in the module nyquistmodem which convert between complex and real valued signals. The modulation is at nyquist rate which means that its a quadrature modulator operating at a period of 4 samples for the sine and cosine waves.

nyquistdemod(base_signal)

Nyqist demodulator which turns the received real valued signal into a complex valued sequence for the OFDM decoder.

nyquistmod(complex_signal)

Nyqist modulator which turns the complex valued base signal into a real valued sequence to be transmitted.

Examples

See https://github.com/dchutchings/py_ofdm for examples.

Project details


Release history Release notifications | RSS feed

This version

2.1

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyofdm-2.1.tar.gz (7.5 kB view details)

Uploaded Source

Built Distributions

pyofdm-2.1-py3.8.egg (10.9 kB view details)

Uploaded Source

pyofdm-2.1-py3-none-any.whl (19.1 kB view details)

Uploaded Python 3

File details

Details for the file pyofdm-2.1.tar.gz.

File metadata

  • Download URL: pyofdm-2.1.tar.gz
  • Upload date:
  • Size: 7.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: Python-urllib/3.8

File hashes

Hashes for pyofdm-2.1.tar.gz
Algorithm Hash digest
SHA256 2abf5c2dd35c530cb83b87e3de78842c3a3a07e3043fed8a23093f8e6eeae833
MD5 d8509a9be9e73fe37332aa478a0247df
BLAKE2b-256 7f5de6f6671d3cdff07398920ccbe8f75de792b68a0404b6f17ae3cfa6c718c9

See more details on using hashes here.

File details

Details for the file pyofdm-2.1-py3.8.egg.

File metadata

  • Download URL: pyofdm-2.1-py3.8.egg
  • Upload date:
  • Size: 10.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: Python-urllib/3.8

File hashes

Hashes for pyofdm-2.1-py3.8.egg
Algorithm Hash digest
SHA256 402765e40548aebdf69b781fd400551eab588ce9691291fc28c9aa01169cbcd3
MD5 e492ec124b1a25831c37ede5c11aea99
BLAKE2b-256 fb60bb1fadf163fc3b88ea66ef809542dcf3fc0af4f2c05c4489492ba503fbc3

See more details on using hashes here.

File details

Details for the file pyofdm-2.1-py3-none-any.whl.

File metadata

  • Download URL: pyofdm-2.1-py3-none-any.whl
  • Upload date:
  • Size: 19.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: Python-urllib/3.8

File hashes

Hashes for pyofdm-2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 cbfb0c28773f25ceef77cb6d7bb0e6e76d423984eb1a7a5797f2fa0e2687d9f6
MD5 56f7d5306986d7994dfd3d03ea1b19f8
BLAKE2b-256 aaa10ff83dd0ef11e9f5aba35b6ad048e74d25c53da8bf361924d9bf7b0dd549

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page