diff --git a/FastComtecMCS8A/MCS8A_spcm.conf b/FastComtecMCS8A/MCS8A_spcm.conf new file mode 100644 index 0000000000000000000000000000000000000000..e8b5809f64a5773ca57727a19327020def2948ef --- /dev/null +++ b/FastComtecMCS8A/MCS8A_spcm.conf @@ -0,0 +1,74 @@ +[Settings] +data_dir = C:\\Users\\steph\\labscript-suite\\userlib\\user_devices\\FastComtecMCS8A\\data +dll_path = C:\\Windows\\System32\\DMCS8.dll +batch_file = C:\\Users\\steph\\labscript-suite\\userlib\\user_devices\\FastComtecMCS8A\\dummy.bat +configuration_file = C:\Users\steph\stephan\spcm_fastcomtec\MCS8_1.SET + +[MCS8A] +range=4096 +periods=2 +sweepmode=22fe2080 +fstchan=0 +holdafter=0 +streamstatus=3 +calreg0=0 +calreg1=0 +calreg2=0 +calreg3=0 +swpreset=20000000 +prena=4 +syncout=1 +cycles=18 +sequences=1 +tagbits=16 +vdac0=92c +vdac1=92c +vdac2=92c +vdac3=92c +vdac4=92c +vdac5=92c +vdac6=92c +vdac7=92c +timepreset=20.000 +digio=0 +digval=0 +autoinc=0 +savedata=0 +mpafmt=asc +sephead=1 +fmt=csv +smoothpts=5 +wndwidth=163 +wndheight=286 +sysdef=0 + +[CHN1] +range=4096 +active=1 +bitshift=0 +cftfak=2580100 +evpreset=10 +roimin=0 +roimax=4096 +caloff=0.000000 +calfact=0.400000 +calfact2=0 +calfact3=0 +calunit=nsec +caluse=1 + +[CHN2] +range=4096 +active=0 +bitshift=0 +cftfak=2580100 +evpreset=10 +roimin=0 +roimax=4096 +caloff=0.000000 +calfact=0.400000 +calfact2=0 +calfact3=0 +calunit=nsec +caluse=1 + diff --git a/FastComtecMCS8A/MCS8_test_measurement.SET b/FastComtecMCS8A/MCS8_test_measurement.SET new file mode 100644 index 0000000000000000000000000000000000000000..9ee1a3435a9133e2759debbd8cdbdb5e1eb443f4 --- /dev/null +++ b/FastComtecMCS8A/MCS8_test_measurement.SET @@ -0,0 +1,65 @@ +[MCS8A A] 208 FW 3.104 SV 1.243 +range=4096 +periods=2 +sweepmode=22fe2080 +fstchan=0 +holdafter=0 +streamstatus=3 +calreg0=0 +calreg1=0 +calreg2=0 +calreg3=0 +swpreset=2000000 +prena=4 +syncout=1 +cycles=18 +sequences=1 +tagbits=16 +vdac0=92c +vdac1=92c +vdac2=92c +vdac3=92c +vdac4=92c +vdac5=92c +vdac6=92c +vdac7=92c +timepreset=20.000 +digio=0 +digval=0 +autoinc=0 +savedata=0 +mpafmt=csv +sephead=1 +fmt=csv +smoothpts=5 +wndwidth=163 +wndheight=286 +sysdef=0 +[CHN1] +range=4096 +active=1 +bitshift=0 +cftfak=2580100 +evpreset=10 +roimin=0 +roimax=4096 +caloff=0.000000 +calfact=0.400000 +calfact2=0 +calfact3=0 +calunit=nsec +caluse=1 +[CHN2] +range=4096 +active=0 +bitshift=0 +cftfak=2580100 +evpreset=10 +roimin=0 +roimax=4096 +caloff=0.000000 +calfact=0.400000 +calfact2=0 +calfact3=0 +calunit=nsec +caluse=1 diff --git a/FastComtecMCS8A/__init__.py b/FastComtecMCS8A/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/FastComtecMCS8A/blacs_tabs.py b/FastComtecMCS8A/blacs_tabs.py new file mode 100644 index 0000000000000000000000000000000000000000..390ac54db7514269f77f36af30194000cbf5bb8a --- /dev/null +++ b/FastComtecMCS8A/blacs_tabs.py @@ -0,0 +1,17 @@ +from blacs.device_base_class import DeviceTab + +class MCS8ATab(DeviceTab): + + def initialise_workers(self): + self.event_queue.logging_enabled =True + + self.create_worker( + 'main_worker', + 'user_devices.FastComtecMCS8A.blacs_workers.MCS8AWorker', + {}, + ) + self.primary_worker = 'main_worker' + + def initialise_GUI(self): + widgets,_,_ = self.auto_create_widgets() + \ No newline at end of file diff --git a/FastComtecMCS8A/blacs_workers.py b/FastComtecMCS8A/blacs_workers.py new file mode 100644 index 0000000000000000000000000000000000000000..d0a43f305c233159586f1f4c367620bbcc40387c --- /dev/null +++ b/FastComtecMCS8A/blacs_workers.py @@ -0,0 +1,75 @@ +##################################################################### +# # +# /user_devices/FastComtecMCS8A/blacs_workers.py # +# # +# Jan 2023, Stephan Roschinski # +# # +# # +##################################################################### +from ctypes import * +from . import spcm_config_start +import subprocess +import time +from . import mcs8a_structures +from blacs.tab_base_classes import Worker + +class MCS8AWorker(Worker): + + def init(self, h5_file): + self.config = spcm_config_start.setup + self.batch_file = self.config.get_config_key('Settings', 'batch_file') + self.process = subprocess.Popen(self.batch_file) + self.h5file = h5_file # run batch file + # Do the rest + self.dll_path = self.config.get_config_key('Settings', 'dll_path') + self.dll=WinDLL(self.dll_path) #put DLL path into the conf file + print('init completed') + self.h5file = h5_file + pass + + def transition_to_buffered(self, device_name, h5_file, initial_values, fresh): + self.h5file = h5_file + return {} + + def transition_to_manual(self): + + + print('tranistion to manual') + + return {} + + def program_manual(self, values): + return {} + + def check_remote_values(self): + return True + + def abort_buffered(self): + return self.transition_to_manual() + + def abort_transition_to_buffered(self): + return True + + + + #these methods need to be implemented differently + def get_status(self): + status = ACQSTATUS() + self.dll.GetStatusData(byref(status),0) # Get status stored in the DLL + return status + + def set_settings(self): + conf_file = self.config.get_config_key('Settings', 'configuration_file') + print(conf_file) + self.dll.RunCmd(0,c_char_p(bytes('loadcnf ' + conf_file, 'utf-8'))) + + def start_measurement(self): + self.dll.RunCmd(0,c_char_p(bytes('start', 'utf-8'))) + + def stop_measurement(self): + self.dll.RunCmd(0,c_char_p(bytes('halt', 'utf-8'))) + + def save_data(self, filename): + data_dir = self.config.get_config_key('Settings', 'data_dir') + self.dll.RunCmd(0,c_char_p(bytes('mpaname=' + data_dir+filename, 'utf-8'))) + self.dll.RunCmd(0,c_char_p(bytes('savempa', 'utf-8'))) \ No newline at end of file diff --git a/FastComtecMCS8A/dummy.bat b/FastComtecMCS8A/dummy.bat new file mode 100644 index 0000000000000000000000000000000000000000..52d9c16d2c744f5c29fefc906e8f3bd51471c931 --- /dev/null +++ b/FastComtecMCS8A/dummy.bat @@ -0,0 +1,2 @@ +cd C:\mcs8x64 +mcs8.exe diff --git a/FastComtecMCS8A/labscript_devices.py b/FastComtecMCS8A/labscript_devices.py new file mode 100644 index 0000000000000000000000000000000000000000..0fd3603ed8fddf1756fd468fe3baf7ce0e4935c8 --- /dev/null +++ b/FastComtecMCS8A/labscript_devices.py @@ -0,0 +1,33 @@ +##################################################################### +# # +# /user_devices/FastComtecMCS8A/labscript_devices.py # +# # +# Jan 2023, Stephan Roschinski # +# # +# # +##################################################################### +from labscript import Device, TriggerableDevice, config +import subprocess +from ctypes import * +import numpy as np + +class MCS8A(TriggerableDevice): + description = 'MCS8A' + + def __init__(self, name, parent_device, connection, batch_file, set_file, dll_path, data_dir, **kwargs): + super().__init__(name, parent_device, connection, **kwargs) + self.BLACS_connection = "SPCM" + self.batch_file = batch_file + self.set_file = set_file + self.dll_path = dll_path + self.data_dir = data_dir + + def generate_code(self, hdf5_file): + group = hdf5_file.create_group(f"devices/{self.name}") + dtypes = [("batch_file",'|S100'), ("SET_file", '|S100'), ("DLL_path", '|S100'), ("data_dir", '|S100')] + settings = np.rec.fromarrays([self.batch_file, self.set_file, self.dll_path, self.data_dir], dtype=dtypes) + group.create_dataset("Settings", data=settings) + return + + + diff --git a/FastComtecMCS8A/mcs8a_structures.py b/FastComtecMCS8A/mcs8a_structures.py new file mode 100644 index 0000000000000000000000000000000000000000..1744076ca17e3a039cf04539cb46cd793c7035e8 --- /dev/null +++ b/FastComtecMCS8A/mcs8a_structures.py @@ -0,0 +1,52 @@ +from ctypes import * + +class ACQSTATUS(Structure): + _fields_ = [("started", c_ulong), #aquisition status + ("maxval", c_ulong), #maxval + ("cnt", c_double*8)] #status: runtime in msec, ofls, + #total sum, roi sum, roi rate,sweeps, + #starts + +class ACQSETTING(Structure): + _fields_ = [("range", c_long), + ("cftfak", c_long), #LOWORD: 256*cft factor(t_after_peak / t_to_peak); HIWORD:max pulse width for CFT + ("roimin", c_long), #lower ROI limit + ("roimax", c_long), #upper limit: roimin<=channel<roimax + ("nregions", c_long), #number of regions + ("caluse", c_long), #bit0: 1 if calibration used, higher bits: formula + ("calpoints", c_long),#number of calibration points + ("param", c_long), #(reserved:) for MAP and POS:LOWORD=x, HIWORD=y + ("offset", c_long), #(reserved:) zoomed MAPS: LOWORD: xoffset, HIWORD, yoffset + ("xdim", c_long), #(reserved:) x resolution of maps + ("bitshift", c_ulong),#LOWORD:Binwidth=2^(bitshift); HIWORD: Threshold for Coinc + ("active", c_long), + ("roipreset", c_double),#ROI preset value + ("dummy1", c_double), + ("dummy2", c_double), + ("dummy3", c_double)] + +class BOARDSETTING(Structure): # This is a structure type describing special MCS6 hardware settings + _fields_ = [("sweepmode", c_long), + ("prena", c_long), + ("cycles", c_long), + ("sequences", c_long), + ("syncout", c_long), + ("digio", c_long), + ("digval", c_long), + ("dac0", c_long),#DAC0 value (START) + ("dac1", c_long),#DAC1 value (STOP 1) + ("dac2", c_long),#DAC2 value (STOP 2) + ("dac3", c_long),#DAC3 value (STOP 3) + ("dac4", c_long),#DAC4 value (STOP 4) + ("dac5", c_long),#DAC5 value (STOP 5) + ("fdac", c_int), + ("tagbits", c_int), + ("extclk", c_int),#use external clock + ("maxchan", c_long), + ("serno", c_long), + ("ddruse", c_long), + ("active", c_long),#module in system + ("holdafter", c_double), + ("swpreset", c_double),#sweep preset value + ("fstchan", c_double),#acquisition delay + ("timepreset", c_double)]#time preset diff --git a/FastComtecMCS8A/register_classes.py b/FastComtecMCS8A/register_classes.py new file mode 100644 index 0000000000000000000000000000000000000000..fb9fb737d5b55e2b6258f0cb752a13605065498f --- /dev/null +++ b/FastComtecMCS8A/register_classes.py @@ -0,0 +1,16 @@ +##################################################################### +# # +# /user_devices/DCAMCamera/register_classes.py # +# # +# Jan 2023, Marvin Holten # +# # +# # +##################################################################### + +from labscript_devices import register_classes + +register_classes( + 'MCS8A', + BLACS_tab='user_devices.FastComtecMCS8A.blacs_tabs.MCS8ATab', + runviewer_parser=None, +) diff --git a/FastComtecMCS8A/runviewer_parser.py b/FastComtecMCS8A/runviewer_parser.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/FastComtecMCS8A/spcm_config_start.py b/FastComtecMCS8A/spcm_config_start.py new file mode 100644 index 0000000000000000000000000000000000000000..479dead0dfbd537035ed6ebc2032dce8fc328fd4 --- /dev/null +++ b/FastComtecMCS8A/spcm_config_start.py @@ -0,0 +1,36 @@ +from configobj import ConfigObj + +class config(object): + def __init__(self): + self.config = ConfigObj("C:\\Users\\steph\\labscript-suite\\userlib\\user_devices\\FastComtecMCS8A\\MCS8A_spcm.conf") + self.nr_channels = int(self.get_config_key('CHN1','active'))+int(self.get_config_key('CHN2','active')) + self.card='' + + def reload(self): + self.config.reload() + + def write(self): + self.config.write() + + def set_number_channels(self, arg): + self.nr_channels=arg + + def get_number_channels(self): + return self.nr_channels + + def set_card(self,arg): + self.card=arg + + def get_card(self): + return self.card + + def set_config_key(self, section, key, value): + self.config[section][key]=value + + def get_config_key(self, section, key): + return self.config[section][key] + +# def get_matrix_status(self, section, status): +# return self.config[section][status] + +setup = config()