• 沒有找到結果。

5.6 Compiling Saved Data

7.1.4 GaussMeterClass.py

# Control Program for Lakeshore 475 DSP Gaussmeter import visa

class GaussMeter():

def __init__(self, address):

self.rm = visa.ResourceManager()

# Depending on instrument GPIB address

# 475 Gaussmeter GPIB address 7?

self.gm = self.rm.open_resource(address)

# self.gm.write("")

# self.gm = self.gm.write("QTST?") print("Gaussmeter Initialized") def test_mode(self):

print(self.gm.query("RDGMODE?"))

# def set_mode(self):

# self.gm.write("1,3,1,1,1") # sets to DC measurement with 5 digits accuracy

,

# self.gm.write("UNIT 3") # sets the units to Oe def measure(self):

# print(self.gm.query("RDGFIELD?")) return float(self.gm.query("RDGFIELD?"))

# properly closes the open resource, if not done then rm.close() will throw an visaIOerror

,

def shutdown(self):

del self.gm

if __name__ == '__main__':

rm = visa.ResourceManager() print(rm.list_resources()) rm.close()

7.1.5 Measurement Scripts

The full list of currently used measurement scripts is available on github. The scripts shown here the ones specifically mentioned in this work.

AHE import os import sys import time import importlib

import matplotlib.animation as animation from GUIBaseClass import GUIBase

from GUIBaseClass import animate_plot

sys.path.append(os.getcwd()) # add path to import dictionary defaults = importlib.import_module('FieldControls',

os.getcwd()) # import dictionary based on the name of the computer

,

mag_settings = getattr(defaults, os.environ.get('USERNAME')) res_settings = getattr(defaults, os.environ.get('USERNAME') + '_RESOURCES')

,

# set Hx field, wait for delay

def fix_param1(index, output, delay, resources, kwargs):

if index == 0:

output / float(kwargs['Hx Conversion'])) # obj, name, value

,

time.sleep(delay)

# set keithley 2400 current, wait for delay def fix_param2(output, delay, resources, kwargs):

resources['keithley_2400'].source_current = output * 10e-3 # set to mA

,→

# set Hz field, wait for delay, measure Hz field, measure voltage, take average return resistance

,

def measure_y(output, delay, resources, fix1_output, fix2_output, kwargs):

,→

setattr(resources['dsp_lockin'], kwargs['Hz Dac'], output / float(kwargs['Hz Conversion'])) time.sleep(delay)

x2 = resources['gaussmeter'].measure() y = 0.0

for i in range(int(kwargs['averages'])):

y += resources['keithley_2000'].voltage

y = (y * 1000 / int(kwargs['averages'])) / fix2_output return float(output), float(y), x2

def main(): # test version of the GUI_base and animation

# test dictionary for settings resource_dict = {

# i.e. AHE Measurement (should be the measurement type)

"gui_title": 'AHE Measurement',

"graph_title": "Resistance (Ohm) vs Hz (Oe)", # Resistance vs. Hx

,

"x_title": "Applied Field (Oe)", # i.e. Applied Field (Oe)

"y_title": "Realtime Resistance (Ohm)", # i.e. Hall Resistance (Ohm)

,

# for gaussmeter readings, leave blank if no gaussmeter used

,→

"x2_title": "Gaussmeter (Oe)",

"fixed_param_1": "Hx Field (Oe)", # i.e. Hx 100 (Oe)

"fixed_param_2": "Current (mA)" # i.e. Current 1.9 (mA) }

loop_commands = {

'fixed_func_1': 'fix_param1', # name of fixed parameter one function

,

'fixed_func_2': 'fix_param2', 'measure_y_func': 'measure_y',

# directory from which the preceeding modules will be imported from

,→

'module_path': os.getcwd(),

# name of the file to get the functions from 'module_name': 'AHE',

'MOKE': False

'Hx Dac': mag_settings['Hx Dac'], 'Hz Dac': mag_settings['Hz Dac'],

'Hx Conversion': mag_settings['Hx Conversion'], 'Hz Conversion': mag_settings['Hz Conversion'], 'Hx Max': mag_settings['Hx Max'],

'Hz Max': mag_settings['Hz Max']

}

"""

Below are the three lines of code that create an instance of the GUIBase, animation function

,

and then start the GUIBase.

"""

measurement_gui = GUIBase(graph_dict, resource_dict, loop_commands,

if __name__ == '__main__':

import matplotlib.animation as animation from GUIBaseClass import GUIBase

from GUIBaseClass import animate_plot

sys.path.append(os.getcwd()) # add path to import dictionary defaults = importlib.import_module('FieldControls',

os.getcwd()) # import dictionary based on the name of the computer

,

mag_settings = getattr(defaults, os.environ.get('USERNAME')) res_settings = getattr(defaults, os.environ.get('USERNAME') + '_RESOURCES')

,

# set Hx field, wait for delay

def fix_param1(index, output, delay, resources, kwargs):

if index == 0:

output / float(kwargs['Hz Conversion'])) time.sleep(delay)

# set keithley 2400 current, wait for delay def fix_param2(output, delay, resources, kwargs):

resources['keithley_2400'].source_current = output * 10e-3 # set to mA

,

# set Hz field, wait for delay, measure Hz field, measure voltage, take average return resistance

,→

def measure_y(output, delay, resources, fix1_output, fix2_output, kwargs):

,

