# -*- coding: utf-8 -*- """ Created on Tue Aug 16 11:28:15 2022 Simple Sketch to Sweep from F1 to F2 @author: Changpuak, using elements from r_57 """ import serial import time # PLEASE DON'T FORGET TO CHANGE THE NUMBER OF THE COM PORT Ning = serial.Serial(port='COM89', baudrate=115200, timeout=.9) time.sleep(5) # Arduinos reset, wait to start up FREQ_START = 10.698 # MHz FREQ_STOP = 10.702 # MHz FREQ_DELTA = 0.001 # MHz WAIT = 5 # sec FREQ = FREQ_START x = [] def CHAT_NINGMOD(x): Ning.write(x.encode('utf-8')) time.sleep(0.5) data = [] line = (Ning.readline()) while len(line) > 0: data.append(line) line = Ning.readline() line = line.decode('utf-8') return data def EMPTY_NINGMOD(x): time.sleep(1) x = b'avanti' while x != b'': x = Ning.readline() # print(x) try: print("STARTING SWEEP ...") CHAT_NINGMOD('SETA:-20\n') EMPTY_NINGMOD(x) while FREQ <= FREQ_STOP: CHAT_NINGMOD('SETF:'+str(FREQ)+'\n') EMPTY_NINGMOD(x) print("{:.3f}".format(FREQ)+" MHz") time.sleep(WAIT) FREQ += FREQ_DELTA finally: Ning.close() print("CONNECTION CLOSED.")