def initializeEquipment(self): profilometerParameters.profilometerResourceManager = visa.ResourceManager() profilometerParameters.updateDictionaryParameter(profilometerParameters.kHNSystemControllerProfilometer_routineRunning,False) profilometerParameters.updateDictionaryParameter(profilometerParameters.kHNSystemControllerProfilometer_routineStart,False) self.Agilent34461a = profilometerAgilent34461a.agilent34461aClass() self.substrateStages = profilometerXYZStages.XYZStages() self.substrateStages.XYZStagesInitialize()
def retrieveVariables(self): self.systemControllerProfilometerRoutineStart = profilometerParameters.retrieveDictionaryParameter(profilometerParameters.kHNSystemControllerProfilometer_routineStart) profilometerParameters.updateDictionaryParameter(profilometerParameters.kHNSystemControllerProfilometer_routineStart,False) self.systemControllerProfilometerRoutineRunning = profilometerParameters.retrieveDictionaryParameter(profilometerParameters.kHNSystemControllerProfilometer_routineRunning) self.systemControllerProfilometerRoutineDirection = profilometerParameters.retrieveDictionaryParameter(profilometerParameters.kHNSystemControllerProfilometer_routineDirection) self.systemControllerProfilometerRoutineStepSize = profilometerParameters.retrieveDictionaryParameter(profilometerParameters.kHNSystemControllerProfilometer_routineStepSize) self.systemControllerProfilometerRoutineTravelDirection = profilometerParameters.retrieveDictionaryParameter(profilometerParameters.kHNSystemControllerProfilometer_routineTravelDistance)
def calibrateProfilometer(self): # Temporary Usage: Get current location [stageX, stageY, stageZ] = self.substrateStages.retrieveStagePostion() print('Stage Position (x,y,z): ({},{},{})'.format(stageX,stageY,stageZ)) # Sets the routine to running so we can get readings from the mutlimeter profilometerParameters.updateDictionaryParameter(profilometerParameters.kHNSystemControllerProfilometer_routineRunning,True) # Checks the omron sensor for its current reading _calibrationValue1 = self.Agilent34461a.retrieveVoltage() # Moves the satges in the -Z direction by 0.5 mm self.substrateStages.moveStageRelative(self.substrateStages.positioner_Z,[-0.5]) # Checks the omron sensor for its new reading _calibrationValue2 = self.Agilent34461a.retrieveVoltage() # Finds the correction ratio based on the known move distance and the read move distance _correctionRatio = -0.5/(_calibrationValue2 - _calibrationValue1) profilometerParameters.updateDictionaryParameter(profilometerParameters.kHNSystemControllerProfilometer_calibrationRatio,(_correctionRatio)) # Updates the routine to no longer be running profilometerParameters.updateDictionaryParameter(profilometerParameters.kHNSystemControllerProfilometer_routineRunning,False) # Moves the stages back up 0.5 mm to their original postion self.substrateStages.moveStageRelative(self.substrateStages.positioner_Z,[0.5])
def __init__(self): threading.Thread.__init__(self) # Dictionary of multipliers based on the movement direction. This flips the sign of the number the user enters # when they click a negative manual movement button. self._directionDictionary = { '+X': 1, '-X': -1, '+Y': 1, '-Y': -1, '+Z': 1, '-Z': -1, } # TEMP VARIABLE INITIALIZATION # profilometerParameters.updateDictionaryParameter(profilometerParameters.kHNSystemControllerProfilometer_routineDirection,'X') profilometerParameters.updateDictionaryParameter(profilometerParameters.kHNSystemControllerProfilometer_routineStepSize,'0') profilometerParameters.updateDictionaryParameter(profilometerParameters.kHNSystemControllerProfilometer_routineTravelDistance,'0')
def initializeData(self): # Sets the profilometer correction ratio to 1 profilometerParameters.updateDictionaryParameter(profilometerParameters.kHNSystemControllerProfilometer_calibrationRatio,1)
def profilometerRoutine(self, direction, travelDistance, stepSize): # Converts the travel distance and step size to a float travelDistance = float(travelDistance) stepSize = float(stepSize) # Changes profilometer start to false so that the routine only runs once profilometerParameters.updateDictionaryParameter(profilometerParameters.kHNSystemControllerProfilometer_routineStart,False) # Clears the data from any previous runs profilometerParameters.clearDataStorageInstances() # Creates an instance of the stages _stagesInstance = profilometerXYZStages.XYZStages() _stagesInstance.XYZStagesInitialize() # If statement that checks to make sure a valid direction has been entered and changes direction to # a value recognized by the stages class if direction == 'X': _movementDirection = _stagesInstance.positioner_X elif direction == 'Y': _movementDirection = _stagesInstance.positioner_Y else: print('Please select a direction') return # If statement that checks the sign of the travel distance if travelDistance < 0: stepSize = -stepSize i = 0 # While loop that starts at 0 and moves the stage by step size until travel distance has been reached # Flow is: Scan > Move > Iterate - This allows us to scan the first and last points while i <= abs(float(travelDistance)): # Checks to see if the user clicked the stop button mid print and stops the print if so if not profilometerParameters.retrieveDictionaryParameter(profilometerParameters.kHNSystemControllerProfilometer_routineRunning): _stagesInstance.moveStageAbort() print('MID PRINTING STOP') break # Gets a data reading from the multimeter multimeterData = self.Agilent34461a.retrieveVoltage() # Gets the current x,y,z stage locations [x,y,z] = _stagesInstance.retrieveStagePostion() # Creates an instance of the data class with the current data profilometerDataClass.profilometerData(x,y,z,multimeterData) # Acquires the data thread lock profilometerParameters.dataThreadLock.acquire() # print('dataThreadLock acquired (SC)') # Updates the new data point to true profilometerParameters.updateDictionaryParameter(profilometerParameters.kHNSystemControllerProfilometer_newDataPoint,True) # Releases the data thread lock profilometerParameters.dataThreadLock.release() # print('dataThreadLock released (SC)') # Moves the stages by creating a stage thread and then running that thread for the movement amount and direction _stagesInstanceThread = threading.Thread(target=_stagesInstance.moveStageRelative,args=(_movementDirection,[stepSize/1000])) _stagesInstanceThread.start() # For loop that runs during the stage movement and aborts the movement if the user clicks the stop button motionStatus = _stagesInstance.checkMotionStatus() while (motionStatus != 0): motionStatus = _stagesInstance.checkMotionStatus() # Checks to see if the user has clicked the stop button and aborts the stage movement if they have if not profilometerParameters.retrieveDictionaryParameter(profilometerParameters.kHNSystemControllerProfilometer_routineRunning): _stagesInstance.moveStageAbort() print('MID PRINTING STOP') break # Increases i by the step size for the next iteration i = i + abs(stepSize)/1000 print('Profilometer Routine Complete')
def buttonClickedStartStop(self): ## If statement that cycles through the start/stop functionality of the button # First if statement that checks for routine running = True and then stops the run if profilometerParameters.retrieveDictionaryParameter(profilometerParameters.kHNSystemControllerProfilometer_routineRunning) == True: # Update the profilometer routine running to False when start/stop button clicked profilometerParameters.updateDictionaryParameter(profilometerParameters.kHNSystemControllerProfilometer_routineRunning,False) self.updateMovementButtonsState(True) # Updates the start/stop button to green and start self.buttonStartStop.setText('Start') self.buttonStartStop.setStyleSheet('background-color: green;border:0px;border-radius:10') print('Profilometer Routine Stopped') # Else if statement that checks for routine running = False and then starts the run elif profilometerParameters.retrieveDictionaryParameter(profilometerParameters.kHNSystemControllerProfilometer_routineRunning) == False: # Updates the profilometer routine running to True when start/stop button clicked profilometerParameters.updateDictionaryParameter(profilometerParameters.kHNSystemControllerProfilometer_routineRunning,True) # Updates the profilometer start flag to True when start/stop button clicked profilometerParameters.updateDictionaryParameter(profilometerParameters.kHNSystemControllerProfilometer_routineStart,True) # Updates the profilometer routine direction based on the radio button selected profilometerParameters.updateDictionaryParameter(profilometerParameters.kHNSystemControllerProfilometer_routineDirection,self.retrieveProfilometerRoutineDirection()) # Updates the profilometer routine step size based on the value entered into the entry box profilometerParameters.updateDictionaryParameter(profilometerParameters.kHNSystemControllerProfilometer_routineStepSize,self.entryBoxStepSize.text()) # Updates the profilometer routine travel distance based on the value entered into the entry box profilometerParameters.updateDictionaryParameter(profilometerParameters.kHNSystemControllerProfilometer_routineTravelDistance,self.entryBoxTravelDistance.text()) self.updateMovementButtonsState(False) # Updates the start/stop button to red and stop self.buttonStartStop.setText('STOP') self.buttonStartStop.setStyleSheet('background-color: red;border:0px;border-radius:10') print('Profilometer Routine Started') ## Routine to test realtime plotting # Runs a while loop that checks to see if the routine is running while profilometerParameters.retrieveDictionaryParameter(profilometerParameters.kHNSystemControllerProfilometer_routineRunning): # Asks the GUI to process any events manually QtGui.QApplication.processEvents() try: # If statement that checks to see if a new data point has been added if profilometerParameters.retrieveDictionaryParameter(profilometerParameters.kHNSystemControllerProfilometer_newDataPoint): # Calls the plot data routine self.buttonClickedPlotData() # print('plot') # Acquires the data thread lock profilometerParameters.dataThreadLock.acquire() # print('dataThreadLock acquired (UI)') # Sets the new data point to false profilometerParameters.updateDictionaryParameter(profilometerParameters.kHNSystemControllerProfilometer_newDataPoint,False) # Releases the data thread lock profilometerParameters.dataThreadLock.release() # print('dataThreadLock released (UI)') except: pass