Skip to content

Commit

Permalink
version 0.5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
ricardoedgarsilva committed Jun 14, 2023
1 parent 0d3fc59 commit d141d54
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 34 deletions.
48 changes: 29 additions & 19 deletions PyCharMem.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
# Global Variables
PROGRAM_INFO = {
'name': 'PyCharMem',
'version': '0.0.3',
'version': '0.0.5',
'author': 'Ricardo E. Silva',
'email': '[email protected]',
'description': 'PyCharMem is a Python program that allows you to measure the charge memory of a device.',
Expand Down Expand Up @@ -221,14 +221,14 @@ def exit(logger, inst):
logger.info('Exiting program...')
inst.close(logger)
logger.info('Instrument closed')
time.sleep(2)



# Important Classes

class FileSave:
def __init__(self, logger, sample, device):
self.path = os.path.join(get_path(), "data", sample, device)
def __init__(self, logger, path, sample, device):
self.path = os.path.join(path, sample, device)
mkdir(logger, self.path)

self.file_name = get_filename(self.path, sample, device)
Expand Down Expand Up @@ -269,8 +269,8 @@ def save_result(self, logger, result):


class Logbook:
def __init__(self, logger, sample):
self.path = os.path.join(get_path(), "data", sample)
def __init__(self, logger, path, sample):
self.path = os.path.join(path, sample)
mkdir(logger, self.path)

self.file_path = os.path.join(self.path, 'logbook.xlsx')
Expand Down Expand Up @@ -307,13 +307,13 @@ class MeasurementThread(QThread):
clear_plots = pyqtSignal(list, list)
close_window = pyqtSignal()

def __init__(self, logger, inst, meas, config):
def __init__(self, logger, inst, meas, config, filesave):
super().__init__()
self.logger = logger
self.inst = inst
self.meas = meas
self.config = config
self.filesave = FileSave(logger, config.get('sample').get('name'), config.get('sample').get('device'))
self.filesave = filesave
self.filesave.save_config(logger, config, meas.name)
self.filesave.save_headers(logger, self.meas.headers)
self.n_cycles = config.get(meas.name).get('n_cycles')
Expand All @@ -337,21 +337,16 @@ def run(self):
progress.update(value_task, advance=-self.n_vals, description=f"[purple]Value 0/{self.n_vals}")
progress.update(cycle_task, advance=1, description=f"[blue]Cycle {cycle}/{self.n_cycles}")
self.inst.set_output_state(self.logger,'OFF')
self.logger.info('Measurement finished! Please close the window to continue.')


logbook = Logbook(self.logger, self.config.get('sample').get('name'))
self.logger.info('Measurement finished! Please enter a comment for the logbook')
comment = ask_for_comment(self.logger)
logbook.save_log(self.logger, get_datetime(), self.filesave.file_name, comment)
self.close_window.emit()
self.logger.info('Logbook saved!')


class MeasurementWindow(QMainWindow):
def __init__(self, logger, inst, meas, config):
def __init__(self, logger, inst, meas, config, filesave):
super().__init__()
self.initUI(meas)
self.measure = MeasurementThread(logger, inst, meas, config)
self.measure = MeasurementThread(logger, inst, meas, config, filesave)
self.measure.update_data.connect(self.update_data)
self.measure.clear_plots.connect(self.clear_plots)
self.measure.close_window.connect(self.close)
Expand Down Expand Up @@ -421,11 +416,11 @@ def close_window(self):

# Main Functions ------------------------------------------------------------------

def start_gui(logger, inst, meas, config):
def start_gui(logger, inst, meas, config, filesave):
app = QApplication(sys.argv)
app.setStyle(QStyleFactory.create("Fusion"))
app.setStyleSheet("QMainWindow::title {background-color: #333333;}")
window = MeasurementWindow(logger, inst, meas, config)
window = MeasurementWindow(logger, inst, meas, config, filesave)
window.show()
app.exec()

Expand Down Expand Up @@ -472,9 +467,24 @@ def main():
meas_class = import_module(logger=logger, type='measurement', measurement_type=option2)
meas = meas_class(logger, config, inst)

filesave = FileSave(logger, config.get('sample').get('path'), config.get('sample').get('name'), config.get('sample').get('device'))

check_missing_params(logger, meas.params[meas.name], meas.nparams)
logger.info('All parameters present')
start_gui(logger, inst, meas, config)
start_gui(logger, inst, meas, config, filesave)

path = config.get('sample').get('path')
sample_name = config.get('sample').get('name')
sample_device = config.get('sample').get('device')

logbook = Logbook(logger,path, sample_name)

logger.info('Please enter a comment for the logbook')
comment = ask_for_comment(logger)
logbook.save_log(logger, get_datetime(), filesave.file_name, comment)
logger.info('Logbook saved!')


option3 = repeat_measurement(logger, console)
if option3: continue
else:
Expand Down
19 changes: 10 additions & 9 deletions config.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# Sample configuration file for the
sample:
name: "MemQuD_It_7x7" # Name of the sample ex: "MRG6N1"
device: "D1" # location of the device ex: "x1y6"
name: "MemQuD_CPI_Q1S11" # Name of the sample ex: "MRG6N1"
device: "55R2" # location of the device ex: "x1y6"
path: "C:\\Users\\ricar\\OneDrive - Universidade de Lisboa\\Desktop\\Data" # path to save the data ex: "C:\\Users\\Admin\\Desktop\\Data"

# Load Instrument
instrument:
Expand All @@ -11,16 +12,16 @@ instrument:
pulsedIV:
cycle: "+-" # cycle of the voltage (ex: "+-","-+", "+" or "-")
n_cycles: 1 # number of cycles
v+: 3.0 # maximum voltage value of positive cycle
v-: -3.0 # minimum voltage value of negative cycle
v_step: 1.0 # voltage step
v_read: 0.05 # voltage step for the read
ccplc+: 0.1 # current compliance for positive cycle
ccplc-: 0.1 # current compliance for negative cycle
v+: 5.0 # maximum voltage value of positive cycle
v-: -5.0 # minimum voltage value of negative cycle
v_step: 0.3 # voltage step
v_read: 0.3 # voltage step for the read
ccplc+: 0.000001 # current compliance for positive cycle
ccplc-: 0.000001 # current compliance for negative cycle
t_write: 0.00001 # time between each voltage step
t_read: 0.00001 # time between each current read
t_wait: 0.00001 # time between each cycle
nplc: 1 #number of power line cycles
nplc: 2 #number of power line cycles

pulsedVI:
cycle: "+-" # cycle of the voltage (ex: "+-","-+", "+" or "-")
Expand Down
Binary file not shown.
Binary file not shown.
Binary file removed instruments/__pycache__/sim.cpython-310.pyc
Binary file not shown.
Binary file removed measurements/__pycache__/pulsedIV.cpython-310.pyc
Binary file not shown.
12 changes: 6 additions & 6 deletions measurements/pulsedIV.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ def create_list(logger, cycle, max_val, min_val, step):

try:
match cycle:
case '+': return list_positive
case '-': return list_negative
case '+-': return np.concatenate((list_positive, list_negative))
case '-+': return np.concatenate((list_negative, list_positive))
case '+': return np.round(list_positive,5)
case '-': return np.round(list_negative,5)
case '+-': return np.round((np.concatenate((list_positive, list_negative))),5)
case '-+': return np.round(np.concatenate((list_negative, list_positive)),5)
except:
logger.critical('Invalid cycle type!')
quit()
Expand Down Expand Up @@ -62,7 +62,7 @@ def initialize_instrument(self, logger, instrument):
instrument.set_sense_func(logger, func='Current')
instrument.set_func_range(logger, func='Current')
instrument.set_func_nplc(logger, func='Current', value=self.params.get(self.name).get('nplc'))
instrument.write(logger, 'INIT:IMM')
#instrument.write(logger, 'INIT:IMM')
logger.debug('Instrument parameters set!')

def measure_val(self, logger, instrument, val):
Expand All @@ -85,7 +85,7 @@ def measure_val(self, logger, instrument, val):
# Read Pulse: End

result = [
result_write[0], # Voltage Write
val, # Voltage Write
result_write[1], # Current Write
result_read[0], # Voltage Read
result_read[1], # Current Read
Expand Down

0 comments on commit d141d54

Please sign in to comment.