Commit f678ad48 authored by Martin Drechsler's avatar Martin Drechsler

Small change to make scans works properly. Now they can never escape the scan...

Small change to make scans works properly. Now they can never escape the scan interval and they dont run if the spinbox value is outisde region of scan. Also, they start and stop softly.
parent 7b6acad6
......@@ -94,7 +94,7 @@ class anal_control_signal(QWidget):
def scanEvent(self):
if abs(float(self.scan_step)-float(float(self.scan_sb_start.val)))<1e-6 or abs(float(self.scan_step)-float(self.scan_sb_stop.val))<1e-6:
if float(self.scan_step) < float(self.scan_sb_start.val) or float(self.scan_step) > float(self.scan_sb_stop.val):
self.scan_direction = (-1) * self.scan_direction
self.scan_step = self.scan_step + self.scan_direction
......@@ -106,6 +106,7 @@ class anal_control_signal(QWidget):
self.scanpBar.setValue( 100 * float(self.scan_step-float(self.scan_sb_start.val))/float(self.scan_sb_stop.val-self.scan_sb_start.val) )
self.scanLabelValue.setText("%.2f" % self.scan_step + ' V')
except ZeroDivisionError:
self.doScanAction()
print('Oh dear, you might be trying to scan from 0 to 0. Plase never do that again. ')
def doScanAction(self):
......@@ -114,14 +115,6 @@ class anal_control_signal(QWidget):
#self.scan_direction = -float( (self.scan_sb_stop.val-self.scan_sb_start.val)/self.scan_sb_period.val ) * 5e-3 * 2
#self.scan_step = float(self.scan_sb_start.val)
b = float(self.scan_sb_stop.val)
a = float(self.scan_sb_start.val)
dt = 5.0e-3
T = float(self.scan_sb_period.val)
n = T/(2*dt)
self.scan_direction = -(b-a)/n # this is the size in voltage of each step
self.scan_step = float(self.sb.val) # from here it beggins
if self.ScanTimer.isActive():
......@@ -130,11 +123,21 @@ class anal_control_signal(QWidget):
self.scan_button.setStyleSheet('background-color: None')
self.PbarTimer.stop()
self.AO.set_out(self.sb.val)
self.sb.setValue(self.scan_step)
else:
b = float(self.scan_sb_stop.val)
a = float(self.scan_sb_start.val)
dt = 5.0e-3
T = float(self.scan_sb_period.val)
n = T/(2*dt)
self.scan_direction = -abs(b-a)/n # this is the size in voltage of each step
self.scan_step = float(self.sb.val) # from here it beggins
if self.scan_step > b or self.scan_step < a:
print('scan can not start outside scan range')
print('scan can not start outside scan range and scan start should be lower than scan stop')
else:
self.scan_button.setStyleSheet("background-color: green")
self.ScanTimer.start(dt*1e3)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment