Exemplo n.º 1
0
    def initialize(self):
        self.nd = MCL_NanoDrive()
        self.adw = ADwin.ADwin()
        self.awgcomm = AWG520()

        # try:
        #     self.adw.Boot(self.adw.ADwindir + 'ADwin11.btl')
        #     count_proc = os.path.join(os.path.dirname(__file__),'ADWIN\\TrialCounter.TB1') # TrialCounter is configured as process 1
        #     self.adw.Load_Process(count_proc)
        # except ADwin.ADwinError as e:
        #     sys.stderr.write(e.errorText)
        #     self.conn.send('Abort!')
        #     self.running=False

        try:
            # boot the adwin with the bootloader
            self.adw.Boot(self.adw.ADwindir + 'ADwin11.btl')
            # Measurement protocol is configured as process 2, external triggered
            count_proc = os.path.join(
                os.path.dirname(__file__), 'ADWIN\\TrialCounter.TB1'
            )  # TrialCounter is configured as process 1
            self.adw.Load_Process(count_proc)

        except ADwin.ADwinError as e:
            sys.stderr.write(e.errorText)
            self.conn.send('Abort!')
            self.scanning = False
Exemplo n.º 2
0
    def initialize(self):
        # for some reason the initialization was not previously carried out in an __Init__ , at first i didnt't want to change this at the moment
        # since it was working with the hardware. But will give it a try
        count_time = self.parameters[1]
        reset_time = self.parameters[2]
        samples = self.parameters[0]
        threshold = self.parameters[4]
        numavgs = self.parameters[3]
        start = self.scan['start']
        step = self.scan['stepsize']
        numsteps = self.scan['steps']
        use_pts = self.mw['PTS'][0]
        enable_scan_pts = self.mw['PTS'][2]
        current_freq = self.mw['PTS'][1]
        start_freq = self.mw['PTS'][3]
        step_freq = self.mw['PTS'][4]
        num_freq_steps = self.mw['PTS'][5]
        stop_freq = self.mw['PTS'][6]
        do_enable_iq = self.awgparams['enable IQ']
        self.adw = ADwin.ADwin()
        try:
            # boot the adwin with the bootloader
            self.adw.Boot(self.adw.ADwindir + 'ADwin11.btl')
            # Measurement protocol is configured as process 2, external triggered
            measure_proc = os.path.join(os.path.dirname(__file__), 'AdWIN',
                                        'Measure_Protocol.TB2')
            self.adw.Load_Process(measure_proc)
            # TrialCounter is configured as process 1
            count_proc = os.path.join(os.path.dirname(__file__),
                                      'ADWIN\\TrialCounter.TB1')
            self.adw.Load_Process(count_proc)
            # TODO: set the parameters in the ADWIN -- check the .BAS files
            # from what I could tell of Adbasic, these values seem to be ignored in the Measure protocol
            # double check with Elijah and maybe correct the .bas file
            self.adw.Set_Par(3, count_time)
            self.adw.Set_Par(4, reset_time)
            self.adw.Set_Par(5, samples)
            # start the Measure protocol
            self.adw.Start_Process(2)
            self.logger.info('Adwin parameter 5 is {:d}'.format(self.adw.Get_Par(5))) # seem to be printing the samples
            # value
            # again?

        except ADwin.ADwinError as e:
            sys.stderr.write(e.errorText)
            self.conn.send('Abort!')
            self.scanning = False


        # initialize the PTS and output the current frequency
        if use_pts:
            self.pts = PTS()
            self.pts.write(int(current_freq * _MHZ))
        else:
            self.logger.error('No microwave synthesizer selected')
        self.awgcomm = AWG520()
        self.awgcomm.setup(do_enable_iq)  # removed the setup of AWG in Upload thread, so do it now.
        self.awgcomm.run()  # places the AWG into enhanced run mode.
        time.sleep(0.2)
