*** Wartungsfenster jeden ersten Mittwoch vormittag im Monat ***

Skip to content
Snippets Groups Projects
Commit 10b31bd8 authored by Roschinski, Stephan's avatar Roschinski, Stephan Committed by Leolab Cavity CAD PC
Browse files

added MCS8A box v1

parent dc9d9528
No related branches found
No related tags found
1 merge request!5Added Fastcomtec MCS8A timetagger for measurements with SPCM
[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
[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
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
#####################################################################
# #
# /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
cd C:\mcs8x64
mcs8.exe
#####################################################################
# #
# /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
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
#####################################################################
# #
# /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,
)
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()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment