Skip to content

Commit

Permalink
docs: implements plot generation in docs
Browse files Browse the repository at this point in the history
Signed-off-by: Erik Buer <[email protected]>
  • Loading branch information
ErikBuer committed Dec 29, 2023
1 parent c78f79e commit 11bcd96
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 36 deletions.
4 changes: 3 additions & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ julia = "1.6"

[extras]
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"


[targets]
test = ["Test"]
test = ["Test", "Documenter"]
5 changes: 5 additions & 0 deletions docs/Project.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
[deps]
DSP = "717857b8-e6f2-59f4-9121-6e50c889abd2"
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
FFTW = "7a1cc6ca-52ef-59f5-83cd-3a7055c09341"
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
PyPlot = "d330b81b-6aea-500a-939a-2ce795aea3ee"
SpecialFunctions = "276daf66-3868-5448-9aa4-cd146d93841b"
10 changes: 9 additions & 1 deletion docs/make.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
push!(LOAD_PATH, "../src/")
using Documenter, DigitalComm

# Ensures that the packages used for docs are added to the docs toml file.
using Pkg
Pkg.activate("docs")

using Documenter

include("../src/DigitalComm.jl") # Ensures that the docs is built using the latest version of the package
using .DigitalComm

DocMeta.setdocmeta!(DigitalComm, :DocTestSetup, :(using DigitalComm); recursive=true)

Expand Down
72 changes: 39 additions & 33 deletions docs/src/Examples/example_AWGN.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,38 +4,44 @@ To simulate a transmission of QPSK // 16QAM // 64QAM // 256QAM other a
white additive Gaussian noise and display the received constellation,
the following code can be used

# ----------------------------------------------------
# --- Transmitter
# ----------------------------------------------------
using DigitalComm
using Plots
# --- Parameters
snr = 20;
mcs = 16;
nbBits = 1024* Int(log2(mcs));
# --- Binary sequence generation
bitSeq = genBitSequence(nbBits);
# --- QPSK mapping
qamSeq = bitMappingQAM(mcs,bitSeq);
# ----------------------------------------------------
# --- Channel
# ----------------------------------------------------
# --- AWGN
# Theoretical power is 1 (normalized constellation)
qamNoise, = addNoise(qamSeq,snr,1);
# ----------------------------------------------------
# --- Rx Stage: SRRC
# ----------------------------------------------------
# --- Binary demapper
bitDec = bitDemappingQAM(mcs,qamNoise);
# --- BER measure
ber = sum(xor.(bitDec,bitSeq)) /length(bitSeq);
# --- Display constellation
plt = scatter(real(qamNoise),imag(qamNoise),label="Noisy");
scatter!(plt,real(qamSeq),imag(qamSeq),label="Ideal");
xlabel!("Real part");
ylabel!("Imag part");
display(plt);
## Transmitter

```@example AWG
using ..DigitalComm # hide
using Plots
# --- Parameters
snr = 20;
mcs = 16;
nbBits = 1024* Int(log2(mcs));
# --- Binary sequence generation
bitSeq = genBitSequence(nbBits);
# --- QPSK mapping
qamSeq = bitMappingQAM(mcs,bitSeq); nothing
```

## Channel

```@example AWG
# --- AWGN
# Theoretical power is 1 (normalized constellation)
qamNoise, = addNoise(qamSeq,snr,1); nothing
```

## Recevicer

```@example AWG
# --- Binary demapper
bitDec = bitDemappingQAM(mcs,qamNoise);
# --- BER measure
ber = sum(xor.(bitDec,bitSeq)) /length(bitSeq);
# --- Display constellation
plt = scatter(real(qamNoise),imag(qamNoise),label="Noisy");
scatter(plt,real(qamSeq),imag(qamSeq),label="Ideal");
xlabel!("Real part");
ylabel!("Imag part");
savefig("constellation.svg"); nothing # hide
```

It plots the received constellation impaired by noise (here a 20dB SNR is used)
![Constellation](./../img/constellation.png)
![Constellation](constellation.svg)
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<img src="docs/src/assets/logo.png" alt="Makie.jl" width="380">
</div>

# DigitalCom.jl
# DigitalComm.jl

[![](https://img.shields.io/badge/docs-stable-blue.svg)](https://juliatelecom.github.io/DigitalComm.jl/dev/index.html)
[![Run tests](https://github.com/JuliaTelecom/DigitalComm.jl/actions/workflows/test.yml/badge.svg)](https://github.com/JuliaTelecom/DigitalComm.jl/actions/workflows/test.yml)
Expand Down

0 comments on commit 11bcd96

Please sign in to comment.