def __init__(self, name, pulser):
        """
            Initialize the virtual instruments

                Input:
                    name            : Name of the virtual instruments
                    pulser          : Name given to the pulser

                Output:
                    None
        """

        Instrument.__init__(self, name, tags=["virtual"])

        self.add_parameter(
            "period", units="ns", flags=Instrument.FLAG_GETSET | Instrument.FLAG_GET_AFTER_SET, type=types.FloatType
        )
        self.add_parameter("cooling_time", units="ns", flags=Instrument.FLAG_GETSET, type=types.FloatType)
        self.add_parameter("origin", units="ns", flags=Instrument.FLAG_GETSET, type=types.FloatType)

        # Defining some stuff
        self._instruments = instruments.get_instruments()
        self._pulser = self._instruments.get(pulser)

        self._cooling_time = 1e3  # in [ns]
        self._origin = 0.0  # in [ns]

        self.get_all()
Esempio n. 2
0
    def __init__(self, name, source=None, channel = 0, stepsize = 2e-9, stepdelay=1):
        '''
            virtual magnet built upon yokogawa source
        '''
        Instrument.__init__(self, name, tags=['virtual'])
        self._instruments = instruments.get_instruments()
        self._source= self._instruments.get(source)
        self._channel = channel        
        # Add parameters        
        self.add_parameter('current', type=types.FloatType,
            flags=Instrument.FLAG_GETSET, units='A')
        self.add_parameter('stepsize', type=types.FloatType,
            flags=Instrument.FLAG_GETSET, units='A')        
        self.add_parameter('range', type=types.FloatType,
            flags=Instrument.FLAG_GETSET, units='A')        
        self.add_parameter('stepdelay', type=types.FloatType,
            flags=Instrument.FLAG_GETSET, units='ms')

        self._stepsize = stepsize
        self._stepdelay = stepdelay
        getattr(self._source, 'set_ch%d_sweep_mode'%channel)('fix')
        getattr(self._source, 'set_ch%d_source_mode'%channel)('curr')
        getattr(self._source, 'set_ch%d_sense_mode'%channel)('curr')

        self.get_all()
Esempio n. 3
0
    def __init__(self, name, pulser):
        '''
            Initialize the virtual instruments

                Input:
                    name            : Name of the virtual instruments
                    pulser          : Name given to the pulser

                Output:
                    None
        '''

        Instrument.__init__(self, name, tags=['virtual'])

        self.add_parameter('period', units='ns',  flags=Instrument.FLAG_GETSET | Instrument.FLAG_GET_AFTER_SET, type=types.FloatType)
        self.add_parameter('cooling_time', units='ns', flags=Instrument.FLAG_GETSET, type=types.FloatType)
        self.add_parameter('origin', units='ns', flags=Instrument.FLAG_GETSET, type=types.FloatType)


        # Defining some stuff
        self._instruments = instruments.get_instruments()
        self._pulser = self._instruments.get(pulser)

        self._cooling_time = 1e3 #in [ns]
        self._origin = 0. #in [ns]


        self.get_all()
    def __init__(self, name, pulser, probe_src, period):
        '''
            Initialize the virtual instruments

                Input:
                    - name: Name of the virtual instruments
                    - pulser: Name of a delay generator
                    - mwsrc: Name given to the microwave_generator
                    - period: Name given to the virtual period

                Output:
                    None
        '''
        Instrument.__init__(self, name, tags=['virtual'])

        #Import instruments
        self._instruments = instruments.get_instruments()
        self._pulser = self._instruments.get(pulser)
        self._period = self._instruments.get(period)
        self._probe_src = self._instruments.get(probe_src)

        #Parameters
        self.add_parameter('width',
                           flags=Instrument.FLAG_GETSET,
                           minval=2,
                           maxval=1e10,
                           units='ns',
                           type=types.FloatType)
        self.add_parameter('delay',
                           flags=Instrument.FLAG_GETSET,
                           minval=-1e10,
                           maxval=1e10,
                           units='ns',
                           type=types.FloatType)

        self.add_parameter('frequency',
                           flags=Instrument.FLAG_GETSET,
                           units='GHz',
                           minval=1e-4,
                           maxval=40,
                           type=types.FloatType)

        self.add_parameter('power',
                           flags=Instrument.FLAG_GETSET,
                           minval=-135.,
                           maxval=25.,
                           units='dBm',
                           type=types.FloatType)

        self.add_parameter('status',
                           option_list=['ON', 'OFF'],
                           flags=Instrument.FLAG_GETSET,
                           type=types.StringType)

        #We initialize the trigger pulse for the board
        self._pulser.set_chC_status('OFF')
        self._pulser.set_chC_polarity('POS')
        self._pulser.set_chC_status('ON')

        self.get_all()
    def __init__(self, name, pulser):
        '''
            Initialize the virtual instruments
                
                Input:
                    name            : Name of the virtual instruments
                    pulser          : Name given to the pulser
                
                Output:
                    None
        '''
        
        Instrument.__init__(self, name, tags=['virtual'])
        
        self.add_parameter('period', units='ns',  flags=Instrument.FLAG_GETSET | Instrument.FLAG_GET_AFTER_SET, type=types.FloatType)
        self.add_parameter('cooling_time', units='ns', flags=Instrument.FLAG_GETSET, type=types.FloatType)
        self.add_parameter('origin', units='ns', flags=Instrument.FLAG_GETSET, type=types.FloatType)

        
        # Defining some stuff
        self._instruments = instruments.get_instruments()
        self._pulser = self._instruments.get(pulser)
        
        self._cooling_time = 1e3 #in [ns]
        self._origin = 0. #in [ns]
        
        
        self.get_all()
    def __init__(self, name, pulser, mwsrc, period):
        '''
            Initialize the virtual instruments
                
                Input:
                    - name: Name of the virtual instruments
                    - pulser: Name of the tektronix AFG3252
                    - mwsrc: Name given to the microwave_generator
                    - live_update (bool): The microwave pulse will be update at each setting or not
                    
                
                Output:
                    None
        '''
        
        Instrument.__init__(self, name, tags=['virtual'])
        
        #Parameters
        self.add_parameter('width',
                            flags=Instrument.FLAG_GETSET, 
                            minval=2.,
                            maxval=1e10,
                            units='ns', 
                            type=types.FloatType)
        
        self.add_parameter('frequency', 
                            flags=Instrument.FLAG_GETSET, 
                            units='GHz', 
                            minval = 10e-3, 
                            maxval= 26.5e9, 
                            type=types.FloatType)
        
        self.add_parameter('power', 
                            flags=Instrument.FLAG_GETSET, 
                            minval = -20., 
                            maxval= 25., 
                            units='dBm', 
                            type=types.FloatType)
        self.add_parameter('delay', 
                            flags=Instrument.FLAG_GETSET, 
                            minval=-1e10,
                            maxval=1e10,
                            units='ns', 
                            type=types.FloatType)
        
        self.add_parameter('status', option_list=['ON', 'OFF'], flags=Instrument.FLAG_GETSET, type=types.StringType)


        #Functions

        
        #Import instruments
        self._instruments = instruments.get_instruments()
        self._pulser = self._instruments.get(pulser)
        self._microwave_generator = self._instruments.get(mwsrc)
        self._period = self._instruments.get(period)
        
        
        self.get_all()
    def __init__(self, name, pulser, probe_src, period):
        '''
            Initialize the virtual instruments
                
                Input:
                    - name: Name of the virtual instruments
                    - pulser: Name of a delay generator
                    - mwsrc: Name given to the microwave_generator
                    - period: Name given to the virtual period
                
                Output:
                    None
        '''
        Instrument.__init__(self, name, tags=['virtual'])
        
        #Import instruments
        self._instruments = instruments.get_instruments()
        self._pulser      = self._instruments.get(pulser)
        self._period      = self._instruments.get(period)
        self._probe_src   = self._instruments.get(probe_src)
        
        #Parameters
        self.add_parameter('width',
                            flags=Instrument.FLAG_GETSET, 
                            minval=2,
                            maxval=1e10,
                            units='ns', 
                            type=types.FloatType)
        self.add_parameter('delay', 
                            flags=Instrument.FLAG_GETSET, 
                            minval=-1e10,
                            maxval=1e10,
                            units='ns', 
                            type=types.FloatType)
        
        self.add_parameter('frequency', 
                            flags=Instrument.FLAG_GETSET, 
                            units='GHz', 
                            minval = 1e-4, 
                            maxval= 40, 
                            type=types.FloatType)
                            
        self.add_parameter('power', 
                            flags=Instrument.FLAG_GETSET, 
                            minval = -135., 
                            maxval= 25., 
                            units='dBm', 
                            type=types.FloatType)

        self.add_parameter('status', option_list=['ON', 'OFF'], flags=Instrument.FLAG_GETSET, type=types.StringType)


        #We initialize the trigger pulse for the board
        self._pulser.set_chC_status('OFF')
        self._pulser.set_chC_polarity('POS')
        self._pulser.set_chC_status('ON')
        
        self.get_all()
    def __init__(self, name, afg, mwsrc, live_update=True):
        '''
            Initialize the virtual instruments
                
                Input:
                    - name: Name of the virtual instruments
                    - afg: Name of the tektronix AFG3252
                    - mwsrc: Name given to the microwave_generator
                    - live_update (bool): The microwave pulse will be update at each setting or not
                    
                
                Output:
                    None
        '''
        
        Instrument.__init__(self, name, tags=['virtual'])
        
        #Parameters
        self.add_parameter('rise_time', flags=Instrument.FLAG_GETSET, units='ns', type=types.FloatType)
        self.add_parameter('plateau_time', flags=Instrument.FLAG_GETSET, units='ns', type=types.FloatType)
        self.add_parameter('fall_time', flags=Instrument.FLAG_GETSET, units='ns', type=types.FloatType)
        
        self.add_parameter('plateau_voltage', flags=Instrument.FLAG_GETSET, units='V', minval=0.05, maxval=5.0, type=types.FloatType)
        self.add_parameter('amplitude', flags=Instrument.FLAG_GET, units='mV', type=types.FloatType)
        
        # self.add_parameter('frequency', flags=Instrument.FLAG_GETSET, units='GHz', minval=100e-6, maxval=12.75, type=types.FloatType)
        # self.add_parameter('power', flags=Instrument.FLAG_GETSET, units='dBm', type=types.FloatType)
        
        self.add_parameter('interval', minval=1e-3, maxval= 500, units='s', flags=Instrument.FLAG_GETSET, type=types.FloatType)

        
        # self.add_parameter('status', option_list=['on', 'off'], flags=Instrument.FLAG_GETSET, type=types.StringType)
        self.add_parameter('live_update', option_list=[True, False], flags=Instrument.FLAG_GETSET, type=types.BooleanType)


        #Functions

        
        #Import instruments
        self._instruments = instruments.get_instruments()
        self._afg = self._instruments.get(afg)
        self._microwave_generator = self._instruments.get(mwsrc)
        self.live_update = live_update
        
        
        #Define default values
        self.rise_time = 10.0 #ns
        self.plateau_time = 20.0 #ns
        self.fall_time = 10.0 #ns
        
        self.plateau_voltage = 3.5 #V
        
        self.get_all()
