def mod(input, modScheme, levels, encoding): bitsPerSymbol = int(math.log(levels,2)) # Fails if it is not possible to modulate the number of bits passed # given the number of bits per symbol assert (len(input) % bitsPerSymbol == 0) if modScheme == MOD_SCHEME_PSK: return PSK.mod(input, levels, encoding) if modScheme == MOD_SCHEME_QAM: return QAM.mod(input, levels, encoding)
print('A: process debug data') print('M: QAM Modem') print('X: Exit') print('>> ') while True: if msvcrt.kbhit(): c = msvcrt.getch().decode("utf-8") print(c) c = c.lower() if c == 'a': ## Qam16 modem payload = (np.random.rand(100) * 256).astype(np.uint8) txBaseband = QAM.modulation(payload, QAM.Constant.ModulationType.QAM16) #plt.plot(txBaseband.real, txBaseband.imag, 'bo') #plt.grid() #plt.show() tx_upsampled = rf.UpSampling(txBaseband, 5 / 100, 100) tx_mixer = rf.Mixer(tx_upsampled, 30 / 100, np.pi / 4) tx_sig = tx_mixer.real + rf.WhiteNoise(tx_mixer, 50) #sp.fftPlot(txBaseband.real, txBaseband.imag, n=2) #sp.fftPlot(tx_upsampled.real, tx_upsampled.imag, n=2) #sp.fftPlot(tx_mixer.real, tx_mixer.imag, n=2) #sp.fftPlot(tx_sig.real) rx_mixer = rf.Mixer(tx_sig, -30 / 100, -1 * np.pi / 4) b = signal.remez(100 + 1, [0, .1, 0.2, 0.5], [1, 1e-4])
def demod(input, modScheme, levels, encoding): if modScheme == MOD_SCHEME_PSK: return PSK.demod(input, levels, encoding) if modScheme == MOD_SCHEME_QAM: return QAM.demod(input, levels, encoding)
if i < size-1: if array[i + 1][j] != None: connectionsChecked += 1 diffs = compareStrings(array[i][j], array[i + 1][j]) if diffs != 1: numberThatDoNoDifferByOneBit += 1 print "Number that do not differ by a single bit: {}".format(numberThatDoNoDifferByOneBit) print "Number of connections checked: {}".format(connectionsChecked) print "16 QAM Linear" array = QAM.generateSquareMatrix(4, 0) differByOneByOnly(array) print "\n\n" print "16 QAM Gray" array = QAM.generateSquareMatrix(4, 1) differByOneByOnly(array) print "\n\n" print "64 QAM Linear" array = QAM.generateSquareMatrix(6, 0) differByOneByOnly(array) print "\n\n"