Exemplo n.º 3
0
    def run(self):
        # ----------------- lines below commented out on 2021-02-07 to avoid writing to disk
        # create files
        samples = self.parameters[0]
        delay = self.parameters[-2:]

        # enable_scan_pts = self.mw['PTS'][2]
        scan_carrier_freq = (self.scan['type'] == 'Carrier frequency')
        # do_enable_iq = self.awgparams['enable IQ']
        # npulses = self.pulseparams['num pulses']
        # if scan_carrier_freq:
        #     # we can scan frequency either using PTS or using the SB freq
        #     #self.scan['type'] = 'frequency'
        #     self.scan['type'] = 'no scan' # this tells the SeqList class to simply put one sequence as the PTS will
        #     # scan the frequency
        # now create teh sequences
        self.sequences = SequenceList(sequence=self.seq,
                                      delay=delay,
                                      pulseparams=self.pulseparams,
                                      scanparams=self.scan,
                                      timeres=self.timeRes)
        # write the files to the AWG520/sequencefiles directory
        self.awgfile = AWGFile(ftype='SEQ', timeres=self.timeRes)
        self.awgfile.write_sequence(sequences=self.sequences,
                                    seqfilename="scan.seq",
                                    repeat=samples)
        # -----------------------------------------------------------------------------------------------
        # now upload the files
        # self.done.emit()
        # uncomment these lines when you are ready to connect to the AWG --------------------------------------------
        try:
            if self.awgparams['awg device'] == 'awg520':
                # print("Upload OK!")
                self.awgcomm = AWG520()
                # transfer all files to AWG
                t = time.process_time()
                for filename in os.listdir(self.dirPath):
                    self.awgcomm.sendfile(self.awgPath / filename,
                                          self.dirPath / filename)
                transfer_time = time.process_time() - t
                time.sleep(1)
                self.logger.info(
                    'time elapsed for all files to be transferred is:{0:.3f} seconds'
                    .format(transfer_time))
                self.awgcomm.cleanup()
                self.done.emit()
            else:
                raise ValueError('AWG520 is the only AWG supported')
        except ValueError as err:
            self.logger.error('Value Error {0}'.format(err))
        except RuntimeError as err:
            self.logger.error('Run time error {0}'.format(err))
Exemplo n.º 4
0
    def initialize(self):
        self.nd=MCL_NanoDrive()
        self.adw=ADwin.ADwin()
        self.awgcomm = AWG520()

        try:
            self.adw.Boot(self.adw.ADwindir + 'ADwin11.btl')
            count_proc = os.path.join(os.path.dirname(__file__),'ADWIN\\TrialCounter.TB1') # TrialCounter is configured as process 1
            self.adw.Load_Process(count_proc)
        except ADwin.ADwinError as e:
            sys.stderr.write(e.errorText)
            self.conn.send('Abort!')
            self.running=False
Exemplo n.º 5
0
    def run(self):
        # create files
        samples = self.parameters[0]
        delay = self.parameters[-2:]

        enable_scan_pts = self.mw['PTS'][2]
        do_enable_iq = self.awgparams['enable IQ']
        npulses = self.pulseparams['num pulses']
        if enable_scan_pts:
            # we can scan frequency either using PTS or using the SB freq
            #self.scan['type'] = 'frequency'
            self.scan[
                'type'] = 'no scan'  # this tells the SeqList class to simply put one sequence as the PTS will
            # scan the frequency
        # now create teh sequences
        self.sequences = SequenceList(sequence=self.seq,
                                      delay=delay,
                                      pulseparams=self.pulseparams,
                                      scanparams=self.scan,
                                      timeres=self.timeRes)
        # write the files to the AWG520/sequencefiles directory
        self.awgfile = AWGFile(sequencelist=self.sequences,
                               ftype='SEQ',
                               timeres=self.timeRes)
        self.awgfile.write_sequence(repeat=samples)
        # now upload the files
        try:
            if self.awgparamgs['device'] == 'awg520':
                self.awgcomm = AWG520()
                #self.awgcomm.setup(do_enable_iq) # pass the enable IQ flag otherwise the AWG will only use one channel
                #  transfer all files to AWG
                t = time.process_time()
                for filename in os.listdir(dirPath):
                    self.awgcomm.sendfile(filename, dirPath / filename)
                transfer_time = time.process_time() - t
                time.sleep(1)
                self.logger.info(
                    'time elapsed for all files to be transferred is:{0:.3f}'.
                    format(transfer_time))
                self.awgcomm.cleanup()
                self.done.emit()
            else:
                raise ValueError('AWG520 is the only AWG supported')
        except ValueError as err:
            self.logger.error('Value Error {0}'.format(err))
        except RuntimeError as err:
            self.logger.error('Run time error {0}'.format(err))
Exemplo n.º 6
0
# This is a script written to test the file upload function to the AWG
# This uploads the files in dirPath to a folder awgPath inside the AWG

import os
from pathlib import Path
from source.Hardware.AWG520 import AWG520
awg=AWG520()

dirPath = Path('D:\PyCharmProjects\quantum-pulse\source\Hardware\AWG520\sequencefiles')
awgPath = Path('./pulsed_esr')

i=1
for filename in os.listdir(dirPath):
    awg.sendfile(awgPath / filename, dirPath / filename)
    print('uploaded {} files'.format(i))
    i+=1

awg.cleanup()