{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Simulation of a baseband transmission (minimal working example)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "This example generates a complex baseband signal, representing a real modulated baseband signal, demodulates it and calculates the bit error rate afterwards" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Load package" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "try:\n", " # if you installed skcomm with pypi\n", " import skcomm as skc\n", "except:\n", " # if you like to use skcomm directly from source.\n", " # Please note: If you want to import skcomm into your file using this snippet, you must ensure that the file is on a directional level below skcomm.\n", " import sys, os\n", " current_parent_folder = os.path.abspath('..')\n", " sys.path.append(os.path.join(current_parent_folder))\n", " import skcomm as skc" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Set simulation parameters" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "symbol_rate = 50e6\n", "n_bits = 2**12\n", "mod_order = 4" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Transmitter subfunctions to generate a 50 GBd QPSK signal" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# construct signal\n", "sig_tx = skc.signal.Signal(n_dims=1)\n", "sig_tx.symbol_rate = symbol_rate \n", "\n", "# generate bits\n", "sig_tx.generate_bits(n_bits=n_bits, seed=1)\n", "\n", "# set constellation (modulation format)\n", "sig_tx.generate_constellation(format='QAM', order=mod_order)\n", "\n", "# create symbols\n", "sig_tx.mapper()\n", "\n", "# generate actual sampled signal (pulseshaping)\n", "sig_tx.pulseshaper(upsampling=1.0, pulseshape='rect')\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Channel Functions \n", "Distortions could be added in more complex simulation cases.\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Receiver Functions" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Bit error rate = 0.0\n" ] } ], "source": [ "# rx signal\n", "sig_rx = sig_tx.copy()\n", "\n", "# decision\n", "sig_rx.decision()\n", "\n", "# demapper\n", "sig_rx.demapper()\n", "\n", "# BER counting\n", "ber_res = skc.rx.count_errors(sig_rx.bits[0], sig_rx.samples[0])\n", "print(f\"Bit error rate = {ber_res['ber']}\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Multiple, more advanced algorithms and procedures could now be added at transmitter (**from module tx**) and receiver side (**from module rx**). Further, also distortion effects caused by the channel (***module channel***) could be added." ] } ], "metadata": { "kernelspec": { "display_name": ".venv", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.13.1" } }, "nbformat": 4, "nbformat_minor": 2 }