Esempio n. 9
0
    def __init__(self, name, PWS1='PWS1', PWS2='PWS2'):
        '''
        Initializes a virtual magnet built upon two PWS4205 wired in parallel
        connected to solenoid coil in the white fridge
        both current sources deliver up to 5A, but coil will quench
        lower
        
        Input:
          name (string)    : name of the instrument
          PWS1 (string) : name of the first power source, default=PWS1
          PWS2 (string) : name of the second power source, default=PWS2
        '''
        logging.info(__name__ +
                     ' : Initializing instrument virtual power source')
        Instrument.__init__(self, name, tags=['virtual'])
        self._instruments = instruments.get_instruments()
        try:
            self._PWS1 = self._instruments.get(PWS1)
        except:
            logging.error('no PWS1 found ... aborting')
            return
        try:
            self._PWS2 = self._instruments.get(PWS2)
        except:
            logging.error('no PWS2 found ... aborting')
            return

        self.add_parameter('current',
                           type=types.FloatType,
                           flags=Instrument.FLAG_GETSET,
                           units='A')
        self.add_parameter('voltage',
                           type=types.FloatType,
                           flags=Instrument.FLAG_GET,
                           units='V')
        self.add_parameter('status',
                           type=types.BooleanType,
                           flags=Instrument.FLAG_GETSET)
        self.add_parameter('magneticField',
                           type=types.FloatType,
                           flags=Instrument.FLAG_GET,
                           units='mT')

        self.add_function('get_all')
        self.add_function('ramp_current')
        self.add_function('ramp_magenticField')
        self.add_function('check_for_quench')
        self.add_function('on')
        self.add_function('off')
        self.get_all()
Esempio n. 10
0
    def __init__(self, name, source=None, channel = 0, dachannels = 1, inverted = False):
		Instrument.__init__(self, name, tags=['virtual'])
		self._instruments = instruments.get_instruments()
		self._source= self._instruments.get(source)
		self._channel = channel # channel = 'portn/linem'
		self._nchannels = dachannels
		self._values = np.zeros((dachannels))
		self._inverted = inverted
        
		# Add parameters        
		self.add_parameter('value', type=float,
			channels=(1, dachannels), channel_prefix = 'ch%d_',
			flags=Instrument.FLAG_SET, units='V')
		self.add_parameter('invert', type=bool,
			flags=Instrument.FLAG_SET, units='')
Esempio n. 11
0
    def __init__(self, name, source=None, channel = 0, dachannels = 1, inverted = False):
		Instrument.__init__(self, name, tags=['virtual'])
		self._instruments = instruments.get_instruments()
		self._source= self._instruments.get(source)
		self._channel = channel # channel = 'portn/linem'
		self._nchannels = dachannels
		self._values = np.zeros((dachannels))
		self._inverted = inverted
        
		# Add parameters        
		self.add_parameter('value', type=types.FloatType,
			channels=(1, dachannels), channel_prefix = 'ch%d_',
			flags=Instrument.FLAG_SET, units='V')
		self.add_parameter('invert', type=types.BooleanType,
			flags=Instrument.FLAG_SET, units='')