setattr(resources['dsp_lockin'], kwargs['Hx Dac'],

output / float(kwargs['Hx Conversion'])) # obj, name, value

,

time.sleep(delay)

x2 = resources['gaussmeter'].measure() y = 0.0

for i in range(int(kwargs['averages'])):

y += resources['keithley_2000'].voltage

y = (y * 1000 / int(kwargs['averages'])) / fix2_output return float(output), float(y), x2

def main(): # test version of the GUI_base and animation

# test dictionary for settings resource_dict = {

# i.e. AHE Measurement (should be the measurement type)

"gui_title": 'AMR Measurement',

"graph_title": "Resistance (Ohm) vs Hx (Oe)", # Resistance vs. Hx

,

"x_title": "Applied Field (Oe)", # i.e. Applied Field (Oe)

"y_title": "Realtime Resistance (Ohm)", # i.e. Hall Resistance (Ohm)

,

# for gaussmeter readings, leave blank if no gaussmeter used

,

"x2_title": "Gaussmeter (Oe)",

"fixed_param_1": "Hz Field (Oe)", # i.e. Hx 100 (Oe)

"fixed_param_2": "Current (mA)" # i.e. Current 1.9 (mA) }

loop_commands = {

'fixed_func_1': 'fix_param1', # name of fixed parameter one function

,→

'fixed_func_2': 'fix_param2', 'measure_y_func': 'measure_y',

# directory from which the preceeding modules will be imported from

,

'module_path': os.getcwd(),

# name of the file to get the functions from 'module_name': 'AMR',

'fix2_step': 'current step',

'Hx Dac': mag_settings['Hx Dac'], 'Hz Dac': mag_settings['Hz Dac'],

'Hx Conversion': mag_settings['Hx Conversion'], 'Hz Conversion': mag_settings['Hz Conversion'], 'Hx Max': mag_settings['Hx Max'],

'Hz Max': mag_settings['Hz Max']

}

"""

Below are the three lines of code that create an instance of the GUIBase, animation function

,

and then start the GUIBase.

"""

measurement_gui = GUIBase(graph_dict, resource_dict, loop_commands,

measurement_gui.fig, animate_plot, interval=200,

if __name__ == '__main__':

main()

import matplotlib.animation as animation from GUIBaseClass import GUIBase

from GUIBaseClass import animate_plot

sys.path.append(os.getcwd()) # add path to import dictionary defaults = importlib.import_module('FieldControls',

os.getcwd()) # import dictionary based on the name of the computer

,

mag_settings = getattr(defaults, os.environ.get('USERNAME')) res_settings = getattr(defaults, os.environ.get('USERNAME') + '_RESOURCES')

,

def fix_param1(index, output, delay, resources, kwargs):

if index == 0:

output / float(kwargs['Hx Conversion'])) time.sleep(delay)

def fix_param2(output, delay, resources, kwargs):

pass

def measure_y(output, delay, resources, fix1_output, fix2_output, kwargs):

,

x2 = resources['gaussmeter'].measure()

resources['keithley_2400'].source_current = output * 10e-3 # mA time.sleep(fix2_output) # write pulse time

resources['keithley_2400'].source_current = 0 # turn off current

,

time.sleep(float(kwargs['write-read delay'])) resources['keithley_2400'].source_current = float(

kwargs['sensing current']) * 10e-3 # mA time.sleep(float(kwargs['read pulse width'])) y = 0.0

for i in range(int(kwargs['averages'])):

y += resources['keithley_2000'].voltage

y = (y * 1000 / int(kwargs['averages'])) / float(

kwargs['sensing current'])

resources['keithley_2400'].source_current = 0 # turn off current

,→

return output, y, x2

def main():

"graph_title": "Resistance (Ohm) vs. Current (mA)",

"x_title": "Pulse Current (mA)",

"y_title": "Resistance (Ohm)",

"x2_title": "Gaussmeter (Oe)",

"fixed_param_1": "Hx Field (Oe)",

"fixed_param_2": "Pulse Width (s)"

}

loop_commands = {

'fixed_func_1': 'fix_param1', # name of fixed parameter one function

,→

'fixed_func_2': 'fix_param2', 'measure_y_func': 'measure_y',

# directory from which the preceeding modules will be imported from

,

'module_path': os.getcwd(),

# name of the file to get the functions from 'module_name': 'SOT_Current_Switching',

'fix1_start': 'hx start', 'fix1_stop': 'hx stop',

'fix1_step': 'hx step',

'fix2_start': 'pulse width start', 'fix2_stop': 'pulse width stop', 'fix2_step': 'pulse width step', 'x_start': 'current start',

"pulse width start": 0.05,

"pulse width end": 0.05,

"pulse width step": 0,

"sensing current": 0.5,

"write-read delay": 0.1, # delay between write and read

# how long after read current sourced is read voltage measured

,

"read pulse width": 0.05,

"averages": 1 }

lockin_controls = {

"title": "Lockin",

'Hx Dac': mag_settings['Hx Dac'], 'Hz Dac': mag_settings['Hz Dac'],

'Hx Conversion': mag_settings['Hx Conversion'], 'Hz Conversion': mag_settings['Hz Conversion'], 'Hx Max': mag_settings['Hx Max'],

'Hz Max': mag_settings['Hz Max']

}

measurement_gui = GUIBase(graph_dict, resource_dict, loop_commands,

measurement_gui.fig, animate_plot, interval=200,

if __name__ == '__main__':

main()

相關文件