added error
This commit is contained in:
parent
f701c204c6
commit
71a6045885
12
channel.py
12
channel.py
@ -2,12 +2,22 @@ import numpy as np
|
|||||||
|
|
||||||
channel_response = np.array([0, 0, 0, 1, 0, 0, 0])
|
channel_response = np.array([0, 0, 0, 1, 0, 0, 0])
|
||||||
|
|
||||||
|
# 15dB seems to be around the minimum for error-free transmission
|
||||||
|
snr_db = 15
|
||||||
|
|
||||||
def sim(in_data):
|
def sim(in_data):
|
||||||
out_data = np.ndarray((len(in_data), len(in_data[0])), dtype=np.csingle)
|
out_data = np.ndarray((len(in_data), len(in_data[0])), dtype=np.csingle)
|
||||||
|
|
||||||
|
# noise stuff is straight copied from the DSP illustrations article
|
||||||
for i in range(len(in_data)):
|
for i in range(len(in_data)):
|
||||||
convolved = np.convolve(channel_response, in_data[i], mode='same')
|
convolved = np.convolve(channel_response, in_data[i], mode='same')
|
||||||
out_data[i] = convolved
|
|
||||||
|
signal_power = np.mean(abs(convolved**2))
|
||||||
|
noise_power = signal_power * 10**(-snr_db/10)
|
||||||
|
|
||||||
|
noise = np.sqrt(noise_power / 2) * (np.random.randn(*convolved.shape) + 1j*np.random.randn(*convolved.shape))
|
||||||
|
|
||||||
|
out_data[i] = convolved + noise
|
||||||
|
|
||||||
return out_data
|
return out_data
|
||||||
|
|
||||||
|
6
main.py
6
main.py
@ -7,7 +7,7 @@ Hopefully eventually this modem design makes it onto an fpga.
|
|||||||
TODO:
|
TODO:
|
||||||
Add comments for functions
|
Add comments for functions
|
||||||
Explain what the main function is doing
|
Explain what the main function is doing
|
||||||
Finish doing the channel simulation stuff (add noise, and verify channel response)
|
Add more errors, like a shifted signal
|
||||||
Add support for 16-QAM, 64-QAM, etc...
|
Add support for 16-QAM, 64-QAM, etc...
|
||||||
Add channel estimation via pilot carriers
|
Add channel estimation via pilot carriers
|
||||||
Add some sort of payload support, i.e. be able to drop the padding at the end
|
Add some sort of payload support, i.e. be able to drop the padding at the end
|
||||||
@ -48,7 +48,7 @@ if __name__ == '__main__':
|
|||||||
|
|
||||||
bytes = bytearray(data, 'utf8')
|
bytes = bytearray(data, 'utf8')
|
||||||
|
|
||||||
parallel = parallelise(16, bytes)
|
parallel = parallelise(64, bytes)
|
||||||
|
|
||||||
modulated = qam.modulate(parallel)
|
modulated = qam.modulate(parallel)
|
||||||
|
|
||||||
@ -66,6 +66,6 @@ if __name__ == '__main__':
|
|||||||
|
|
||||||
to_serialise = qam.demodulate(to_decode)
|
to_serialise = qam.demodulate(to_decode)
|
||||||
|
|
||||||
data = serialise(16, to_serialise)
|
data = serialise(64, to_serialise)
|
||||||
|
|
||||||
print(data)
|
print(data)
|
||||||
|
Loading…
Reference in New Issue
Block a user