Esempio n. 12
0
    def __init__(self, name, PWS1='PWS1', PWS2='PWS2'):
        '''
        Initializes a virtual magnet built upon two PWS4205 wired in parallel
        connected to solenoid coil in the white fridge
        both current sources deliver up to 5A, but coil will quench
        lower
        
        Input:
          name (string)    : name of the instrument
          PWS1 (string) : name of the first power source, default=PWS1
          PWS2 (string) : name of the second power source, default=PWS2
        '''
        logging.info(__name__ + ' : Initializing instrument virtual power source')
        Instrument.__init__(self, name, tags=['virtual'])
        self._instruments = instruments.get_instruments()
        try:
            self._PWS1= self._instruments.get(PWS1)
        except:
            logging.error('no PWS1 found ... aborting')
            return
        try:
            self._PWS2= self._instruments.get(PWS2)
        except:
            logging.error('no PWS2 found ... aborting')
            return

        self.add_parameter('current', type=types.FloatType,
            flags=Instrument.FLAG_GETSET, units='A')
        self.add_parameter('voltage', type=types.FloatType,
            flags=Instrument.FLAG_GET, units='V')        
        self.add_parameter('status', type=types.BooleanType,
            flags=Instrument.FLAG_GETSET)
        self.add_parameter('magneticField', type=types.FloatType, 
        flags=Instrument.FLAG_GET, units='mT')

        self.add_function('get_all')
        self.add_function('ramp_current')
        self.add_function('ramp_magenticField')
        self.add_function('check_for_quench')
        self.add_function('on')
        self.add_function('off')
        self.get_all()
Esempio n. 13
0
    def __init__(self,
                 name,
                 source=None,
                 channel=0,
                 stepsize=2e-9,
                 stepdelay=1):
        '''
            virtual magnet built upon yokogawa source
        '''
        Instrument.__init__(self, name, tags=['virtual'])
        self._instruments = instruments.get_instruments()
        self._source = self._instruments.get(source)
        self._channel = channel
        # Add parameters
        self.add_parameter('current',
                           type=types.FloatType,
                           flags=Instrument.FLAG_GETSET,
                           units='A')
        self.add_parameter('stepsize',
                           type=types.FloatType,
                           flags=Instrument.FLAG_GETSET,
                           units='A')
        self.add_parameter('range',
                           type=types.FloatType,
                           flags=Instrument.FLAG_GETSET,
                           units='A')
        self.add_parameter('stepdelay',
                           type=types.FloatType,
                           flags=Instrument.FLAG_GETSET,
                           units='ms')

        self._stepsize = stepsize
        self._stepdelay = stepdelay
        getattr(self._source, 'set_ch%d_sweep_mode' % channel)('fix')
        getattr(self._source, 'set_ch%d_source_mode' % channel)('curr')
        getattr(self._source, 'set_ch%d_sense_mode' % channel)('curr')

        self.get_all()
Esempio n. 14
0
    def __init__(self, name, source=None, channel = 0, stepsize = 2e-9, stepdelay=1, multiplier = 1, range = 1e-3, old = 0):
        Instrument.__init__(self, name, tags=['virtual'])
        self._instruments = instruments.get_instruments()
        self._source= self._instruments.get(source)
        self._channel = channel        
        # Add parameters        
        self.add_parameter('current', type=float,
            flags=Instrument.FLAG_SET, units='A')
        self.add_parameter('stepsize', type=float,
            flags=Instrument.FLAG_GETSET, units='A')        
        self.add_parameter('stepdelay', type=float,
            flags=Instrument.FLAG_GETSET, units='ms')
        self.add_parameter('multiplier', type=float,
            flags=Instrument.FLAG_GETSET, units='')
        self.add_parameter('range', type=float,
            flags=Instrument.FLAG_GETSET, units='A')            

        self._stepsize = stepsize
        self._stepdelay = stepdelay
        self._multiplier = multiplier
        self._range = range
        self._old = old;
        self.get_all()
Esempio n. 15
0
	def __init__(self, name, source=None, channel = 0, stepsize = 2e-9, stepdelay=1, multiplier = 1, range = 1e-3, old = 0):
		Instrument.__init__(self, name, tags=['virtual'])
		self._instruments = instruments.get_instruments()
		self._source= self._instruments.get(source)
		self._channel = channel        
		# Add parameters        
		self.add_parameter('current', type=types.FloatType,
			flags=Instrument.FLAG_SET, units='A')
		self.add_parameter('stepsize', type=types.FloatType,
			flags=Instrument.FLAG_GETSET, units='A')        
		self.add_parameter('stepdelay', type=types.FloatType,
			flags=Instrument.FLAG_GETSET, units='ms')
		self.add_parameter('multiplier', type=types.FloatType,
			flags=Instrument.FLAG_GETSET, units='')
		self.add_parameter('range', type=types.FloatType,
			flags=Instrument.FLAG_GETSET, units='A')            

		self._stepsize = stepsize
		self._stepdelay = stepdelay
		self._multiplier = multiplier
		self._range = range
		self._old = old;
		self.get_all()
Esempio n. 16
0
# Global namespace

import os
import sys
from qtflow import get_flowcontrol
from instruments import get_instruments
from lib import config as _config
from data import Data
from plot import Plot, plot, plot3, replot_all
from scripts import Scripts, Script

config = _config.get_config()

data = Data.get_named_list()
instruments = get_instruments()
frontpanels = {}
sliders = {}
scripts = Scripts()

flow = get_flowcontrol()
msleep = flow.measurement_idle
mstart = flow.measurement_start
mend = flow.measurement_end

from plot import Plot2D, Plot3D
try:
    from plot import plot_file
except:
    pass

plots = Plot.get_named_list()
    def __init__(self, name, spectrum, mwsrc_read_out, pulser, nums=128, segsize= 2048, amp0=500, amp1=500):
        '''
            Initialize the virtual instruments

                Input:
                    name            : Name of the virtual instruments
                    spectrum        : Name given to the Spectrum M3i4142
                    nums (int)      : number of consequtive measurements
                                        default = 128

                    segsize (int)   : Size of the memory allocated in the card [Sample]
                                        default = 2048

                    amp0 (int)      : half of the range of the channel 0 [mV]
                                        default = 500

                    amp1 (int)      : half of the range of the channel 1 [mV]
                                        default = 500

                Output:
                    None
        '''

        Instrument.__init__(self, name, tags=['virtual'])


        self.add_parameter('input_term_ch0', option_list=['50', '1 M'], units='Ω', flags=Instrument.FLAG_GETSET, type=types.StringType)
        self.add_parameter('input_term_ch1', option_list=['50', '1 M'], units='Ω', flags=Instrument.FLAG_GETSET, type=types.StringType)

        self.add_parameter('input_amp_ch0', option_list=[200, 500, 1000, 2000, 5000, 10000], units='mV', flags=Instrument.FLAG_GETSET, type=types.IntType)
        self.add_parameter('input_amp_ch1', option_list=[200, 500, 1000, 2000, 5000, 10000], units='mV', flags=Instrument.FLAG_GETSET, type=types.IntType)

        self.add_parameter('filter_ch0', option_list=['FBW', '20 MHz'], units='', flags=Instrument.FLAG_GETSET, type=types.StringType)
        self.add_parameter('filter_ch1', option_list=['FBW', '20 MHz'], units='', flags=Instrument.FLAG_GETSET, type=types.StringType)

        self.add_parameter('input_coupling_ch0', option_list=['AC', 'DC'], units='', flags=Instrument.FLAG_GETSET, type=types.StringType)
        self.add_parameter('input_coupling_ch1', option_list=['AC', 'DC'], units='', flags=Instrument.FLAG_GETSET, type=types.StringType)

        #The maxvalue of the samplerate is only of 250 MS.Hz because we use the two channels of the board
        self.add_parameter('samplerate', units='MS.Hz', minval=10, maxval=250, flags=Instrument.FLAG_GETSET, type=types.IntType)
        self.add_parameter('delay', units='ns', minval = 0., maxval=1e6, flags=Instrument.FLAG_GETSET, type=types.FloatType)

        self.add_parameter('segmentsize', minval=16, units='S', flags=Instrument.FLAG_GETSET, type=types.IntType)
        self.add_parameter('repetitions', minval=1, flags=Instrument.FLAG_GETSET, type=types.IntType)

