jarjonam 5 år sedan
förälder
incheckning
54760ed1db
6 ändrade filer med 74 tillägg och 5 borttagningar
  1. 14 2
      pi/server.py
  2. 2 2
      pi/web/main.css
  3. 10 1
      pi/web/main.html
  4. 41 0
      pi/web/main.js
  5. 5 0
      pi/web/popper.min.js
  6. 2 0
      pi/web/tippy.min.js

+ 14 - 2
pi/server.py

@@ -39,6 +39,7 @@ def save_waveform():
 	#update_state()
 
 import datetime
+@eel.expose
 def clean_old_files(path, max_Files):
 	def sorted_ls(path):
 	    mtime = lambda f: os.stat(os.path.join(path, f)).st_mtime
@@ -55,11 +56,18 @@ def clean_old_files(path, max_Files):
 			if datetime.datetime.now() - file_modified > datetime.timedelta(hours=10):
 				os.remove(curpath)'''
 
+@eel.expose
+def clean_long_term():
+	with open('data/long_term.csv','w') as fd:
+		fd.write('')
+
+
 @eel.expose
 def calibrate_gain():
 	if(state["mode"]!=0):
 		error("You must be in learn mode to calibrate the loop gain")
 		return
+	message("Calibrating...")
 	chip = chips[state["selected_board"]]
 	auto_set_pga = state["auto_set_pga"]
 	chip.set_auto_set_pga(0) #Stop it while we scan
@@ -96,6 +104,7 @@ def calibrate_coarse_fine_ratio():
 	if(state["mode"]!=0):
 		error("You must be in learn mode to calibrate the broad to fine ratio")
 		return
+	message("Calibrating...")
 	chip = chips[state["selected_board"]]
 	auto_set_pga = state["auto_set_pga"]
 	chip.set_auto_set_pga(0) #Stop it while we scan
@@ -140,6 +149,7 @@ def calibrate_coarse_fine_ratio():
 
 @eel.expose
 def measure_response_function():
+	message("Measuring...")
 	if(state["mode"]!=0):
 		error("You must be in learn mode to measure the response function.")
 		return
@@ -215,6 +225,8 @@ def error(txt):
 	eel.renderUI(state)
 def warning(txt):
 	eel.warning(txt)
+def message(txt):
+	eel.message(txt)
 
 @eel.expose
 def set_selected_board(n):
@@ -228,8 +240,8 @@ def set_pi_freq(freq):
 	if(freq>100):
 		error("The communication cannot be this fast. High values are likely to disturb the board.")
 		return
-	if(freq<0.2):
-		error("Frequency must be at least 0.2Hz.")
+	if(freq<0.01):
+		error("Frequency must be at least 0.01Hz.")
 		return
 	if(freq>10):
 		warning("High values are likely to disturb the board.")

+ 2 - 2
pi/web/main.css

@@ -1,12 +1,12 @@
 body{
 	margin:0px;
+    font-family: sans-serif;
+    font-size: 12px;
 }
 #app{
 	background: whitesmoke;
 	width: 705px;
 	height: 715px;
-	font-family: sans-serif;
-	font-size: 12px;
 }
 .spacing {
     height: 14px;

+ 10 - 1
pi/web/main.html

@@ -6,6 +6,8 @@
 	<script type="text/javascript" src="toastify.js"></script>
 	<link rel="stylesheet" type="text/css" href="toastify.css">
 	<script type="text/javascript" src="main.js"></script>
+	<script type="text/javascript" src="popper.min.js"></script>
+	<script type="text/javascript" src="tippy.min.js"></script>
 	<link rel="stylesheet" type="text/css" href="main.css">
 	<title> Stabilization Board software </title>
 </head>
@@ -48,6 +50,8 @@
 						</select>
 						<span class="spacing">&nbsp</span>
 						<input type="checkbox" id="waveformGraphAutoupdate" checked> Autoupdate
+						<span class="spacing">&nbsp</span>
+						<input type="button" id="waveformGraphClear" value="Clear">
 					</div>
 					<div class="row" style="margin-left: 10px; font-style:italic">
 						<span id="waveformGraphText"></span>
@@ -70,9 +74,12 @@
 							<option value="10">Fine output</option>
 						</select>
 						Y: <select id="longGraphY">
+							<option value="0">Wf. number</option>
+							<option value="1">Time / min</option>
+							<option disabled>_________</option>
 							<option value="2">Signal</option>
 							<option value="3">Gnd</option>
-							<option value="4">Signal - Gnd</option>
+							<option selected value="4">Signal - Gnd</option>
 							<option value="5">Signal Std</option>
 							<option value="6">Gnd Std</option>
 							<option value="7">Mode</option>
@@ -82,6 +89,8 @@
 						</select>
 						<span class="spacing">&nbsp</span>
 						<input type="checkbox" id="longGraphAutoupdate" checked> Autoupdate
+						<span class="spacing">&nbsp</span>
+						<input type="button" id="longGraphClear" value="Clear">
 					</div>
 					<div id="longGraph">
 					</div>

+ 41 - 0
pi/web/main.js

@@ -1,6 +1,7 @@
 eel.expose(renderUI);
 eel.expose(error)
 eel.expose(warning)
+eel.expose(message)
 
 // Helper functions
 
@@ -97,6 +98,36 @@ function onload(){ //Bind events
 	document.getElementById("longGraphY").addEventListener("change", function(){
 		loadLongGraph()
 	})
+	document.querySelector('#waveformGraphClear').addEventListener("click", function(event){
+		eel.clean_old_files("data/waveforms/", 0)
+	})
+	document.querySelector('#longGraphClear').addEventListener("click", function(event){
+		eel.clean_long_term()
+	})
+
+	// Information for simple usage
+	tippy('#boxAdress', {delay: 3000, content: "The i2c adress used for communication with the board. This is automatically obtained.",})
+	tippy('#outOfLock', {delay: 3000, content: "The box is out of lock when the output of the board is maximum, and thus fluctuations cannot be stabilized anymore.",})
+	tippy('#piFreq', {delay: 3000, content: "Frequency at which the Pi polls the board for new waveforms, typically no more than 10Hz as this can disturb the board.",})
+	tippy('#boardFreq', {delay: 3000, content: "Frequency at which the board is currently measuring waveforms (untested).",})
+	tippy('#remoteTrigg', {delay: 3000, content: "If true, the board will continously trigger, ignoring the trigger input. For normal operation set to false.",})
+	tippy('#enabGnd', {delay: 3000, content: "If true (recommended), the board stabilizes signal-gnd, otherwise it stabilizes signal",})
+	tippy('#Vlearn', {delay: 3000, content: "The output voltage (0-4095) when the box is in learn mode. This can be used to select an appropiate input power. Small values will unnecessarily suppress the signal and large values (>3500, see response function) may result in out_of_lock due to the limited range.",})
+	tippy('#start', {delay: 3000, content: "Point # where the signal starts being measured. Sampling frequency ~1MHz.",})
+	tippy('#stop', {delay: 3000, content: "Point # where the signal stop being measured. Sampling frequency ~1MHz.",})
+	tippy('#startGnd', {delay: 3000, content: "Point # where the ground starts being measured. Sampling frequency ~1MHz.",})
+	tippy('#stopGnd', {delay: 3000, content: "Point # where the ground stops being measured. Sampling frequency ~1MHz.",})
+	tippy('#N', {delay: 3000, content: "Number of waveforms (typ. 1) to sample in each stabilization cycle.",})
+	tippy('#wfLen', {delay: 3000, content: "Number of points to sample (1-255)",})
+	tippy('#stepMax', {delay: 3000, content: "Maximum step allowed in one stabilization cycle (typ. 200) . Small values may lead to slow response to sharp fluctuations.",})
+	tippy('#Gain', {delay: 3000, content: "At every step Vout += (Vmeasured-Vset)*Gain",})
+	tippy('#calibrateGain', {delay: 3000, content: "Automatically select a loop gain based on the response function of the system.",})
+	tippy('#autoSetPga', {delay: 3000, content: "When True, the board changes the input gain and offset so that the signal is in an appropiate range (not clipped and going >2000). Set to False to select it manually.",})
+	tippy('#inputGain', {delay: 3000, content: "Allowed values: [1, 2, 4, 8, 16, 32, 64, 128]",})
+	tippy('#offset', {delay: 3000, content: "Input offset (0-4096). 2000 corresponds to no offset.",})
+	tippy('#coarseFineRatio', {delay: 3000, content: "Ratio of the precision in the fine and broad outputs. Typ. 20 from circuit design.",})
+	tippy('#calibrateCoarseFineRatio', {delay: 3000, content: "Calibrate the ratio by measuring the response functions of the broad and fine outputs.",})
+	tippy('#measureResponseFunction', {delay: 3000, content: "Measure the photodiode signal as a funtion of the output voltage.",})
 
 	setTimeout(loop, 100)
 
@@ -340,4 +371,14 @@ function warning(txt){
 	  close: true,
 	  backgroundColor: "#e36d25",
 	  duration: 3000,}).showToast()
+}
+
+function message(txt){
+	Toastify({
+	  text: txt,
+	  gravity: 'bottom',
+	  position: 'left',
+	  close: true,
+	  backgroundColor: "white",
+	  duration: 3000,}).showToast()
 }

Filskillnaden har hållts tillbaka eftersom den är för stor
+ 5 - 0
pi/web/popper.min.js


Filskillnaden har hållts tillbaka eftersom den är för stor
+ 2 - 0
pi/web/tippy.min.js