added error

This commit is contained in:
David Lenfesty 2019-08-25 19:00:49 -06:00
parent f701c204c6
commit 71a6045885
2 changed files with 14 additions and 4 deletions

View File

@ -2,12 +2,22 @@ import numpy as np
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):
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)):
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

View File

@ -7,7 +7,7 @@ Hopefully eventually this modem design makes it onto an fpga.
TODO:
Add comments for functions
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 channel estimation via pilot carriers
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')
parallel = parallelise(16, bytes)
parallel = parallelise(64, bytes)
modulated = qam.modulate(parallel)
@ -66,6 +66,6 @@ if __name__ == '__main__':
to_serialise = qam.demodulate(to_decode)
data = serialise(16, to_serialise)
data = serialise(64, to_serialise)
print(data)