#        self.add_parameter('acquisitionTime', units='ms', flags=Instrument.FLAG_GET, type=types.FloatType)
#        self.add_parameter('bandWidth', units='Hz', flags=Instrument.FLAG_GET, type=types.FloatType)


        self.add_parameter('status', flags=Instrument.FLAG_GETSET, option_list=['on', 'off'], type=types.StringType)
        self.add_parameter('detuning', units='MHz', flags=Instrument.FLAG_GETSET, type=types.FloatType)
        self.add_parameter('frequency', units='GHz', minval=100e-6, maxval=12.75, flags=Instrument.FLAG_GETSET, type=types.FloatType)
        self.add_parameter('power', units='dBm', minval=-5, maxval=30, flags=Instrument.FLAG_GETSET, type=types.FloatType)
        self.add_parameter('time_delay_for_phase', units= 'ns', flags = Instrument.FLAG_GETSET, type=types.FloatType)

        # Defining some stuff
        self._instruments = instruments.get_instruments()
        self._spectrum = self._instruments.get(spectrum)
        self._pulser = self._instruments.get(pulser)

        self._microwave_generator = self._instruments.get(mwsrc_read_out)

        #Default detuning [MHz]
        self._detuning = 0

        #We initialize the card
        #Number of segments
        self._nums=nums
        #We don't want to record data before the trigger so, we put the posttrigger time equal to the segment size
        #We initialize the card on two channel multiple recording mode
        self._spectrum.init_channel01_multiple_recording(nums=self._nums, segsize=segsize, posttrigger=segsize-8, amp0=amp0, amp1=amp1)
#                       init_channel0_multiple_recording(self, nums = 4, segsize=10
# 24, posttrigger=768, amp=500, offs=0):
#        self._spectrum.init_channel0_multiple_recording(nums=self._nums, segsize=segsize, posttrigger=segsize-8,amp=amp0)

        # we put the spectrum as ext ref clock mode:
        self._spectrum.set_CM_extrefclock() # added by Remy


        #We initialize the trigger pulse for the board
        self._pulser.set_chB_status('OFF')
        self._pulser.set_chB_polarity('POS')
        self._pulser.set_chB_width(50)
        self._pulser.set_chB_delay(0.)
        self._pulser.set_chB_status('ON')
        self.time_phase_delay = 0.

        self.get_all()
    def __init__(self, name, awg, channel, mwsrc):
        '''
            Initialize the virtual instruments

                Input:
                    - name (string): Name of the virtual instruments
                    - awg (string): Name of a awg
                    - channel (int): channel number of the awg
                    - mwsrc (string): Name of to the microwave generator

                Output:
                    None
        '''
        Instrument.__init__(self, name, tags=['virtual'])

        #Import instruments
        self._instruments = instruments.get_instruments()
        self._awg = self._instruments.get(awg)
        self._mwsrc = self._instruments.get(mwsrc)

        if not channel in (1, 2, 3, 4):
            raise ValueError(
                'The channel of the awg should be between 1 and for')
        self._channel = int(channel)

        # Default parameters
        self._duration = 50  # In ns
        self._delay = 50  # In ns

        self._awg.set_ref_source('EXT')
        self._awg.set_ref_freq(10)

        self._awg.set_func_mode('SEQ')
        self._awg.seq_mode('STEP')
        self._awg.seq_jump_source('BUS')
        self._awg.set_trace_mode('SING')
        self._awg.set_clock_freq(1e3)

        self._awg.set_run_mode('TRIG')
        self._awg.set_trigger_mode('NORM')
        self._awg.set_trigger_source('TIM')
        self._awg.set_trigger_timer_mode('TIME')
        self._awg.set_channels_synchronised('ON')
        self._awg.set_trigger_timer_time(100)
        self._awg.init_channel(self._channel)
        self._gaussian()

        #Parameters
        self.add_parameter(
            'duration',
            flags=Instrument.FLAG_GETSET,
            minval=0.,
            # maxval = self._max_width,
            units='ns',
            type=types.FloatType)

        self.add_parameter(
            'delay',
            flags=Instrument.FLAG_GETSET,
            minval=0,
            #    maxval=1e10,
            units='ns',
            type=types.FloatType)

        min_freq = 1e-9 * self._mwsrc.get_parameter_options(
            'frequency')['minval']
        max_freq = 1e-9 * self._mwsrc.get_parameter_options(
            'frequency')['maxval']
        self.add_parameter('frequency',
                           flags=Instrument.FLAG_GETSET,
                           units='GHz',
                           minval=min_freq,
                           maxval=max_freq,
                           type=types.FloatType)

        min_power = self._mwsrc.get_parameter_options('power')['minval']
        max_power = self._mwsrc.get_parameter_options('power')['maxval']
        self.add_parameter('power',
                           flags=Instrument.FLAG_GETSET,
                           minval=min_power,
                           maxval=max_power,
                           units='dBm',
                           type=types.FloatType)

        self.add_parameter('status',
                           option_list=['ON', 'OFF'],
                           flags=Instrument.FLAG_GETSET,
                           type=types.StringType)

        self.set_status('OFF')
        self._mwsrc.set_status('ON')
        #Functions
        self.get_all()
