# template tile for Lab #7, Task #3 import numpy import matplotlib.pyplot as p import waveforms as w import lab7 p.ion() # transmission rate bits_per_second = 20000 # receive amplitude-modulated transmission: def am_receive(samples,fc,samples_per_bit,channel_bw): ####### # copy your Task 2 code for am_receive to here # and add plot of eye diagram ###### pass if __name__ == '__main__': n = 8 # no. of bits of ISI to test for # generate all possible n-bit sequences message = [0] * (n * 2**n) for i in xrange(2**n): for j in xrange(n): message[i*n + j] = 1 if (i & (2**j)) else 0 message = [0,0] + message + [0,0] # periodic message = numpy.array(message,dtype=numpy.int) # send it through transmitter, modulate to legal freq near 125 kHz samples_per_bit = lab7.samples_per_bit(lab7.sample_rate, bits_per_second) fc = lab7.quantize_frequency(125e3,lab7.sample_rate, len(message)*samples_per_bit) xmit = lab7.am_transmit(message,samples_per_bit,lab7.sample_rate, fc,lab7.channel_bw) # run receiver receive = am_receive(xmit,fc,samples_per_bit,lab7.channel_bw) # report results print 'message: ',message print 'received:',receive if not numpy.array_equal(message,receive): print '***** differences *****' else: print 'message received okay'