Skip to content

Commit 5446b07

Browse files
authored
Update README.md
1 parent 6406ede commit 5446b07

File tree

1 file changed

+59
-1
lines changed

1 file changed

+59
-1
lines changed

commpy/channelcoding/README.md

Lines changed: 59 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,68 @@ Redundancy of the channel coding schemes influences (decreases) bit rate. Actual
3939
To change the code rate (k/n) of the block code dimensions of the Generator matrix can be changed:
4040
![blockcoderate](https://raw.githubusercontent.com/kirlf/CSP/master/FEC/assets/coderateblock.png)
4141

42-
To change the coderate of the continuous code, e.g. [convolutional code](https://github.com/kirlf/CSP/blob/master/FEC/Convolutional%20codes%20intro.md), **puncturing** procedure is frequently used:
42+
To change the coderate of the continuous code, e.g. convolutional code, **puncturing** procedure is frequently used:
4343

4444
![punct](https://raw.githubusercontent.com/kirlf/CSP/master/FEC/assets/punct.png)
4545

46+
## Example
47+
48+
Let us consider implematation of the **convolutional codes** as an example.
49+
50+
Main modeling routines:
51+
- generate random message
52+
- encode
53+
- modulate it
54+
- add a noise (e.g. AWGN)
55+
- demodulate
56+
- decode
57+
- check the error correction
58+
59+
```python
60+
import numpy as np
61+
import commpy.channelcoding.convcode as cc
62+
import commpy.modulation as modulation
63+
64+
N = 100000 #number of symbols per the frame
65+
message_bits = np.random.randint(0, 2, N) # message
66+
67+
M = 4 # modulation order (QPSK)
68+
k = np.log2(M) #number of bit per modulation symbol
69+
modem = modulation.PSKModem(M) # M-PSK modem initialization
70+
```
71+
72+
The [following](https://en.wikipedia.org/wiki/File:Conv_code_177_133.png) convolutional code will be used:
73+
74+
![](https://upload.wikimedia.org/wikipedia/commons/thumb/b/b3/Conv_code_177_133.png/800px-Conv_code_177_133.png)
75+
76+
*Shift-register for the (7, [171, 133]) convolutional code polynomial.*
77+
78+
Convolutional encoder parameters:
79+
80+
```python
81+
rate = 1/2 # code rate
82+
L = 7 # constraint length
83+
m = np.array([L-1]) # number of delay elements
84+
generator_matrix = np.array([[0o171, 0o133]]) # generator branches
85+
trellis = cc.Trellis(M, generator_matrix) # Trellis structure
86+
```
87+
88+
Viterbi decoder parameters:
89+
90+
```python
91+
tb_depth = 5*(m.sum() + 1) # traceback depth
92+
```
93+
94+
Simulation loop:
95+
96+
```python
97+
EbNo = 5 # energy per bit to noise power spectral density ratio (in dB)
98+
snrdB = EbNo + 10*np.log10(k*rate) # Signal-to-Noise ratio (in dB)
99+
noiseVar = 10**(-snrdB/10) # noise variance (power)
100+
101+
102+
```
103+
46104
### Reference
47105

48106
[1] Moon, Todd K. "Error correction coding." Mathematical Methods and Algorithms. Jhon Wiley and Son (2005).

0 commit comments

Comments
 (0)