Esempio n. 19
0
    def __init__(self, name, igh=None):
        Instrument.__init__(self, name, tags=['virtual'])

        self._instruments = instruments.get_instruments()
        self._igh = self._instruments.get(igh)

        self.add_parameter('timeout',
                           type=types.FloatType,
                           flags=Instrument.FLAG_GETSET,
                           units='sec')
        self.add_parameter('idle_mintime',
                           type=types.FloatType,
                           flags=Instrument.FLAG_GETSET,
                           units='sec')
        self.add_parameter('slow_mintime',
                           type=types.FloatType,
                           flags=Instrument.FLAG_GETSET,
                           units='sec')
        self.add_parameter('disk_mintime',
                           type=types.FloatType,
                           flags=Instrument.FLAG_GETSET,
                           units='sec')
        self.add_parameter('timeout_mode',
                           type=types.BooleanType,
                           flags=Instrument.FLAG_GET)
        self.add_parameter('idle_mode',
                           type=types.BooleanType,
                           flags=Instrument.FLAG_GET)
        self.add_parameter('plot_enable',
                           type=types.BooleanType,
                           flags=Instrument.FLAG_GET)
        self.add_parameter('status',
                           type=types.StringType,
                           flags=Instrument.FLAG_GET)

        self.add_function('start')
        self.add_function('stop')
        self.add_function('plot_start')
        self.add_function('plot_stop')
        self.add_function('set_default_fast')
        self.add_function('set_default_slow')

        self._debug_counter = 0

        self._timeout = 10
        self._idle_mintime = 10
        self._slow_mintime = 300
        self._disk_mintime = 10

        self._slow_lasttime = 0
        self._disk_lasttime = 0

        self.plot_stop()

        self._dir = os.path.join(qt.config.get('datadir'), 'Tlog')
        self._filebasename = 'temperature_log'
        self._this_month = None

        if not os.path.isdir(self._dir):
            os.makedirs(self._dir)

        self._last_hour = TimeBuffer(60 * 60, self._dir, 'last_hour.dat')
        self._last_12hour = TimeBuffer(60 * 60 * 12, self._dir,
                                       'last_12hour.dat')

        self._task = Scheduler(self._run_all,
                               self._timeout,
                               self._idle_mintime,
                               timeout_mode=True,
                               idle_mode=True)
        self._status = 'running'

        self.get_all()
    def __init__(self, name, awg, channel, conversion = 1, dt = 0, pulsedef=None, amplitude=2.0,\
                                                            offset=0.0, pulser=None, cardnr=None):
        '''
        awg has following properties:

        baseline offset
        
        multiple plateaus with each:

        start time
        ramp time
        ramp type
        height of plateau


        ending with:
        fall time
        fall type


        think about:
        channels
        '''
        Instrument.__init__(self, name, tags=['virtual'])
        
        # Defining some stuff 
        self._instruments = instruments.get_instruments()
        self._awg = self._instruments.get(awg)
        self._channel = channel
        self._clock = self._awg.get_clock()
        self._numpoints = self._awg.get_numpoints()
        self._amplitude = amplitude #FIXME ugly use of variables _amplitude and _offset
        self._offset = offset
        self._filename = 'ch%d.wfm' % self._channel
        
        #pulser
        self._pulser = self._instruments.get(pulser)
        self._cardnr = cardnr
        
#        self._npulse = 0 # Number of pulses in the bursts
#        self._period = 0 # Sequence period
#        self._plen = 0 # Length of a pulse in the burst
        
        self.add_parameter('delay',
                type=types.FloatType,
                flags=Instrument.FLAG_GETSET,
                units='ns')
        self.add_parameter('period',
            type=types.FloatType,
            flags=Instrument.FLAG_GETSET | Instrument.FLAG_GET_AFTER_SET,
            units='ns')
        self.add_parameter('pulse_length',
            type=types.FloatType,
            flags=Instrument.FLAG_GETSET | Instrument.FLAG_GET_AFTER_SET,
            units='ns')
                
        self.add_parameter('conversion',
                type=types.FloatType,
                flags=Instrument.FLAG_GET,
                units=' ')
        self._conversion = conversion  #Conversion factor to universal mV
        self.get_conversion()
        
        self.add_parameter('dt',
                type=types.FloatType,
                flags=Instrument.FLAG_GET,
                units='ns')
        self._dt = dt  #dt to universal zero
        self.get_dt()
        
        # Add parameters
        self.add_parameter('awg_amplitude', type=types.FloatType,
            flags=Instrument.FLAG_GETSET | Instrument.FLAG_GET_AFTER_SET,
            units='V')
        self.add_parameter('awg_offset', type=types.FloatType,
            flags=Instrument.FLAG_GETSET | Instrument.FLAG_GET_AFTER_SET,
            units='V')
        self.add_parameter('awg_status', type=types.StringType,
            flags=Instrument.FLAG_GETSET | Instrument.FLAG_GET_AFTER_SET)

        self.add_parameter('baselevel', type=types.FloatType,
            flags=Instrument.FLAG_GETSET | Instrument.FLAG_GET_AFTER_SET,
            units='mV')
        self.add_parameter('starttime', type=types.FloatType,
            flags=Instrument.FLAG_GETSET | Instrument.FLAG_GET_AFTER_SET,
            units='ns')
        self.add_parameter('risetime', type=types.FloatType,
            flags=Instrument.FLAG_GETSET | Instrument.FLAG_GET_AFTER_SET,
            units='ns')
        self.add_parameter('risetype', type=types.StringType,
            flags=Instrument.FLAG_GETSET | Instrument.FLAG_GET_AFTER_SET)

        self.add_parameter('level', type=types.FloatType,
            flags=Instrument.FLAG_GETSET | Instrument.FLAG_GET_AFTER_SET,
            units='mV')
        self.add_parameter('level0', type=types.FloatType,
            flags=Instrument.FLAG_GETSET | Instrument.FLAG_GET_AFTER_SET,
            units='mV')
        self.add_parameter('length', type=types.FloatType,
            flags=Instrument.FLAG_GETSET | Instrument.FLAG_GET_AFTER_SET,
            units='ns')
        self.add_parameter('falltime', type=types.FloatType,
            flags=Instrument.FLAG_GETSET | Instrument.FLAG_GET_AFTER_SET,
            units='ns')
        self.add_parameter('falltype', type=types.StringType,
            flags=Instrument.FLAG_GETSET | Instrument.FLAG_GET_AFTER_SET)

        # Initializing AWG Channel
        w = AWG520_wfms.Channel_Zeros(self._numpoints)
        m1 = AWG520_wfms.Marker_Zeros(self._numpoints)
        m2 = AWG520_wfms.Marker_Zeros(self._numpoints)

        self._awg.send_waveform(w,m1,m2,self._filename, self._clock)
        self._awg.set('ch%d_filename' % self._channel, self._filename)
        self.set_awg_amplitude(amplitude)
        self.set_awg_offset(offset)

        if pulsedef is not None:
            self.set_pulsedef(pulsedef)

        self.get_all()
