aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--panel.py49
1 files changed, 42 insertions, 7 deletions
diff --git a/panel.py b/panel.py
index d57a645..c1b707a 100644
--- a/panel.py
+++ b/panel.py
@@ -13,14 +13,46 @@ import ue9qol
class Sweeper:
def __init__(self, start, stop, Npoints, SweepTime):
- self.cnt = 0
+ # walk from start to stop with Npoints
+ # cnt = 1 corresponds to start
+ # cnt = Npoints corresponds to stop
+ # variables like relVar are relative to the start of the period
+ self.start = start
+ self.stop = stop
+ self.Npoints = Npoints
+ self.SweepTime = SweepTime
+
+ self.span = self.stop - self.start
+ self.center = (self.stop + self.start)/2
+ self.dPos = self.span/(self.Npoints-1)
+ self.restart()
+
+ def restart(self):
+ self.cnt = 1
+ self.startTime = datetime.now()
+ self.updPos()
def incr(self):
self.cnt += 1
+ self.updPos()
+
+ def updPos(self):
+ self.relCnt = 1 + ((self.cnt-1) % self.Npoints)
+ self.pos = self.start + self.dPos * (self.relCnt - 1)
+ self.relPos = (self.pos-self.start)/self.span
def getCnt(self):
return self.cnt
+ def getRelCnt(self):
+ return self.relCnt
+
+ def getPos(self):
+ return self.pos
+
+ def getRelPos(self):
+ return self.relPos
+
class Experiment:
@@ -33,7 +65,7 @@ class Experiment:
self.guiSetup(root)
self.hardware = {}
self.hardwareSetup()
- self.sweeper = Sweeper(0, 100, 100, 10)
+ self.sweeper = Sweeper(1, 10, 10, 10)
self.root.after(1000, self.hello )
def hardwareSetup(self):
@@ -69,13 +101,16 @@ class Experiment:
def hello(self):
self.root.after(1000, self.hello )
- tic = self.tic
self.sweeper.incr()
tic = self.sweeper.getCnt()
- self.hardware['LabJack'].setOutputCh(0, tic % 6)
- self.data['tic'].append(tic)
- self.data['ch1'].append( self.hardware['LabJack'].getInputCh(1) )
- self.tic = self.tic + 1
+ x = self.sweeper.getPos()
+ # y = self.sweeper.getPos()
+ # self.hardware['LabJack'].setOutputCh(0, x/2)
+ self.hardware['LabJack'].setOutputCh(0, 2)
+ self.data['tic'].append(x)
+ y= self.hardware['LabJack'].getInputCh(1)
+ # self.data['ch1'].append( self.hardware['LabJack'].getInputCh(1) )
+ self.data['ch1'].append( y )
start = datetime.now()
self.ax.cla()
self.ax.plot(self.data['tic'], self.data['ch1'])