Example #1
0
 def MoveTo(self, iChannel, fPos, bTimeOut=True):
     stepPos = round(fPos/self.stepsize)
     if (stepPos >= self.hardMin):
         if (fPos < self.max_travel):
             nik.ZDrive.Position = stepPos
         else:
              nik.ZDrive.Position = round(self.max_travel/self.stepsize)
     else:
         nik.ZDrive.Position = self.hardMin
         
     eventLog.logEvent('Focus Change', 'New z-pos = %f' % stepPos)
Example #2
0
    def Notify(self):
        if self.Tracking and self._IsGuided():
            currPos = self.posFcn()
            if self.EstimateSlope:
                SlopeEst_new = (self.LastPos -
                                currPos) / self.LastStep  #estimate slope

                self.SlopeEst = .5 * self.SlopeEst + 0.5 * SlopeEst_new  #average slope changes
                #print self.SlopeEst

            posErr = currPos - self.TargetPos
            #print posErr
            if self.recDrift:
                self.Errors.append(posErr)
                self.PiezoPoss.append(self.piezo.GetPos(0))
                self.slopeEsts.append(self.SlopeEst)

            eventLog.logEvent('Focus Position',
                              '%f, %f, %f' % (currPos, posErr, self.SlopeEst))

            if abs(posErr) > abs(
                    self.tolerance * self.SlopeEst):  #needs correction
                corr = posErr / self.SlopeEst

                corr = round(0.8 * corr / .05) * .05

                #don't make more than 1um correction in any one step
                corr = min(max(corr, -1), 1)
                print(corr)

                self.LastPos = currPos
                self.piezo.MoveTo(0, self.piezo.GetPos(0) + corr)

                self.LastStep = corr

                self.cumShift += corr  #increment cumulative shift

                #we've moved a lot - lock obviously broken
                if abs(self.cumShift) > 5:
                    self.Tracking = False  #turn tracking off to stop runnaway
            else:
                self.cumShift = 0  #reset cumulative shift
Example #3
0
    def Notify(self):
        if self.Tracking and self._IsGuided():
            currPos = self.posFcn()
            if self.EstimateSlope:
                SlopeEst_new = (self.LastPos - currPos)/self.LastStep #estimate slope
            
                self.SlopeEst = .5*self.SlopeEst + 0.5*SlopeEst_new #average slope changes
                #print self.SlopeEst
            
            posErr = currPos - self.TargetPos
            #print posErr
            if self.recDrift:
                self.Errors.append(posErr)
                self.PiezoPoss.append(self.piezo.GetPos(0))
                self.slopeEsts.append(self.SlopeEst)

            eventLog.logEvent('Focus Position', '%f, %f, %f' % (currPos, posErr,self.SlopeEst ))
            
            if abs(posErr) > abs(self.tolerance*self.SlopeEst): #needs correction
                corr = posErr/self.SlopeEst
                
                corr = round(0.8*corr/.05)*.05
                
                #don't make more than 1um correction in any one step
                corr = min(max(corr, -1), 1)
                print(corr)
                
                self.LastPos = currPos
                self.piezo.MoveTo(0,self.piezo.GetPos(0) + corr)
                
                self.LastStep = corr

                self.cumShift += corr #increment cumulative shift

                #we've moved a lot - lock obviously broken
                if abs(self.cumShift) > 5: 
                    self.Tracking = False #turn tracking off to stop runnaway
            else:
                self.cumShift = 0 #reset cumulative shift