Esempio n. 21
0
    def __init__(self, name, igh=None):
        Instrument.__init__(self, name, tags=['virtual'])

        self._instruments = instruments.get_instruments()
        self._igh = self._instruments.get(igh)

        self.add_parameter('timeout',
                type=types.FloatType,
                flags=Instrument.FLAG_GETSET,
                units='sec')
        self.add_parameter('idle_mintime',
                type=types.FloatType,
                flags=Instrument.FLAG_GETSET,
                units='sec')
        self.add_parameter('slow_mintime',
                type=types.FloatType,
                flags=Instrument.FLAG_GETSET,
                units='sec')
        self.add_parameter('disk_mintime',
                type=types.FloatType,
                flags=Instrument.FLAG_GETSET,
                units='sec')
        self.add_parameter('timeout_mode',
                type=types.BooleanType,
                flags=Instrument.FLAG_GET)
        self.add_parameter('idle_mode',
                type=types.BooleanType,
                flags=Instrument.FLAG_GET)
        self.add_parameter('plot_enable',
                type=types.BooleanType,
                flags=Instrument.FLAG_GET)
        self.add_parameter('status',
                type=types.StringType,
                flags=Instrument.FLAG_GET)

        self.add_function('start')
        self.add_function('stop')
        self.add_function('plot_start')
        self.add_function('plot_stop')
        self.add_function('set_default_fast')
        self.add_function('set_default_slow')

        self._debug_counter = 0

        self._timeout = 10
        self._idle_mintime = 10
        self._slow_mintime = 300
        self._disk_mintime = 10

        self._slow_lasttime = 0
        self._disk_lasttime = 0

        self.plot_stop()

        self._dir = os.path.join(qt.config.get('datadir'), 'Tlog')
        self._filebasename = 'temperature_log'
        self._this_month = None

        if not os.path.isdir(self._dir):
            os.makedirs(self._dir)

        self._last_hour = TimeBuffer(60*60, self._dir, 'last_hour.dat')
        self._last_12hour = TimeBuffer(60*60*12, self._dir, 'last_12hour.dat')

        self._task = Scheduler(self._run_all, self._timeout, self._idle_mintime, timeout_mode=True, idle_mode=True)
        self._status = 'running'

        self.get_all()
    def __init__(self, name, pulser, ch, mwsrc, period):
        '''
            Initialize the virtual instruments
                
                Input:
                    - name: Name of the virtual instruments
                    - pulser: Name of a delay generator (set_ch%c_width and set_ch%c_wdelay methods are required)
                    - channel: channel name of the delay generator
                    - mwsrc: Name given to the microwave_generator
                
                Output:
                    None
        '''
        Instrument.__init__(self, name, tags=['virtual'])
        
        #Import instruments
        self._instruments = instruments.get_instruments()
        self._pulser = self._instruments.get(pulser)
        self._period = self._instruments.get(period)
        self._ch = ch
        self._microwave_generator = self._instruments.get(mwsrc)
        self._pulser.set('ch%c_polarity'%self._ch,'POS')
        self._microwave_generator.set_status('ON')
        
        #Fetching parameter bounds
        self._max_power = self._microwave_generator.get_parameter_options('power')['maxval']
        
        try:
            self._min_power = self._microwave_generator.get_parameter_options('power')['minval']
        except Exception as error:
            self._min_power = -145.0
        self._max_freq = 1e-9*self._microwave_generator.get_parameter_options('frequency')['maxval']
        self._min_freq = 1e-9*self._microwave_generator.get_parameter_options('frequency')['minval']
        self._max_width = self._pulser.get_parameter_options('ch%c_width'%self._ch)['maxval']
        self._min_width = self._pulser.get_parameter_options('ch%c_width'%self._ch)['minval']
        
        #Parameters
        self.add_parameter('width',
                            flags=Instrument.FLAG_GETSET, 
                            minval=self._min_width,
                            maxval=self._max_width,
                            units='ns', 
                            type=types.FloatType)
#        self.add_parameter('delay', 
#                            flags=Instrument.FLAG_GETSET, 
#                            minval=0,
#                            maxval=1e10,
#                            units='ns', 
#                            type=types.FloatType)
        
        self.add_parameter('frequency', 
                            flags=Instrument.FLAG_GETSET, 
                            units='GHz', 
                            minval = self._min_freq, 
                            maxval= self._max_freq, 
                            type=types.FloatType)
                            
        self.add_parameter('power', 
                            flags=Instrument.FLAG_GETSET, 
                            minval = self._min_power, 
                            maxval= self._max_power, 
                            units='dBm', 
                            type=types.FloatType)

        self.add_parameter('status', option_list=['ON', 'OFF'], flags=Instrument.FLAG_GETSET, type=types.StringType)


        #Functions
        self.get_all()
    def __init__(self, name, spectrum, mwsrc_read_out, nums=128, segsize= 2048, amp0=500, amp1=500):
        '''
            Initialize the virtual instruments
                
                Input:
                    name            : Name of the virtual instruments
                    spectrum        : Name given to the Spectrum M3i4142
                    nums (int)      : number of consequtive measurements
                                        default = 128
                            
                    segsize (int)   : Size of the memory allocated in the card [Sample]
                                        default = 2048
                                        
                    amp0 (int)      : half of the range of the channel 0 [mV]
                                        default = 500
                                        
                    amp1 (int)      : half of the range of the channel 1 [mV]
                                        default = 500
                
                Output:
                    None
        '''
        
        Instrument.__init__(self, name, tags=['virtual'])
        
        
        self.add_parameter('input_term_ch0', option_list=['50', '1 M'], units='Ω', flags=Instrument.FLAG_GETSET, type=types.StringType)
        self.add_parameter('input_term_ch1', option_list=['50', '1 M'], units='Ω', flags=Instrument.FLAG_GETSET, type=types.StringType)

        self.add_parameter('input_amp_ch0', option_list=[200, 500, 1000, 2000, 5000, 10000], units='mV', flags=Instrument.FLAG_GETSET, type=types.IntType, default=200)
        self.add_parameter('input_amp_ch1', option_list=[200, 500, 1000, 2000, 5000, 10000], units='mV', flags=Instrument.FLAG_GETSET, type=types.IntType, default=200)
        
        #The maxvalue of the samplerate is only of 250 MS.Hz because we use the two channels of the board
        self.add_parameter('samplerate', units='MS.Hz', maxval=400, flags=Instrument.FLAG_GETSET, type=types.IntType)
        self.add_parameter('segmentsize', minval=16, units='S', flags=Instrument.FLAG_GETSET, type=types.IntType)
        self.add_parameter('repetitions', minval=1, flags=Instrument.FLAG_GETSET, type=types.IntType)
#        self.add_parameter('acquisitionTime', units='ms', flags=Instrument.FLAG_GET, type=types.FloatType)
        self.add_parameter('bandwidth', units='Hz', option_list=[10, 100, 1000, 10000, 100000], flags=Instrument.FLAG_GET, type=types.FloatType)
        self.add_parameter('status', flags=Instrument.FLAG_GETSET, option_list=['on', 'off'], type=types.StringType)
#        self.add_parameter('detuning', units='MHz', flags=Instrument.FLAG_GETSET, type=types.FloatType)
        self.add_parameter('startfrequency', units='GHz', minval=100e-6, maxval=12.75, flags=Instrument.FLAG_GETSET, type=types.FloatType)
        self.add_parameter('stopfrequency', units='GHz', minval=100e-6, maxval=12.75, flags=Instrument.FLAG_GETSET, type=types.FloatType)
        self.add_parameter('numsteps', units='', minval=1, maxval=10**5+1, flags=Instrument.FLAG_GETSET, type=types.FloatType)
        self.add_parameter('power', units='dBm', minval=-20, maxval=30, flags=Instrument.FLAG_GETSET, type=types.FloatType)
        self.add_parameter('averages', units='', minval=1, maxval=10**6, flags=Instrument.FLAG_GETSET, type=types.FloatType)
        
        # Defining some stuff
        self._instruments = instruments.get_instruments()
        self._spectrum = self._instruments.get(spectrum)
        
        self._microwave_generator = self._instruments.get(mwsrc_read_out)

        self._spectrum.set_input_amp_ch0(200)
        self._spectrum.set_input_amp_ch1(200)
        self._spectrum.set_input_term_ch0('50')
        self._spectrum.set_input_term_ch1('50')
