Exemple #1
0
    def setUp(self):
        sys.path = [os.path.dirname(os.getcwd())] + sys.path
        proj_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))

        cocotb_compile_and_run(sim_files=[proj_dir + '/test/mmc3_eth_tb.v'],
                               top_level='tb',
                               include_dirs=(proj_dir, proj_dir + '/src'))
        '''
        with open("test_mmc3_eth.yaml") as conf_file:
            try:
                conf = yaml.safe_load(conf_file)
            except yaml.YAMLError as exception:
                print(exception)

        conf['transfer_layer'][0]['type']

        self.chip = Dut(conf)
        self.chip.init()
        '''

        self.chip = Dut(cnfg_yaml)
        self.chip.init()
Exemple #2
0
# ------------------------------------------------------------
# SiTCP throughput test
# Reads data for a couple of seconds and displays the data rate
#
# Copyright (c) All rights reserved
# SiLab, Institute of Physics, University of Bonn
# ------------------------------------------------------------
#

import time
from basil.dut import Dut

chip = Dut("mmc3_eth.yaml")
chip.init()

chip['GPIO_LED']['LED'] = 0x01  #start data source

testduration = 10
total_len = 0
tick = 0
tick_old = 0
start_time = time.time()

while time.time() - start_time < testduration:
    data = chip['SRAM'].get_data()
    total_len += len(data) * 4 * 8
    time.sleep(0.01)
    tick = int(time.time() - start_time)
    if tick != tick_old:
        print tick
        tick_old = tick
Exemple #3
0
# ------------------------------------------------------------
# Copyright (c) All rights reserved
# SiLab, Institute of Physics, University of Bonn
# ------------------------------------------------------------
#

from basil.dut import Dut

chip = Dut("mio3_eth_gpac.yaml")
chip.init()

chip['VDD'].set_current_limit(80, unit='mA')
chip['VDD'].set_voltage(1.3, unit='V')
chip['VDD'].set_enable(True)

chip['CONTROL']['LED'] = 0xa5

chip['CONTROL'].write()
Exemple #4
0
 def setUp(self):
     cfg = yaml.load(cnfg_yaml)
     self.device = Dut(cfg)
     self.device.init()
Exemple #5
0
# ------------------------------------------------------------
# Copyright (c) All rights reserved
# SiLab, Institute of Physics, University of Bonn
# ------------------------------------------------------------
#

import numpy as np

from basil.dut import Dut


chip = Dut("sram_test.yaml")
chip.init()


def test_sram(count=10000):
    i = 0
    error = 0

    for k in range(count):

        # chip['CONTROL']['COUNTER_EN'] = 1
        # chip['CONTROL'].write()
        # chip['CONTROL']['COUNTER_EN'] = 0
        # chip['CONTROL'].write()

        chip['PULSE'].set_DELAY(1)
        chip['PULSE'].set_WIDTH((k + 1) % 3000)
        chip['PULSE'].START

        ret = chip['FIFO'].get_data()
Exemple #6
0
#
# ------------------------------------------------------------
# Copyright (c) All rights reserved
# SiLab, Institute of Physics, University of Bonn
# ------------------------------------------------------------
#
''' This script shows how to use a Suss or Signatone Probe station.

BTW:
For the PA-200 it is not forseen to be able to communicate with the prober bench software
when running on the host PC without using the propriatary and not documented network interface dll.

A work around is to use the Suss RS232 interface that is in place to connect to another
client PC. To be able to use the Probe station directly with BASIL on the host PC via RS232 a virtual
comport has to be created connecting the real comport (that is set in the RS232 Interface
application, pbrs232.exe) to a virtual one.
This virtual one is then used to steer the probe station within BASIL.
'''

from basil.dut import Dut

dut = Dut('suss_pa_200.yaml')
dut.init()
print(dut['SussProber'].get_position())
print(dut['SussProber'].get_die())

dut2 = Dut('SignatoneProber.yaml')
dut2.init()
print(dut2['SignatoneProber'].get_position())
print(dut2['SignatoneProber'].get_die())
 def setUpClass(cls):
     cls.cnfg = yaml.load(cnfg_yaml)
     cls.dut = Dut(cls.cnfg)
     cls.dut['spi_module']._require_version = "==1"
     cls.dut.init()
     cls.dut['spi_module']._mem_bytes = 4
Exemple #8
0
# ------------------------------------------------------------
# Copyright (c) All rights reserved
# SiLab, Institute of Physics, University of Bonn
# ------------------------------------------------------------
#
''' Example how to use different laboratory devices (Sourcemeter, pulsers, etc.) that understand SCPI.
    The language (SCPI) is independent of the interface (TCP, RS232, GPIB, USB, etc.). The interfaces
    can be choosen by an appropriate transportation layer (TL). This can be a VISA TL and
    a Serial TL at the moment. VISA TL is recommendet since it gives you access to almost
    all laboratory devices (> 90%) over TCP, RS232, USB, GPIB (Windows only so far).
    '''

from basil.dut import Dut

# Talk to a Keithley device via serial port using pySerial
dut = Dut('keithley2400_pyserial.yaml')
dut.init()
print dut['Sourcemeter'].get_name()

# Talk to a Keithley device via serial port using VISA with Serial interface
dut = Dut('keithley2400_pyvisa.yaml')
dut.init()
print dut['Sourcemeter'].get_name()
# Some additional implemented methods for this device
print dut['Sourcemeter'].get_voltage()
dut['Sourcemeter'].off()
dut['Sourcemeter'].set_voltage(3.14159)
dut['Sourcemeter'].set_current_limit(.9265)

