TNMR updates: workaround for the hardware module error. Added more dashboard support. Added class definition auto-generated by pycom (NTNMR.py)

This commit is contained in:
2025-06-30 13:55:21 +02:00
parent 388748c995
commit 10acd4a188
5 changed files with 1687 additions and 17 deletions

View File

@@ -93,6 +93,7 @@ class ProgrammedSequence(fc.Readable):
compiled_parameters = {} # so that we can store the values of parameters only when compiling, effectively giving us an instance of each parameter loaded into TNMR, as well as "targets" (those above)
inited = False
approx_sequence_length = 0
### SETUP
def tnmr(self):
@@ -207,11 +208,14 @@ class ProgrammedSequence(fc.Readable):
# first, create the sequence
seq = seq_gen.get_initial_block()
i = 0
self.approx_sequence_length = 0
for s in self.sequence_data:
seq = seq_gen.combine_blocks(seq, seq_gen.get_single_pulse_block(f'pulse_{i}', str(s['pulse_width']) + 'u',
str(s['pulse_height']),
str(s['delay_time']) + 'u',
str(s['phase_cycle'])))
self.approx_sequence_length += float(s['delay_time'])*1e-6
self.approx_sequence_length += float(s['pulse_width'])*1e-6
i += 1
seq = seq_gen.combine_blocks(seq, seq_gen.get_final_block(str(self.ringdown_time) + 'u',
str(self.pre_acquisition_time) + 'u',
@@ -219,10 +223,13 @@ class ProgrammedSequence(fc.Readable):
str(self.post_acquisition_time) + 'm',
str(self.acq_phase_cycle)))
self.approx_sequence_length += float(self.acquisition_time)*1e-6
self.approx_sequence_length += float(self.post_acquisition_time)*1e-6
# then, save the thing
filepath = os.getcwd()
filename = self.title + f'_{time.time()}'
filename = filepath + '/' + filename.replace('.','')
filename = filepath + '/sequences/' + filename.replace('.','')
seq_gen.save_sequence(filename, seq)
seq_gen.save_sequence_cfg(filename, seq)
@@ -240,12 +247,10 @@ class ProgrammedSequence(fc.Readable):
# then, load the thing into TNMR
self.tnmr().load_sequence(filename)
time.sleep(1.0) # hardware module issue???
# load some parameters back to TNMR
for key, val in dashboard_params.items():
self.tnmr().set_nmrparameter(key, val)
time.sleep(0.5)
# finally, let ourselves know we're ready
self.status = ('PREPARED', 'compiled')
@@ -256,11 +261,11 @@ class ProgrammedSequence(fc.Readable):
'''Tells TNMR to acquire data. Only call after __compile_sequence().'''
if(self.status[0] != 'BUSY'):
self.status = ('BUSY', 'acquiring')
self.tnmr().ZeroGo(lock=True, interval=0.5)
self.tnmr().ZeroGo(lock=True, interval=0.5, check_time=max(self.approx_sequence_length*5, 5))
newvals = {}
newvals['reals'] = self.tnmr().get_data()[0]
newvals['imags'] = self.tnmr().get_data()[1]
newvals['t'] = [ self.compiled_parameters['acquisition_time'] * i/self.compiled_parameters['num_scans'] for i in range(0, self.compiled_parameters['num_scans']) ]
newvals['t'] = [ self.compiled_parameters['acquisition_time'] * i/1024 for i in range(0, 1024) ]
self.value = newvals
self.status = ('PREPARED', 'compiled')
@@ -272,7 +277,7 @@ class ProgrammedSequence(fc.Readable):
thread: bool, determines if this should open a child thread and detach the process
'''
self.__compile_sequence()
time.sleep(0.5)
time.sleep(1.0)
self.__zero_go()