#        self._spectrum.set_pretrigger(8)
        #Default detuning [MHz]
#        self._detuning = 0
        
        #We initialize the card
        #Number of segments
        self._nums=nums
        #We don't want to record data before the trigger so, we put the posttrigger time equal to the segment size
        #We initialize the card on two channel multiple recording mode
        #self._spectrum.init_channel01_multiple_recording(nums=self._nums, segsize=segsize, posttrigger=segsize-8,amp0=amp0,amp1=amp1)

        
        self.get_all()
    def __init__(self, name, spectrum, mwsrc_read_out, memsize= 8008, amp0=500, amp1=500):
        '''
            Initialize the virtual instruments
                
                Input:
                    name:                       Name of the virtual instruments
                    spectrum:                   Name given to the Spectrum M3i4142

                    
                    memsize (sample):           Size of the memory allocated in the card [Sample]
                                                default = 8008
                                        
                    amp0 (int)                  : half of the range of the channel 0 [mV]
                                                default = 500
                                        
                    amp1 (int)                  : half of the range of the channel 1 [mV]
                                                default = 500
                
                Output:
                    None
        '''
        
        Instrument.__init__(self, name, tags=['virtual'])
        
        
        self.add_parameter('input_term_ch0', option_list=['50', '1 M'], units='Ω', flags=Instrument.FLAG_GETSET, type=types.StringType)
        self.add_parameter('input_term_ch1', option_list=['50', '1 M'], units='Ω', flags=Instrument.FLAG_GETSET, type=types.StringType)

        self.add_parameter('input_amp_ch0', option_list=[200, 500, 1000, 2000, 5000, 10000], units='mV', flags=Instrument.FLAG_GETSET, type=types.IntType)
        self.add_parameter('input_amp_ch1', option_list=[200, 500, 1000, 2000, 5000, 10000], units='mV', flags=Instrument.FLAG_GETSET, type=types.IntType)
        
        #The maxvalue of the samplerate is only of 250 MS.Hz because we use the two channels of the board
        self.add_parameter('samplerate', units='MS.Hz', maxval=400, flags=Instrument.FLAG_GETSET, type=types.IntType)

        self.add_parameter('numberSample', minval=16, units='S', flags=Instrument.FLAG_GETSET, type=types.IntType)
        
        self.add_parameter('acquisitionTime', units='ms', flags=Instrument.FLAG_GET, type=types.FloatType)
        self.add_parameter('bandWidth', units='Hz', flags=Instrument.FLAG_GET, type=types.FloatType)


        self.add_parameter('status', flags=Instrument.FLAG_GETSET, option_list=['on', 'off'], type=types.StringType)
        self.add_parameter('detuning', units='MHz', flags=Instrument.FLAG_GETSET, type=types.FloatType)
        self.add_parameter('frequency', units='GHz', minval=100e-6, maxval=12.75, flags=Instrument.FLAG_GETSET, type=types.FloatType)
        self.add_parameter('power', units='dBm', minval=-20, maxval=30, flags=Instrument.FLAG_GETSET, type=types.FloatType)

        
        # Defining some stuff
        self._instruments = instruments.get_instruments()
        self._spectrum = self._instruments.get(spectrum)
        
        self._microwave_generator = self._instruments.get(mwsrc_read_out)
        
        #Default detuning [MHz]
        self.detuning = 0
        
        #We initialize the card
        #The memory size is in sample
        self.memsize = memsize
        
        #We don't want to record data before the trigger so, we put the posttrigger time equal to the total memory size
        self.posttrigger = self.memsize

        #We initialize the card on two channel single mode
        self._spectrum.init_channel01_single_mode(int(self._spectrum.get_memsize()), int(self._spectrum.get_post_trigger()),amp0= int(self._spectrum.get_input_amp_ch0()),amp1 = int(self._spectrum.get_input_amp_ch1()) )

        
        self.get_all()
Esempio n. 25
0
File: qt.py Progetto: Chrede88/qtlab
# Global namespace

import os
import sys
from qtflow import get_flowcontrol
from instruments import get_instruments
from lib import config as _config
from data import Data
from scripts import Scripts, Script

config = _config.get_config()

data = Data.get_named_list()
instruments = get_instruments()
frontpanels = {}
sliders = {}
scripts = Scripts()

flow = get_flowcontrol()
msleep = flow.measurement_idle
mstart = flow.measurement_start
mend = flow.measurement_end

def version():
    version_file = os.path.join(config['execdir'], 'VERSION')
    try:
        f = file(version_file,'r')
        str = f.readline()
        str = str.rstrip('\n\r')
        f.close()
    except:
