# phase-continous FSK import math import matplotlib.pyplot as plt Fs = 10000 # sample rate f0 = 100 # bit 0 f1 = 200 # bit 1 bits = [0, 1, 0, 1] samples_per_bit = 500 phase = 0 time = [] signal = [] for bit in bits: # Selct frequency based on bit if bit == 0: f = f0 else: f = f1 # Generate sample for this bit for i in range(samples_per_bit): # Advance phase phase += 2 * math.pi * f / Fs # Generate carrier sample = math.cos(phase) time.append(len(time) / Fs) signal.append(sample) plt.plot(time, signal) plt.xlabel("Time (seconds)") plt.ylabel("Amplitude") plt.title("Phase-Continuous FSK") plt.grid() plt.show()