# Example of a SCPI device implementing more specialized functions (e.g. unit conversion) via extra class definitions
dut = Dut('agilent33250a_pyserial.yaml')
    def scan(self,
             mask_steps=4,
             repeat_command=100,
             PrmpVbpDac=80,
             vthin2Dac=0,
             columns=[True] * 16,
             scan_range=[0, 0.2, 0.005],
             vthin1Dac=80,
             preCompVbnDac=50,
             mask_filename='',
             **kwargs):
        '''Scan loop
        Parameters
        ----------
        mask : int
            Number of mask steps.
        repeat : int
            Number of injections.
        '''
        inj_factor = 1.0
        INJ_LO = 0.0
        try:
            dut = Dut(
                ScanBase.get_basil_dir(self) +
                '/examples/lab_devices/agilent33250a_pyserial.yaml')
            dut.init()
            logging.info('Connected to ' + str(dut['Pulser'].get_info()))
        except RuntimeError:
            INJ_LO = 0.2
            inj_factor = 2.0
            logging.info(
                'External injector not connected. Switch to internal one')
            self.dut['INJ_LO'].set_voltage(INJ_LO, unit='V')

        self.dut['global_conf']['PrmpVbpDac'] = 80
        self.dut['global_conf']['vthin1Dac'] = 255
        self.dut['global_conf']['vthin2Dac'] = 0
        self.dut['global_conf']['vffDac'] = 24
        self.dut['global_conf']['PrmpVbnFolDac'] = 51
        self.dut['global_conf']['vbnLccDac'] = 1
        self.dut['global_conf']['compVbnDac'] = 25
        self.dut['global_conf']['preCompVbnDac'] = 50

        self.dut.write_global()
        self.dut['control']['RESET'] = 0b01
        self.dut['control']['DISABLE_LD'] = 0
        self.dut['control']['PIX_D_CONF'] = 0
        self.dut['control'].write()

        self.dut['control']['CLK_OUT_GATE'] = 1
        self.dut['control']['CLK_BX_GATE'] = 1
        self.dut['control'].write()
        time.sleep(0.1)

        self.dut['control']['RESET'] = 0b11
        self.dut['control'].write()

        self.dut['global_conf']['OneSr'] = 1

        self.dut['global_conf']['TestHit'] = 0
        self.dut['global_conf']['SignLd'] = 0
        self.dut['global_conf']['InjEnLd'] = 0
        self.dut['global_conf']['TDacLd'] = 0
        self.dut['global_conf']['PixConfLd'] = 0
        self.dut.write_global()

        #self.dut['global_conf']['OneSr'] = 0  #all multi columns in parallel
        self.dut['global_conf']['ColEn'][:] = bitarray.bitarray([True] *
                                                                16)  #(columns)
        self.dut['global_conf']['ColSrEn'][:] = bitarray.bitarray([True] * 16)
        self.dut.write_global()

        self.dut['pixel_conf'].setall(False)
        self.dut.write_pixel()
        self.dut['global_conf']['InjEnLd'] = 1
        self.dut.write_global()
        self.dut['global_conf']['InjEnLd'] = 0

        mask_en = np.full([64, 64], False, dtype=np.bool)
        mask_tdac = np.full([64, 64], 16, dtype=np.uint8)

        for inx, col in enumerate(columns):
            if col:
                mask_en[inx * 4:(inx + 1) * 4, :] = True

        if mask_filename:
            logging.info('Using pixel mask from file: %s', mask_filename)

            with tb.open_file(mask_filename, 'r') as in_file_h5:
                mask_tdac = in_file_h5.root.scan_results.tdac_mask[:]
                mask_en = in_file_h5.root.scan_results.en_mask[:]

        self.dut.write_en_mask(mask_en)
        self.dut.write_tune_mask(mask_tdac)

        self.dut['global_conf']['OneSr'] = 0
        self.dut.write_global()

        self.dut['inj'].set_delay(
            10000
        )  #this seems to be working OK problem is probably bad injection on GPAC usually +0
        self.dut['inj'].set_width(1000)
        self.dut['inj'].set_repeat(repeat_command)
        self.dut['inj'].set_en(False)

        self.dut['trigger'].set_delay(400 - 4)
        self.dut['trigger'].set_width(16)
        self.dut['trigger'].set_repeat(1)
        self.dut['trigger'].set_en(True)

        ###
        self.dut['trigger'].set_delay(
            10000
        )  #this seems to be working OK problem is probably bad injection on GPAC usually +0
        self.dut['trigger'].set_width(16)
        self.dut['trigger'].set_repeat(repeat_command)
        self.dut['trigger'].set_en(False)

        ##
        logging.debug('Configure TDC')
        self.dut['tdc']['RESET'] = True
        self.dut['tdc']['EN_TRIGGER_DIST'] = True
        self.dut['tdc']['ENABLE_EXTERN'] = False
        self.dut['tdc']['EN_ARMING'] = False
        self.dut['tdc']['EN_INVERT_TRIGGER'] = False
        self.dut['tdc']['EN_INVERT_TDC'] = False
        self.dut['tdc']['EN_WRITE_TIMESTAMP'] = True

        lmask = [1] + ([0] * (mask_steps - 1))
        lmask = lmask * ((64 * 64) / mask_steps + 1)
        lmask = lmask[:64 * 64]

        scan_range = np.arange(scan_range[0], scan_range[1],
                               scan_range[2]) / inj_factor

        for idx, k in enumerate(scan_range):
            dut['Pulser'].set_voltage(INJ_LO, float(INJ_LO + k), unit='V')
            self.dut['INJ_HI'].set_voltage(float(INJ_LO + k), unit='V')
            time.sleep(0.5)

            bv_mask = bitarray.bitarray(lmask)

            with self.readout(scan_param_id=idx):
                logging.info('Scan Parameter: %f (%d of %d)', k, idx + 1,
                             len(scan_range))
                pbar = ProgressBar(maxval=mask_steps).start()
                for i in range(mask_steps):

                    self.dut['global_conf']['vthin1Dac'] = 255
                    self.dut['global_conf']['preCompVbnDac'] = 50
                    self.dut['global_conf']['vthin2Dac'] = 0
                    self.dut['global_conf']['PrmpVbpDac'] = 80
                    self.dut.write_global()
                    time.sleep(0.1)

                    self.dut['pixel_conf'][:] = bv_mask
                    self.dut.write_pixel_col()
                    self.dut['global_conf']['InjEnLd'] = 1
                    #self.dut['global_conf']['PixConfLd'] = 0b11
                    self.dut.write_global()

                    bv_mask[1:] = bv_mask[0:-1]
                    bv_mask[0] = 0

                    self.dut['global_conf']['vthin1Dac'] = vthin1Dac
                    self.dut['global_conf']['preCompVbnDac'] = preCompVbnDac
                    self.dut['global_conf']['vthin2Dac'] = vthin2Dac
                    self.dut['global_conf']['PrmpVbpDac'] = PrmpVbpDac
                    self.dut.write_global()
                    time.sleep(0.1)

                    #self.dut['inj'].start()

                    pbar.update(i)

                    while not self.dut['inj'].is_done():
                        pass

                    while not self.dut['trigger'].is_done():
                        pass

                    #self.dut['trigger'].set_repeat(0)
                    #self.dut['control']['CLK_BX_GATE'] = 0
                    #self.dut['control']['CLK_OUT_GATE'] = 0
                    #self.dut['control'].write()

                    print('!!!!!!!!!!!!!!!1')
                    self.dut['tdc'].ENABLE = True
                    self.dut['trigger'].start()
                    time.sleep(10)
                    self.dut['tdc'].ENABLE = False
                    print('!!!!!!!!!!!!!!!2')

                    #self.dut['control']['CLK_BX_GATE'] = 1
                    #self.dut['control']['CLK_OUT_GATE'] = 1
                    #self.dut['control'].write()

        scan_results = self.h5_file.create_group("/", 'scan_results',
                                                 'Scan Masks')
        self.h5_file.createCArray(scan_results, 'tdac_mask', obj=mask_tdac)
        self.h5_file.createCArray(scan_results, 'en_mask', obj=mask_en)