Esempio n. 26
0
    def __init__(self, name, mwsrc1, ssb1, redpitaya, mwsrc2='None', ssb2='None'):

        # -------------------------------------------------------------------------------------------------------------#
        # -----------------------------------    Importation of the device    -----------------------------------------#
        # -------------------------------------------------------------------------------------------------------------#
        
        Instrument.__init__(self, name, tags=['virtual'])
        self._instruments = instruments.get_instruments()
        self._SSB_tone1 = self._instruments.get(ssb1)
        self._microwave_generator1 = self._instruments.get(mwsrc1)
        # self._microwave_generator1.set_status('ON')
        # self._microwave_generator1.set_power(-30)
        
        self._redpitaya = self._instruments.get(redpitaya)



        # if we import the second microwave generator or not
        if mwsrc2 != 'None':
            self._presence_mwsrc2 = 1
            self._microwave_generator2 = self._instruments.get(mwsrc2)
            # self._microwave_generator2.set_status('ON')
        else:
            self._presence_mwsrc2 = 0
        # if we import the second ssb or not
        if ssb2 != 'None':
            self._presence_ssb2 = 1
            self._SSB_tone2 = self._instruments.get(ssb2)
        else:
            self._presence_ssb2 = 0

        # # -------------------------------------------------------------------------------------------------------------#
        # # ----------------------------------    Creation of the parameters    -----------------------------------------#
        # # -------------------------------------------------------------------------------------------------------------#

        self.add_parameter('power_first_tone',
                           flags=Instrument.FLAG_GETSET,
                           minval=-50.,
                           maxval=4.,
                           units='dBm',
                           type=types.FloatType)
        self.add_parameter('power_second_tone',
                           flags=Instrument.FLAG_GETSET,
                           minval=-50.,
                           maxval=4.,
                           units='dBm',
                           type=types.FloatType)
        self.add_parameter('cw_frequency',
                           flags=Instrument.FLAG_GETSET,
                           units='GHz',
                           minval=1e-4,
                           maxval=40,
                           type=types.FloatType,
                           channels=(1, 2),
                           channel_prefix='src%d_')
        self.add_parameter('ro_pulse_duration',
                           flags=Instrument.FLAG_GETSET,
                           units='s',
                           minval=8e-9,
                           maxval=64e-6,
                           type=types.FloatType)
        self.add_parameter('ro_pulse_amplitude',
                           flags=Instrument.FLAG_GETSET,
                           units='Volt',
                           minval=0,
                           maxval=1,
                           type=types.FloatType)
        self.add_parameter('ro_pulse_frequency',
                           flags=Instrument.FLAG_GETSET,
                           units='Hz',
                           minval=0,
                           maxval=1./8e-9,
                           type=types.FloatType)
        self.add_parameter('ro_pulse_delay_trigger',
                           flags=Instrument.FLAG_GETSET,
                           units='s',
                           minval=0,
                           maxval=64e-6,
                           type=types.FloatType)
        self.add_parameter('ro_pulse_delay_IQ',
                           flags=Instrument.FLAG_GETSET,
                           units='s',
                           minval=0,
                           maxval=64e-6,
                           type=types.FloatType)
        self.add_parameter('period',
                           flags=Instrument.FLAG_GETSET,
                           units='s',
                           minval=8e-9,
                           maxval=1,
                           type=types.FloatType)
        self.add_parameter('frequency_start',
                           flags=Instrument.FLAG_SET,
                           units='GHz',
                           minval=1e-4,
                           maxval=40,
                           type=types.FloatType,
                           channels=(1, 2),
                           channel_prefix='src%d_')
        self.add_parameter('frequency_stop',
                           flags=Instrument.FLAG_SET,
                           units='Hz',
                           minval=1e-4,
                           maxval=40,
                           channels=(1, 2),
                           channel_prefix='src%d_',
                           type=types.FloatType)
        self.add_parameter('frequency_points',
                           flags=Instrument.FLAG_SET,
                           units='%',
                           minval=1,
                           maxval=10000000,
                           channels=(1, 2),
                           channel_prefix='src%d_',
                           type=types.FloatType)
                           
                           
        # Initializing parameters
        
        self.set_ro_pulse_duration(1e-6) # Hz
        self.set_ro_pulse_amplitude(0.5) # V 
        self.set_ro_pulse_frequency(31.25e6) # Hz
        self.set_ro_pulse_delay_trigger(0e-9) # s
        self.set_ro_pulse_delay_IQ(200e-9) # s 
        
        self._time_loop = 0.5 # s
        self._nb_point_int_max = 7000
        self._period_min = 64e-6 # s
        self.set_period(self._period_min)
        
        if self._presence_mwsrc2:
            self._microwave_generator1.set_freqsweep('off')
            self._microwave_generator2.set_freqsweep('on')
            self._microwave_generator2.set_sweepmode('STEP')
            self._microwave_generator2.set_spacingfreq('lin')
            # !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
            self._microwave_generator1.set_gui_update('ON')
            self._microwave_generator2.set_gui_update('ON')
        else:
            self._microwave_generator1.set_freqsweep('on')
            self._microwave_generator1.set_sweepmode('STEP')
            self._microwave_generator1.set_spacingfreq('lin')
            # !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
            self._microwave_generator1.set_gui_update('ON')
        self._redpitaya.reset_LUT()
    def __init__(self, name):
        '''
        Initialize the virtual instrument

            Input:
                - name: Name of the virtual instruments
            Output:
                None
        '''
        # No real Instrument here ...
        Instrument.__init__(self, name, tags=['virtual'])
        # #Import instruments
        self._instruments = instruments.get_instruments()

        ########################################################################
        #                    parameters
        ########################################################################
        # GET_SET
        self.add_parameter('freq_start',
                           flags=Instrument.FLAG_GETSET,
                           units='GHz',
                           minval=1e-4,
                           maxval=40,
                           type=types.FloatType)

        self.add_parameter('freq_stop',
                           flags=Instrument.FLAG_GETSET,
                           units='GHz',
                           minval=1e-4,
                           maxval=40,
                           type=types.FloatType)

        self.add_parameter('conversion_loss',
                           flags=Instrument.FLAG_GETSET,
                           units='dB',
                           type=types.FloatType)

        self.add_parameter('band_type',
                           flags=Instrument.FLAG_GETSET,
                           option_list=[-1, +1],
                           type=types.FloatType)

        self.add_parameter('LO_power',
                           flags=Instrument.FLAG_GETSET,
                           units='dBm',
                           option_list=(5., 15.),
                           type=types.FloatType)

        self.add_parameter(
            'IF_frequency',
            flags=Instrument.FLAG_GETSET,
            units='GHz',
            # minval = 1e-4,
            # maxval= 0.5,
            type=types.FloatType)

        self._freqstart = 4.
        self._freqstop = 8.
        self._conversionloss = 6.
        self._LOpower = 5.
        self._bandtype = -1
        self._IFfreq = 0.08
    def __init__(self, name, awg, channel, mwsrc):
        '''
            Initialize the virtual instruments

                Input:
                    - name (string): Name of the virtual instruments
                    - awg (string): Name of a awg
                    - channel (int): channel number of the awg
                    - mwsrc (string): Name of to the microwave generator

                Output:
                    None
        '''
        Instrument.__init__(self, name, tags=['virtual'])

        #Import instruments
        self._instruments = instruments.get_instruments()
        self._awg         = self._instruments.get(awg)
        self._mwsrc       = self._instruments.get(mwsrc)

        if not channel in (1, 2, 3, 4):
            raise ValueError('The channel of the awg should be between 1 and for')
        self._channel     = int(channel)

        # Default parameters
        self._duration = 50 # In ns
        self._delay    = 50 # In ns


        self._awg.set_ref_source('EXT')
        self._awg.set_ref_freq(10)

        self._awg.set_func_mode('SEQ')
        self._awg.seq_mode('STEP')
        self._awg.seq_jump_source('BUS')
        self._awg.set_trace_mode('SING')
        self._awg.set_clock_freq(1e3)

        self._awg.set_run_mode('TRIG')
        self._awg.set_trigger_mode('NORM')
        self._awg.set_trigger_source('TIM')
        self._awg.set_trigger_timer_mode('TIME')
        self._awg.set_channels_synchronised('ON')
        self._awg.set_trigger_timer_time(100)
        self._awg.init_channel(self._channel)
        self._gaussian()

        #Parameters
        self.add_parameter('duration',
                            flags  = Instrument.FLAG_GETSET,
                            minval = 0.,
                            # maxval = self._max_width,
                            units  = 'ns',
                            type   = types.FloatType)

        self.add_parameter('delay',
                           flags=Instrument.FLAG_GETSET,
                           minval=0,
                        #    maxval=1e10,
                           units='ns',
                           type=types.FloatType)

        min_freq = 1e-9*self._mwsrc.get_parameter_options('frequency')['minval']
        max_freq = 1e-9*self._mwsrc.get_parameter_options('frequency')['maxval']
        self.add_parameter('frequency',
                           flags  = Instrument.FLAG_GETSET,
                           units  = 'GHz',
                           minval = min_freq,
                           maxval = max_freq,
                           type   = types.FloatType)

        min_power = self._mwsrc.get_parameter_options('power')['minval']
        max_power = self._mwsrc.get_parameter_options('power')['maxval']
        self.add_parameter('power',
                            flags  = Instrument.FLAG_GETSET,
                            minval = min_power,
                            maxval = max_power,
                            units  = 'dBm',
                            type   = types.FloatType)

        self.add_parameter('status',
                           option_list = ['ON', 'OFF'],
                           flags       = Instrument.FLAG_GETSET,
                           type        = types.StringType)



        self.set_status('OFF')
        self._mwsrc.set_status('ON')
        #Functions
        self.get_all()