There is a way of sending signals in simulations. E.g. if you want to transmit the bit combination 10
in a 4QAM system, you would have to start with a modulator, which maps this to a complex symbol: Lets say the mapping is 1+1j
-> Now you would have to "transmit" this complex symbol over a channel which introduces distortion (e.g. additive white gaussian noise). At the receiver you now try to detect this symbol and map it back to the original 10 bit combination.
I would recommend you to program this from scratch to get a better understanding of the topic.
The code for a 4QAM Modulation could e.g. look like this:
import matplotlib.pyplot as plt
import numpy as np
import pylab as pyl
def modulate_4QAM(bits):
b_temp = np.reshape(bits * 2 - 1, (-1, 2)) # reshape bits in [0,1] to [-1,1]
x = 1 / np.sqrt(2) * (b_temp[:, 0] + 1j * b_temp[:, 1])
return x
def detecting_4QAM(received_signal):
# detecting (slicing) and de-mapping
received_bits = np.zeros((len(received_signal), 2))
received_bits[:, 0] = np.real(received_signal) > 0
received_bits[:, 1] = np.imag(received_signal) > 0
received_bits = np.reshape(received_bits, (-1,))
return received_bits
if __name__ == '__main__':
b = pyl.randint(0, 2, int(4)) # generate random bits
x = modulate_4QAM(b) # map bits to complex symbols
noisePower=10**(-5/20) #caltulcate the noise power for a given SNR value
noise = (noisePower)*1/np.sqrt(2)*(pyl.randn(len(x))+1j*pyl.randn(len(x)))#generate noise
y_AWGN =x+noise # add the noise to the signal
b_received = detecting_4QAM(y_AWGN)
Note that scaling from a 4QAM to a 64QAM would result in an additional programming/typing overhead and toolboxes become very handy for that.
This is only a fraction of a coding example which simulates the BER over SNR of an AWGN with a 4QAM modulation from: https://github.com/TheWirelessClassroom/PythonExamples/tree/Modulation
P.S. I'm new to the forum and unsure if only the fraction or the full code is more helpful/wanted. I would be happy to get some feedback on that and change the post accordingly.