Exemple #10
0
 def setUp(self):
     self.cfg = yaml.safe_load(cnfg_yaml)
     self.device = Dut(self.cfg)
     self.device.init()
    
registers:
  - name        : GPIO_LED
    type        : StdRegister
    hw_driver   : gpio_drv
    size        : 8
    fields:
      - name    : LED
        size    : 8
        offset  : 7
"""

import time
from basil.dut import Dut

chip = Dut(cnfg_yaml)
chip.init()

#for i in range(8):
#    chip['GPIO_LED']['LED'] = 0x01 << i
#    chip['GPIO_LED'].write()
#    print('LED:', chip['GPIO_LED'].get_data())
#    #time.sleep(1)

print 'START'
chip['M26_RX1'].reset()
chip['M26_RX2'].reset()
chip['M26_RX3'].reset()
chip['M26_RX4'].reset()
chip['M26_RX5'].reset()
chip['M26_RX6'].reset()
from __future__ import print_function
from basil.dut import Dut
import time

dut = Dut('/home/rasmus/git/basil/examples/lab_devices/ttiql355tp.yaml')
dut.init()
print(dut['PowerSupply'].get_name())


def power_on():
    dut['PowerSupply'].on(channel=1)
    dut['PowerSupply'].on(channel=2)
    dut['PowerSupply'].on(channel=3)

    time.sleep(3)

    print("Channel 1")
    print(dut['PowerSupply'].get_voltage(channel=1))
    print("Channel 2")
    print(dut['PowerSupply'].get_voltage(channel=2))


def power_off():
    dut['PowerSupply'].off(channel=1)
    dut['PowerSupply'].off(channel=2)
    dut['PowerSupply'].off(channel=3)

    time.sleep(3)

    print("Channel 1")
    print(dut['PowerSupply'].get_voltage(channel=1))
            # TODO interlock on air humidity?
            if t_sens is not None and (t_sens < (target - accuracy) or t_sens >
                                       (target + accuracy)):
                logging.warning(
                    'Temperature on device deviated too much: Target = {0}, T_sens = {1:1.2f}'
                    .format(target, t_sens))
            if time.time() - timestamp_start > wait_time:
                logging.info('Wait time over. Continuing...')
                break


if __name__ == '__main__':
    with open(OUTFILE_TEMPS, 'w') as f:
        pass

    dut = Dut('thermocycling.yaml')
    dut.init()

    logging.info('Starting run, setting start temperature to 20C...')
    dut['Climatechamber'].start_manual_mode()
    dut['Climatechamber'].set_air_dryer(
        True)  # make sure air dryer is running to avoid condensation
    go_to_temperature(20, wait_time=3 * 60 *
                      60)  # wait 3h at 20°C to make sure the air is dry

    # Reset data file
    with open(OUTFILE_TEMPS, 'w') as f:
        f.write(
            '#Timestamp, T_setpoint, T_chamber, T_sens, Hum_sens, T_mod, Hum_mod, T_air, Hum_air\n'
        )
Exemple #14
0
#
# ------------------------------------------------------------
# Copyright (c) All rights reserved
# SiLab, Institute of Physics, University of Bonn
# ------------------------------------------------------------
#

''' Example how to use the digital IO of the Arduino board.
'''

import time

from basil.dut import Dut

dut = Dut('arduino.yaml')
dut.init()

time.sleep(1)  # Wait for Arduino to reset

dut['Arduino'].set_output(channel=13, 1)
dut['Arduino'].set_output(channel='ALL', 'OFF')
    def init_dut(self): 
        
        if self.remote:
            dut = Dut('agilent_e3644a_pyserial.yaml')
            dut.init()
            status = dut['Powersupply'].get_enable()
            time.sleep(0.15)    
            status = status.replace("\n", "").replace("\r", "")
            status = int(status) #convert string to float in order to compare values!
            if status == 1:
                logging.info("Output of powersupply is ON, status: %s"%status)
            else:
                logging.info("Output of powersupply is OFF, status: %s" % status)  # TODO: STOP READOUT!!!
                #abort(msg='Scan timeout was reached')
                #stop_current_run(msg='OFF')
            current = dut['Powersupply'].get_current()
            current = current.replace("\n", "").replace("\r", "")
            logging.info('Current:  %s A', current)
            current = float(current)  # convert string to float in order to compare values!
        else:
            logging.info('No remote enabled')

        map(lambda channel: channel.reset(), self.dut.get_modules('m26_rx'))
        self.dut['jtag'].reset()

        if 'force_config_mimosa26' in self._conf and not self._conf['force_config_mimosa26'] and self.remote and current >= 3.3: #check if force_config is False
                logging.info('Skipping m26 configuration, m26 is already configured')
        else:     
            if 'm26_configuration' in self._conf and self._conf['m26_configuration']:
                m26_config_file =  os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))), self._conf['m26_configuration'])

                logging.info('Loading m26 configuration file %s', m26_config_file)
                self.dut.set_configuration(m26_config_file)

                IR={"BSR_ALL":'00101',"DEV_ID_ALL":'01110',"BIAS_DAC_ALL":'01111',"LINEPAT0_REG_ALL":'10000',
                    "DIS_DISCRI_ALL":'10001',"SEQUENCER_PIX_REG_ALL":'10010',"CONTROL_PIX_REG_ALL":'10011',
                    "LINEPAT1_REG_ALL":'10100',"SEQUENCER_SUZE_REG_ALL":'10101',"HEADER_REG_ALL":'10110',
                    "CONTROL_SUZE_REG_ALL":'10111',
                    "CTRL_8b10b_REG0_ALL":'11000',"CTRL_8b10b_REG1_ALL":'11001',"RO_MODE1_ALL":'11101',
                    "RO_MODE0_ALL":'11110',
                    "BYPASS_ALL":'11111'}
                ## write JTAG
                irs = ["BIAS_DAC_ALL","BYPASS_ALL","BSR_ALL","RO_MODE0_ALL","RO_MODE1_ALL",
                "DIS_DISCRI_ALL","LINEPAT0_REG_ALL","LINEPAT1_REG_ALL","CONTROL_PIX_REG_ALL","SEQUENCER_PIX_REG_ALL",
                "HEADER_REG_ALL","CONTROL_SUZE_REG_ALL","SEQUENCER_SUZE_REG_ALL","CTRL_8b10b_REG0_ALL",
                "CTRL_8b10b_REG1_ALL"]
                for i,ir in enumerate(irs):
                    logging.info('Programming M26 JATG configuration reg %s', ir)
                    logging.debug(self.dut[ir][:])
                    self.dut['jtag'].scan_ir([BitLogic(IR[ir])]*6)
                    ret = self.dut['jtag'].scan_dr([self.dut[ir][:]])[0]
                    
                if self.remote:    
                    current = dut['Powersupply'].get_current()
                    current = current.replace("\n", "").replace("\r", "")
                    logging.info('Current:  %s A', current)  
                ## read JTAG  and check
                irs=["DEV_ID_ALL","BSR_ALL","BIAS_DAC_ALL","RO_MODE1_ALL","RO_MODE0_ALL",
                   "DIS_DISCRI_ALL","LINEPAT0_REG_ALL","LINEPAT1_REG_ALL","CONTROL_PIX_REG_ALL",
                   "SEQUENCER_PIX_REG_ALL",
                   "HEADER_REG_ALL","CONTROL_SUZE_REG_ALL","SEQUENCER_SUZE_REG_ALL","CTRL_8b10b_REG0_ALL",
                   "CTRL_8b10b_REG1_ALL","BYPASS_ALL"]
                ret={}
                for i,ir in enumerate(irs):
                    logging.info('Reading M26 JATG configuration reg %s', ir)
                    self.dut['jtag'].scan_ir([BitLogic(IR[ir])]*6)
                    ret[ir]= self.dut['jtag'].scan_dr([self.dut[ir][:]])[0]
                
                if self.remote:
                    current = dut['Powersupply'].get_current()
                    current = current.replace("\n", "").replace("\r", "")
                    logging.info('Current:  %s A', current)    
                ## check
                for k,v in ret.iteritems():
                    if k=="CTRL_8b10b_REG1_ALL":
                        pass
                    elif k=="BSR_ALL":
                        pass #TODO mask clock bits and check others
                    elif self.dut[k][:]!=v:
                        logging.error("JTAG data does not match %s get=%s set=%s"%(k,v,self.dut[k][:]))
                    else:
                        logging.info("Checking M26 JTAG %s ok"%k)
                    
                if self.remote:    
                    current = dut['Powersupply'].get_current()
                    current = current.replace("\n", "").replace("\r", "")
                    logging.info('Current:  %s A', current)    
                #START procedure
                logging.info('Starting M26')
                temp=self.dut['RO_MODE0_ALL'][:]
                  #disable extstart
                for reg in self.dut["RO_MODE0_ALL"]["RO_MODE0"]:
                    reg['En_ExtStart']=0
                    reg['JTAG_Start']=0
                self.dut['jtag'].scan_ir([BitLogic(IR['RO_MODE0_ALL'])]*6)
                self.dut['jtag'].scan_dr([self.dut['RO_MODE0_ALL'][:]])
                  #JTAG start
                for reg in self.dut["RO_MODE0_ALL"]["RO_MODE0"]:
                    reg['JTAG_Start']=1
                self.dut['jtag'].scan_ir([BitLogic(IR['RO_MODE0_ALL'])]*6)
                self.dut['jtag'].scan_dr([self.dut['RO_MODE0_ALL'][:]])
                for reg in self.dut["RO_MODE0_ALL"]["RO_MODE0"]:
                    reg['JTAG_Start']=0
                self.dut['jtag'].scan_ir([BitLogic(IR['RO_MODE0_ALL'])]*6)
                self.dut['jtag'].scan_dr([self.dut['RO_MODE0_ALL'][:]])
                  #write original configuration
                self.dut['RO_MODE0_ALL'][:]=temp
                self.dut['jtag'].scan_ir([BitLogic(IR['RO_MODE0_ALL'])]*6)
                self.dut['jtag'].scan_dr([self.dut['RO_MODE0_ALL'][:]])
                  #readback?
                self.dut['jtag'].scan_ir([BitLogic(IR['RO_MODE0_ALL'])]*6)
                self.dut['jtag'].scan_dr([self.dut['RO_MODE0_ALL'][:]]*6)
                
                if self.remote:
                    current = dut['Powersupply'].get_current()
                    current = current.replace("\n", "").replace("\r", "")
                    logging.info('Current:  %s A', current)
            else:
                logging.info('Skipping m26 configuration')
Exemple #16
0
#
# ------------------------------------------------------------
# Copyright (c) All rights reserved
# SiLab, Institute of Physics, University of Bonn
# ------------------------------------------------------------
#
''' This script shows how to use a Motor Stage
'''

from __future__ import print_function
from basil.dut import Dut

dut = Dut('mercury_pyserial.yaml')
dut.init()
print(dut["MotorStage"].get_position())
# dut["MotorStage"].set_position(100000)
Exemple #17
0
#
# ------------------------------------------------------------
# Copyright (c) All rights reserved
# SiLab, Institute of Physics, University of Bonn
# ------------------------------------------------------------
#
''' Example how to use the chiller.
'''

from basil.dut import Dut

dut = Dut('julaboF32HD.yaml')
dut.init()
print("ID: {}".format(dut["chiller"].get_identifier()))
print("Status: {}".format(dut["chiller"].get_status()))

# start
# set menu->confiuration->setpoint->rs232
dut["chiller"].start_thermostat()
dut["chiller"].get_status()
            token = slack_token
        slack = WebClient(token)


def notify(message):
    if notify_on_slack:
        for user in slack_users:
            slack.chat_postMessage(channel=user, text=message, username='******', icon_emoji=':robot_face:')


if __name__ == '__main__':

    setup_slack()
    notify("Starts thermal cycles!")

    dut = Dut(PERIPHERYFILE)
    dut.init()
    sensors = setup_sensors()

    with open(OUTFILE_TEMPS, 'w') as f:
        f.write('#Timestamp, ' + ', '.join([s['name'] for s in sensors] + [interlock_dp]) + ', ' + '\n')

    logging.info('Starting run, setting start temperature to 20C...')
    dut['Climatechamber'].start_manual_mode()
    dut['Climatechamber'].set_air_dryer(True)  # make sure air dryer is running to avoid condensation
    try:
        go_to_temperature(starting_temperature, wait_time=minimal_starting_time, save_data=save_data_on_startup)
        wait_for_min_dew_point(starting_temperature - starting_dew_point, timeout=maximal_starting_time - minimal_starting_time)
    except Exception:
        notify("Thermal cycling couldn't be started!")
        raise
Exemple #19
0
import time
from basil.dut import Dut

# Initialize x-ray tube
devices = Dut('xray_tube_pyserial.yaml')
devices.init()

# Set high voltage and current
devices["xray_tube"].set_voltage(10)  # 40 kV
devices["xray_tube"].set_current(50)  # 50 mA
print(devices["xray_tube"].get_actual_voltage())  # in kV
print(devices["xray_tube"].get_actual_current())  # in mA

devices["xray_tube"].set_high_voltage_on()  # Turn on HV
devices["xray_tube"].set_timer(dur=3600)  # 3600 s
devices["xray_tube"].activate_timer(
)  # Activate the timer (clock symbol on display)
devices["xray_tube"].open_shutter(
)  # Starts actual irradiation (and timer, if set)

time.sleep(10)
# Print remaining irradiation time in seconds
print(devices["xray_tube"].get_actual_time())

# Print status of HV (bit 6 of status word 0)
print(devices["xray_tube"].get_status(0)[1])
Exemple #20
0
# ------------------------------------------------------------
# Copyright (c) All rights reserved
# SiLab, Institute of Physics, University of Bonn
# ------------------------------------------------------------
#


from basil.dut import Dut

chip = Dut("simple_register_example.yaml")

print(chip['TEST'])
print(chip['REG'])

# chip['REG'][0] = 1
chip['REG']['VPULSE'][5] = 1
# chip['REG']['VPULSE'] = 1

# chip['REG']['COLUMN'][0] = 1 # does not work yet
# chip['REG'][0] = 1 # does not work yet

chip['REG']['COLUMN'][0]['EnR'] = 1
chip['REG']['COLUMN'][0]['DACR'] = 3

chip['REG']['VINJECT'] = 3
print(chip['REG'])

chip['REG']['VINJECT'][0] = 1
print(chip['REG'])

print('VINJECT {}'.format(str(chip['REG']['VINJECT'])))
Exemple #21
0
# ------------------------------------------------------------
# SiTCP throughput test
# Reads data for a couple of seconds and displays the data rate
#
# Copyright (c) All rights reserved
# SiLab, Physics Institute, University of Bonn
# ------------------------------------------------------------
#
import logging
import time

import numpy as np

from basil.dut import Dut

chip = Dut("bdaq53_eth.yaml")
chip.init()

chip['CONTROL']['EN'] = 0
chip['CONTROL'].write()

logging.info("Starting data test ...")

chip['CONTROL']['EN'] = 1
chip['CONTROL'].write()

start = 0
for i in range(10):

    time.sleep(1)
        print "here 6"

        #reset some stuff
        self['SEQ']['GLOBAL_SHIFT_EN'].setall(False)
        self['SEQ']['GLOBAL_CTR_LD'].setall(False)
        self['SEQ']['GLOBAL_DAC_LD'].setall(False)
        self['SEQ']['PIXEL_SHIFT_EN'].setall(False)
        self['SEQ']['INJECTION'].setall(False)


# Read in the configuration YAML file
stream = open("pyBAR_SEABAS.yaml", 'r')
cnfg = yaml.load(stream)

# Create the Pixel object
dut = Dut(cnfg)
dut.init()


def cmd(data, size):
    dut['cmd']['CMD_SIZE'] = size
    dut['cmd'].set_data(data)
    dut['cmd']['START']

    while not dut['cmd']['READY']:
        pass


cmd([0xB4, 0x10, 0x37, 0x00, 0x00], 39)  # settings PLL
cmd([0xB4, 0x10, 0x38, 0x04, 0x0C], 39)  #settings PLL
cmd([0xB4, 0x50, 0x70], 23)  # run mode
Exemple #23
0
    def setUp(self):
        cocotb_compile_and_run(sim_files=[os.path.join(os.path.dirname(__file__), self._test_tb)], sim_bus=self._sim_bus, extra_defines=self._bus_split_def)

        self.chip = Dut(cnfg_yaml)
        self.chip.init()
    def pre_run(self):
        # sending data
        self.socket_addr = self._run_conf['send_data']
        if self.socket_addr:
            logging.info('Send data to %s', self.socket_addr)
        # scan parameters
        if 'scan_parameters' in self.run_conf:
            if isinstance(self.run_conf['scan_parameters'], basestring):
                self.run_conf['scan_parameters'] = ast.literal_eval(
                    self.run_conf['scan_parameters'])
            sp = namedtuple(
                'scan_parameters',
                field_names=zip(*self.run_conf['scan_parameters'])[0])
            self.scan_parameters = sp(*zip(
                *self.run_conf['scan_parameters'])[1])
        else:
            sp = namedtuple_with_defaults('scan_parameters', field_names=[])
            self.scan_parameters = sp()
        logging.info(
            'Scan parameter(s): %s', ', '.join([
                '%s=%s' % (key, value)
                for (key, value) in self.scan_parameters._asdict().items()
            ]) if self.scan_parameters else 'None')

        # init DUT
        if not isinstance(self.conf['dut'], Dut):
            module_path = os.path.dirname(
                os.path.abspath(inspect.getfile(inspect.currentframe())))
            if isinstance(self.conf['dut'], basestring):
                # dirty fix for Windows pathes
                self.conf['dut'] = os.path.normpath(self.conf['dut'].replace(
                    '\\', '/'))
                # abs path
                if os.path.isabs(self.conf['dut']):
                    dut = self.conf['dut']
                # working dir
                elif os.path.exists(
                        os.path.join(self.conf['working_dir'],
                                     self.conf['dut'])):
                    dut = os.path.join(self.conf['working_dir'],
                                       self.conf['dut'])
                # path of this file
                elif os.path.exists(os.path.join(module_path,
                                                 self.conf['dut'])):
                    dut = os.path.join(module_path, self.conf['dut'])
                else:
                    raise ValueError('%s: dut file not found' %
                                     self.conf['dut'])
                self._conf['dut'] = Dut(dut)
            else:
                self._conf['dut'] = Dut(self.conf['dut'])

            # only initialize when DUT was not initialized before
            if 'dut_configuration' in self.conf and self.conf[
                    'dut_configuration']:
                if isinstance(self.conf['dut_configuration'], basestring):
                    # dirty fix for Windows pathes
                    self.conf['dut_configuration'] = os.path.normpath(
                        self.conf['dut_configuration'].replace('\\', '/'))
                    # abs path
                    if os.path.isabs(self.conf['dut_configuration']):
                        dut_configuration = self.conf['dut_configuration']
                    # working dir
                    elif os.path.exists(
                            os.path.join(self.conf['working_dir'],
                                         self.conf['dut_configuration'])):
                        dut_configuration = os.path.join(
                            self.conf['working_dir'],
                            self.conf['dut_configuration'])
                    # path of dut file
                    elif os.path.exists(
                            os.path.join(os.path.dirname(self.dut.conf_path),
                                         self.conf['dut_configuration'])):
                        dut_configuration = os.path.join(
                            os.path.dirname(self.dut.conf_path),
                            self.conf['dut_configuration'])
                    # path of this file
                    elif os.path.exists(
                            os.path.join(module_path,
                                         self.conf['dut_configuration'])):
                        dut_configuration = os.path.join(
                            module_path, self.conf['dut_configuration'])
                    else:
                        raise ValueError(
                            '%s: dut_configuration file not found' %
                            self.conf['dut_configuration'])
                    self.dut.init(dut_configuration)
                else:
                    self.dut.init(self.conf['dut_configuration'])
            else:
                self.dut.init()
            # additional init of the DUT
            self.init_dut()
        else:
            pass  # do nothing, already initialized
        # FIFO readout
        self.fifo_readout = FifoReadout(self.dut)
        # initialize the FE
        self.init_fe()
Exemple #25
0
#
# ------------------------------------------------------------
# Copyright (c) All rights reserved
# SiLab, Institute of Physics, University of Bonn
# ------------------------------------------------------------
#

''' This script shows how to read temperature/humidity with Sensition sensors and how to set temperature using a Binder MK 53 climate chamber.
The Sensition sensors are read using the Sensirion EK-H4 multiplexer box from the evaluation kit. A serial TL has to be used
(http://www.sensirion.com/fileadmin/user_upload/customers/sensirion/Dokumente/Humidity/Sensirion_Humidity_EK-H4_Datasheet_V3.pdf).
For the communication with the Binder MK 53 also  a serial TL has to be used (http://www.binder-world.com).
'''

from basil.dut import Dut

# Sensirion sensor readout
dut = Dut('sensirionEKH4_pyserial.yaml')
dut.init()
print dut['Thermohygrometer'].get_temperature()
print dut['Thermohygrometer'].get_humidity()
print dut['Thermohygrometer'].get_dew_point()

# Binder MK 53 control
dut = Dut('binderMK53_pyserial.yaml')
dut.init()
print dut['Climatechamber'].get_temperature()
print dut['Climatechamber'].get_door_open()
print dut['Climatechamber'].get_mode()
temperature_target = dut['Climatechamber'].get_temperature_target()
dut['Climatechamber'].set_temperature(temperature_target)
Exemple #26
0
#
# ------------------------------------------------------------
# Copyright (c) All rights reserved
# SiLab, Institute of Physics, University of Bonn
# ------------------------------------------------------------
#
'''
    This script shows how to set temperature using a Binder MK 53 climate chamber.
    For the communication with the Binder MK 53 also  a serial TL has to be used (http://www.binder-world.com).
    The newer Weiss Labevent climatechamber uses a direct TCP/IP connection.
'''

from basil.dut import Dut

# Binder MK 53 control
dut = Dut('binderMK53_pyserial.yaml')
dut.init()
print(dut['Climatechamber'].get_temperature())
print(dut['Climatechamber'].get_door_open())
print(dut['Climatechamber'].get_mode())
temperature_target = dut['Climatechamber'].get_temperature_target()
dut['Climatechamber'].set_temperature(temperature_target)

# New Weiss Labevent control
dut = Dut('WeissLabEvent_socket.yaml')
dut.init()
dut['Climatechamber'].start_manual_mode()
dut['Climatechamber'].set_temperature(20)
dut['Climatechamber'].set_air_dryer(
    True)  # Make sure the air dryer is turned on
print(dut['Climatechamber'].get_temperature())
Exemple #27
0
    def _run(self):
        if 'scan_parameters' in self.run_conf:
            sp = namedtuple(
                'scan_parameters',
                field_names=zip(*self.run_conf['scan_parameters'])[0])
            self.scan_parameters = sp(*zip(
                *self.run_conf['scan_parameters'])[1])
        else:
            sp = namedtuple_with_defaults('scan_parameters', field_names=[])
            self.scan_parameters = sp()
        logging.info('Scan parameter(s): %s' % (', '.join([
            '%s=%s' % (key, value)
            for (key, value) in self.scan_parameters._asdict().items()
        ]) if self.scan_parameters else 'None'))

        try:
            last_configuration = self._get_configuration()
            if 'fe_configuration' in self.conf and self.conf[
                    'fe_configuration']:
                if not isinstance(self.conf['fe_configuration'], FEI4Register):
                    if isinstance(self.conf['fe_configuration'], basestring):
                        if os.path.isabs(self.conf['fe_configuration']):
                            fe_configuration = self.conf['fe_configuration']
                        else:
                            fe_configuration = os.path.join(
                                self.conf['working_dir'],
                                self.conf['fe_configuration'])
                        self._conf['fe_configuration'] = FEI4Register(
                            configuration_file=fe_configuration)
                    elif isinstance(
                            self.conf['fe_configuration'],
                        (int, long)) and self.conf['fe_configuration'] >= 0:
                        self._conf['fe_configuration'] = FEI4Register(
                            configuration_file=self._get_configuration(
                                self.conf['fe_configuration']))
                    else:
                        self._conf['fe_configuration'] = FEI4Register(
                            configuration_file=self._get_configuration())
                else:
                    pass  # do nothing, already initialized
            elif last_configuration:
                self._conf['fe_configuration'] = FEI4Register(
                    configuration_file=last_configuration)
            else:
                if 'chip_address' in self.conf and isinstance(
                        self.conf['chip_address'], (int, long)):
                    chip_address = self.conf['chip_address']
                    broadcast = False
                else:
                    chip_address = 0
                    broadcast = True
                if 'fe_flavor' in self.conf and self.conf['fe_flavor']:
                    self._conf['fe_configuration'] = FEI4Register(
                        fe_type=self.conf['fe_flavor'],
                        chip_address=chip_address,
                        broadcast=broadcast)
                else:
                    raise ValueError('No valid configuration found')

            if not isinstance(self.conf['dut'], Dut):
                if isinstance(self.conf['dut'], basestring):
                    if os.path.isabs(self.conf['dut']):
                        dut = self.conf['dut']
                    else:
                        dut = os.path.join(self.conf['working_dir'],
                                           self.conf['dut'])
                    self._conf['dut'] = Dut(dut)
                else:
                    self._conf['dut'] = Dut(self.conf['dut'])
                module_path = os.path.dirname(
                    os.path.abspath(inspect.getfile(inspect.currentframe())))
                if 'dut_configuration' in self.conf and self.conf[
                        'dut_configuration']:
                    if isinstance(self.conf['dut_configuration'], basestring):
                        if os.path.isabs(self.conf['dut_configuration']):
                            dut_configuration = self.conf['dut_configuration']
                        else:
                            dut_configuration = os.path.join(
                                self.conf['working_dir'],
                                self.conf['dut_configuration'])
                        self.dut.init(dut_configuration)
                    else:
                        self.dut.init(self.conf['dut_configuration'])
                elif self.dut.name == 'usbpix':
                    self.dut.init(
                        os.path.join(module_path,
                                     'dut_configuration_usbpix.yaml'))
                elif self.dut.name == 'usbpix_gpac':
                    self.dut.init(
                        os.path.join(module_path,
                                     'dut_configuration_usbpix_gpac.yaml'))
                else:
                    logging.warning('Omit initialization of DUT')
                if self.dut.name == 'usbpix':
                    self.dut['POWER'].set_voltage('VDDA1', 1.500)
                    self.dut['POWER'].set_voltage('VDDA2', 1.500)
                    self.dut['POWER'].set_voltage('VDDD1', 1.200)
                    self.dut['POWER'].set_voltage('VDDD2', 1.200)
                    self.dut['POWER_SCC']['EN_VD1'] = 1
                    self.dut['POWER_SCC']['EN_VD2'] = 1
                    self.dut['POWER_SCC']['EN_VA1'] = 1
                    self.dut['POWER_SCC']['EN_VA2'] = 1
                    self.dut['POWER_SCC'].write()
                    # enabling readout
                    self.dut['rx']['CH1'] = 1
                    self.dut['rx']['CH2'] = 1
                    self.dut['rx']['CH3'] = 1
                    self.dut['rx']['CH4'] = 1
                    self.dut['rx']['TLU'] = 1
                    self.dut['rx']['TDC'] = 1
                    self.dut['rx'].write()
                elif self.dut.name == 'usbpix_gpac':
                    self.dut['V_in'].set_current_limit(
                        1000, unit='mA')  # one for all
                    # enabling LVDS transceivers
                    self.dut['CCPD_Vdd'].set_enable(False)
                    self.dut['CCPD_Vdd'].set_voltage(0.0, unit='V')
                    self.dut['CCPD_Vdd'].set_enable(True)
                    # enabling V_in
                    self.dut['V_in'].set_enable(False)
                    self.dut['V_in'].set_voltage(2.1, unit='V')
                    self.dut['V_in'].set_enable(True)
                    # enabling readout
                    self.dut['rx']['FE'] = 1
                    self.dut['rx']['TLU'] = 1
                    self.dut['rx']['TDC'] = 1
                    self.dut['rx']['CCPD_TDC'] = 0
                    self.dut['rx'].write()
                else:
                    logging.warning(
                        'Unknown DUT name: %s. DUT may not be set up properly'
                        % self.dut.name)

            else:
                pass  # do nothing, already initialized

            if not self.fifo_readout:
                self.fifo_readout = FifoReadout(self.dut)
            if not self.register_utils:
                self.register_utils = FEI4RegisterUtils(
                    self.dut, self.register)
            with open_raw_data_file(filename=self.output_filename,
                                    mode='w',
                                    title=self.run_id,
                                    scan_parameters=self.scan_parameters.
                                    _asdict()) as self.raw_data_file:
                self.save_configuration_dict(self.raw_data_file.h5_file,
                                             'conf', self.conf)
                self.save_configuration_dict(self.raw_data_file.h5_file,
                                             'run_conf', self.run_conf)
                self.register_utils.global_reset()
                self.register_utils.configure_all()
                if is_fe_ready(self):
                    reset_service_records = False
                else:
                    reset_service_records = True
                self.register_utils.reset_bunch_counter()
                self.register_utils.reset_event_counter()
                if reset_service_records:
                    # resetting service records must be done once after power up
                    self.register_utils.reset_service_records()
                with self.register.restored(name=self.run_number):
                    self.configure()
                    self.register.save_configuration(
                        self.raw_data_file.h5_file)
                    self.fifo_readout.reset_rx()
                    self.fifo_readout.reset_sram_fifo()
                    self.fifo_readout.print_readout_status()
                    self.scan()
        except Exception:
            self.handle_err(sys.exc_info())
        else:
            try:
                if self.abort_run.is_set():
                    raise RunAborted('Omitting data analysis: run was aborted')
                self.analyze()
            except AnalysisError as e:
                logging.error('Analysis of data failed: %s' % e)
            except Exception:
                self.handle_err(sys.exc_info())
            else:
                self.register.save_configuration(self.output_filename)
        finally:
            self.raw_data_file = None
            try:
                self.fifo_readout.print_readout_status()
            except Exception:
                pass
            try:
                self.dut['USB'].close()  # free USB resources
            except Exception:
                logging.error('Cannot close USB device')
        if not self.err_queue.empty():
            exc = self.err_queue.get()
            if isinstance(exc[1], (RxSyncError, EightbTenbError, FifoError,
                                   NoDataTimeout, StopTimeout)):
                raise RunAborted(exc[1])
            else:
                raise exc[0], exc[1], exc[2]
Exemple #28
0
    def setUp(self):
        cocotb_compile_and_run([os.getcwd() + '/test_SimAdcRx.v'])

        self.chip = Dut(cnfg_yaml)
        self.chip.init()
Exemple #29
0
    def setUp(self):
        cocotb_compile_and_run(
            [os.path.join(os.path.dirname(__file__), 'test_SimGpio.v')])

        self.chip = Dut(cnfg_yaml)
        self.chip.init()
Exemple #30
0
    def compute_move(self,
                     size_x=None,
                     z=None,
                     currentLimit=1.000000E-01,
                     z_delay=None,
                     x_delay=None,
                     x=None,
                     size_z=None,
                     sourcemeter=False,
                     motorstage=None,
                     directory=None):
        # Initial plot will be generated
        '''
        Assuming that the cabinet door is the -z
        1 mm is equivalent to 56.88888 step
        x : Number of movements to x direction
        z: Number of movements inside the cabinet
        Size_x: size of the step in  mm x direction
        Size_z: size of the step in  mm z direction
        '''
        size_x = size_x * 57000
        size_z = size_z * 57000
        if sourcemeter:
            #dut = Dut('Scanning_pyserial.yaml')
            dut = Dut(rootdir[:-8] +
                      "devices/source_meter/keithley2400_pyserial.yaml")
            dut.init()
            dut['Keithley'].write(":OUTP ON")
            dut['Keithley'].write("*RST")
            dut['Keithley'].write(":SOUR:VOLT:RANG 60")
            dut['Keithley'].write('SENS:CURR:PROT ' + str(currentLimit))
            print("The Protection Current limit is",
                  dut['Keithley'].ask("SENS:CURR:PROT?"))
            dut['Keithley'].write(":SOUR:FUNC VOLT")
            dut['Keithley'].write(':SOUR:VOLT 50')
        if motorstage:
            dut = Dut('motorstage_Pyserial.yaml')
            dut.init()

        def fill_snake_pattern(step_z=False,
                               sourcemeter=sourcemeter,
                               motorstage=motorstage,
                               size_z=None,
                               a=None,
                               b=None,
                               c=None,
                               size_x=None,
                               x_delay=None,
                               z_delay=z_delay,
                               directory=None):
            first_point = True
            for step_x in tqdm(np.arange(a, b, c), unit='xstep'):
                if motorstage:
                    if not first_point:
                        dut["ms"].read_write(
                            "MR%d" % (size_x),
                            address=3)  # x 50000,100,50 = 4.5 cm left/right
                    first_point = False
                time.sleep(x_delay)
                if sourcemeter:
                    val = dut['Keithley'].ask(":MEAS:CURR?")
                    current = val[15:-43]
                else:
                    current = random.randint(0, 100)
                # save for Monitoring
                self.set_data(x=current)
                beamspot[step_z, step_x] = float(current)
                self.set_beam_spot(beamspot)
                try:
                    save_to_h5(data=beamspot,
                               outname='beamspot_Live.h5',
                               directory=directory)

                except IndexError:  #open file failure
                    pass
                beamshow = plt.imshow(beamspot,
                                      aspect='auto',
                                      origin='upper',
                                      cmap=plt.get_cmap('tab20c'))
                plt.pause(0.05)
            if motorstage:
                dut["ms"].read_write(
                    "MR%d" % (-size_z),
                    address=2)  # x# x 50000,100,50 = 4.5 cm in/out
            time.sleep(z_delay)

        t0 = time.time()
        length = 20
        config_beamspot = define_configured_array(size_x=size_x,
                                                  z=z,
                                                  x=x,
                                                  size_z=size_z)
        beamspot = np.zeros(shape=(z, x), dtype=np.float64)
        for step_z in tqdm(np.arange(z), unit='zstep'):
            a, b = config_beamspot[step_z].item(
                0), config_beamspot[step_z].item(1)
            c, new_size_x = config_beamspot[step_z].item(
                2), config_beamspot[step_z].item(3)
            fill_snake_pattern(step_z=step_z,
                               a=int(a),
                               b=int(b),
                               c=int(c),
                               size_x=int(new_size_x),
                               x_delay=x_delay,
                               z_delay=z_delay,
                               directory=directory)
        #plt.show()
        outname = 'beamspot.h5'
        save_to_h5(data=beamspot, outname=outname, directory=directory)
        log.info("The beamspot file is saved as " +
                 os.path.join(directory, outname))
        t1 = time.time()
        log.info("The time Estimated is " + np.str(t1 - t0) + " s")