|  | @@ -34,6 +34,8 @@ def save_waveform():
 | 
	
		
			
				|  |  |  	with open('data/long_term.csv','a') as fd:
 | 
	
		
			
				|  |  |  		fd.write(line)
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +	update_state()
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |  import datetime
 | 
	
		
			
				|  |  |  def clean_old_files():
 | 
	
		
			
				|  |  |  	for dirpath, dirnames, filenames in os.walk("data/waveforms/"):
 | 
	
	
		
			
				|  | @@ -45,6 +47,9 @@ def clean_old_files():
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  @eel.expose
 | 
	
		
			
				|  |  |  def calibrate_gain():
 | 
	
		
			
				|  |  | +	if(state["mode"]!=0):
 | 
	
		
			
				|  |  | +		error("You must be in learn mode to calibrate the loop gain")
 | 
	
		
			
				|  |  | +		return
 | 
	
		
			
				|  |  |  	chip = chips[state["selected_board"]]
 | 
	
		
			
				|  |  |  	auto_set_pga = state["auto_set_pga"]
 | 
	
		
			
				|  |  |  	chip.set_auto_set_pga(0) #Stop it while we scan
 | 
	
	
		
			
				|  | @@ -75,6 +80,9 @@ def calibrate_gain():
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  @eel.expose
 | 
	
		
			
				|  |  |  def calibrate_coarse_fine_ratio():
 | 
	
		
			
				|  |  | +	if(state["mode"]!=0):
 | 
	
		
			
				|  |  | +		error("You must be in learn mode to calibrate the broad to fine ratio")
 | 
	
		
			
				|  |  | +		return
 | 
	
		
			
				|  |  |  	chip = chips[state["selected_board"]]
 | 
	
		
			
				|  |  |  	auto_set_pga = state["auto_set_pga"]
 | 
	
		
			
				|  |  |  	chip.set_auto_set_pga(0) #Stop it while we scan
 | 
	
	
		
			
				|  | @@ -116,6 +124,44 @@ def calibrate_coarse_fine_ratio():
 | 
	
		
			
				|  |  |  	chip.set_auto_set_pga(auto_set_pga)
 | 
	
		
			
				|  |  |  	update_state()
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +@eel.expose
 | 
	
		
			
				|  |  | +def measure_response_function():
 | 
	
		
			
				|  |  | +	if(state["mode"]!=0):
 | 
	
		
			
				|  |  | +		error("You must be in learn mode to measure the response function.")
 | 
	
		
			
				|  |  | +		return
 | 
	
		
			
				|  |  | +	chip = chips[state["selected_board"]]
 | 
	
		
			
				|  |  | +	auto_set_pga = state["auto_set_pga"]
 | 
	
		
			
				|  |  | +	chip.set_auto_set_pga(0) #Stop it while we scan
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +	# Scan Vcoarse
 | 
	
		
			
				|  |  | +	measurements = []
 | 
	
		
			
				|  |  | +	for Vcoarse in range(0, 4000, 100):
 | 
	
		
			
				|  |  | +		chip.set_Vlearn(Vcoarse)
 | 
	
		
			
				|  |  | +		time.sleep(0.1)
 | 
	
		
			
				|  |  | +		data = chip.read_data()
 | 
	
		
			
				|  |  | +		gnd = sum(data[state["start_gnd"]:state["stop_gnd"]])/(state["stop_gnd"]-state["start_gnd"])
 | 
	
		
			
				|  |  | +		signal = sum(data[state["start"]:state["stop"]])/(state["stop"]-state["start"])
 | 
	
		
			
				|  |  | +		print('Vcoarse', chip.get_Vlearn(), 'signal', signal-gnd)
 | 
	
		
			
				|  |  | +		measurements.append([chip.get_Vlearn(), signal-gnd])
 | 
	
		
			
				|  |  | +	chip.set_Vlearn(state["Vlearn"])
 | 
	
		
			
				|  |  | +	measurements = np.array(measurements)
 | 
	
		
			
				|  |  | +	
 | 
	
		
			
				|  |  | +	plt.plot(measurements[:,0], measurements[:,1])
 | 
	
		
			
				|  |  | +	plt.xlabel('Output voltage')
 | 
	
		
			
				|  |  | +	plt.ylabel('Photodiode signal')
 | 
	
		
			
				|  |  | +	plt.plot()
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +	chip.set_auto_set_pga(auto_set_pga)
 | 
	
		
			
				|  |  | +	update_state()
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +@eel.expose
 | 
	
		
			
				|  |  | +def sdev_time():
 | 
	
		
			
				|  |  | +	pass
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +@eel.expose
 | 
	
		
			
				|  |  | +def noise_power_spectrum():
 | 
	
		
			
				|  |  | +	pass
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  ###################################
 | 
	
		
			
				|  |  |  ## EXPOSED GUI COMMUNICATION
 | 
	
	
		
			
				|  | @@ -366,7 +412,7 @@ def update_state():
 | 
	
		
			
				|  |  |  my_options = {
 | 
	
		
			
				|  |  |  	'mode': "chrome-app", #chrome-app
 | 
	
		
			
				|  |  |  	'host': 'localhost',
 | 
	
		
			
				|  |  | -	'port': 8107,
 | 
	
		
			
				|  |  | +	'port': 8000 + int(np.random.rand()*1000),
 | 
	
		
			
				|  |  |  	'size':(710, 725),
 | 
	
		
			
				|  |  |  	#'chromeFlags': ["--start-fullscreen", "--browser-startup-dialog"]
 | 
	
		
			
				|  |  |  }
 |