Ejemplo n.º 1
0
    def add_marker_parameters(self):
        # Each (module, channel) separately
        for mod in self.modules:
            mod_name = 'mod{m}'.format(m=mod)
            mod_scpi = 'MODULE{m}'.format(m=mod)

            doc_source = 'Marker source of module {m}.'.format(m=mod)
            self.add_parameter(mod_name + '_marker_source',
                               docstring=doc_source,
                               get_cmd='MARKER:' + mod_scpi + ':SOURCE?',
                               set_cmd='MARKER:' + mod_scpi + ':SOURCE {}',
                               vals=validators.Enum('int', 'ext'))

            for channel in self.channels:
                mod_ch_name = 'mod{m}_ch{c}'.format(m=mod, c=channel)
                mod_ch_scpi = 'MODULE{m}:CHANNEL{c}'.format(m=mod, c=channel)
                doc_state = 'Marker state of module {m}, ' \
                            'channel {c}.'.format(m=mod, c=channel)
                self.add_parameter(mod_ch_name + '_marker_state',
                                   docstring=doc_state,
                                   get_cmd='MARKER:' + mod_ch_scpi + ':STATE?',
                                   set_cmd='MARKER:' + mod_ch_scpi +
                                   ':STATE {}',
                                   vals=validators.OnOff())

        # Marker breakout board
        self.add_parameter('mbbc_state',
                           docstring='Whether the _marker breakout board_ is '
                           'connected to the VSM.',
                           get_cmd='MBBC?',
                           vals=validators.Enum('connected', 'disconnected'))
    def add_qubit_parameters(self):
        # Qubit attributes are set per channel row (so all modules in one go)
        for channel in self.channels:
            ch_name = '_ch{c}'.format(c=channel)
            ch_scpi = ':CHANNEL{c}'.format(c=channel)

            doc_description = 'Qubit description on display ' \
                              'for row {c}'.format(c=channel)
            self.add_parameter('qubit' + ch_name + '_description',
                               docstring=doc_description,
                               get_cmd='QUBIT' + ch_scpi + ':DESCRIPTION?',
                               set_cmd='QUBIT' + ch_scpi + ':DESCRIPTION {}',
                               vals=validators.Strings())

            doc_frequency = 'Qubit frequency in Hz for row {c}. ' \
                            'Range 4.0E9--8.0E9 Hz.'.format(c=channel)
            self.add_parameter('qubit' + ch_name + '_frequency',
                               docstring=doc_frequency,
                               unit='Hz',
                               get_cmd='QUBIT' + ch_scpi + ':FREQUENCY?',
                               set_cmd='QUBIT' + ch_scpi + ':FREQUENCY {}',
                               vals=validators.Numbers(),
                               get_parser=float)

            colors = ', '.join([
                'black', 'blue', 'green', 'grey', 'orange', 'red', 'white',
                'yellow', 'dcl_blue', 'dcl_green', 'dcl_red', 'dcl_violet'
            ])
            doc_color = 'Qubit led and display color for row {c}. ' \
                        'Can either be one of the predefined colors ({lst})' \
                        'or a RGB hex string like "#rrggbb".'.format(c=channel,
                                                                     lst=colors)

            self.add_parameter('qubit' + ch_name + '_led_color',
                               docstring=doc_color,
                               get_cmd='QUBIT' + ch_scpi + ':LEDCOLOR?',
                               set_cmd='QUBIT' + ch_scpi + ':LEDCOLOR {}',
                               vals=validators.Strings())

            # Individual channels can be switched on or off
            for mod in self.modules:
                mod_ch_name = '_mod{m}_ch{c}'.format(m=mod, c=channel)
                mod_ch_scpi = ':MODULE{m}:CHANNEL{c}'.format(m=mod, c=channel)

                doc_on_off = 'On/off state for channel {c} of ' \
                             'module {m}'.format(m=mod, c=channel)
                self.add_parameter('qubit' + mod_ch_name,
                                   docstring=doc_on_off,
                                   get_cmd='QUBIT' + mod_ch_scpi + '?',
                                   set_cmd='QUBIT' + mod_ch_scpi + ' {}',
                                   vals=validators.OnOff())
Ejemplo n.º 3
0
    def __init__(self, parent: 'DG1062', name: str, channel: int) -> None:
        """
        Args:
            parent: The instrument this channel belongs to
            name (str)
            channel (int)
        """

        super().__init__(parent, name)
        self.channel = channel

        for param, unit in [("freq", "Hz"), ("ampl", "V"), ("offset", "V"),
                            ("phase", "deg"), ("sample_rate", "1/s")]:
            self.add_parameter(
                param,
                unit=unit,
                get_cmd=partial(self._get_waveform_param, param),
                set_cmd=partial(self._set_waveform_param, param),
            )

        self.add_parameter("waveform",
                           get_cmd=partial(self._get_waveform_param,
                                           "waveform"))

        self.add_parameter(
            "impedance",
            get_cmd=f":OUTPUT{channel}:IMP?",
            set_cmd=f":OUTPUT{channel}:IMP {{}}",
            unit="Ohm",
            vals=vals.MultiType(
                vals.Ints(min_value=DG1062Channel.min_impedance,
                          max_value=DG1062Channel.max_impedance),
                vals.Enum("INF", "MIN", "MAX", "HighZ")),
            get_parser=(lambda value: "HighZ" if float(value) > DG1062Channel.
                        max_impedance else float(value)),
            set_parser=lambda value: "INF" if value == "HighZ" else value)

        self.add_parameter(
            "sync",
            get_cmd=f":OUTPUT{channel}:SYNC?",
            set_cmd=f"OUTPUT{channel}:SYNC {{}}",
            vals=vals.Enum(0, 1, "ON", "OFF"),
        )

        self.add_parameter(
            "polarity",
            get_cmd=f":OUTPUT{channel}:GAT:POL?",
            set_cmd=f":OUTPUT{channel}:GAT:POL {{}}",
            vals=vals.OnOff(),
            val_mapping={
                1: 'POSITIVE',
                0: 'NEGATIVE'
            },
        )

        self.add_parameter(
            "state",
            get_cmd=f"OUTPUT{channel}:STATE?",
            set_cmd=f"OUTPUT{channel}:STATE {{}}",
        )

        self.add_parameter("duty_cycle",
                           get_cmd=self._get_duty_cycle,
                           set_cmd=self._set_duty_cycle,
                           unit="%",
                           vals=vals.Numbers(min_value=1, max_value=99),
                           docstring=('This functions reads/sets the duty '
                                      'cycle for a square and pulse wave '
                                      'since these inheret a duty cycle.\n'
                                      'For other waveforms it will give '
                                      'the user an error'))

        burst = DG1062Burst(cast(DG1062, self.parent), "burst", self.channel)
        self.add_submodule("burst", burst)

        # We want to be able to do the following:
        # >>> help(gd.channels[0].sin)
        # >>> gd.channels[0].sin(freq=2E3, ampl=1.0, offset=0, phase=0)
        # We do not use add_function as it is more cumbersome to use.
        for waveform in self.waveforms:
            f = partial_with_docstring(
                self.apply,
                docstring="Args: " + ", ".join(self.waveform_params[waveform]),
                waveform=waveform)
            setattr(self, waveform.lower(), f)

        # Retreive current waveform from device
        self.waveform()
Ejemplo n.º 4
0
    def __init__(self, name, **kwargs):

        super().__init__(name=name, **kwargs)

        self.add_parameter(name='power',
                           label='Power',
                           unit='dBm',
                           parameter_class=ManualParameter,
                           vals=vals.Numbers(-150, 25))

        self.add_parameter(name='avg',
                           label='Averages',
                           unit='',
                           parameter_class=ManualParameter,
                           vals=vals.Numbers(1, 1000))

        self.add_parameter(name='average_mode',
                           parameter_class=ManualParameter,
                           vals=vals.Enum('auto', 'flatten', 'reduce',
                                          'moving'))

        self.add_parameter(name='average_state',
                           parameter_class=ManualParameter,
                           vals=vals.OnOff())

        self.add_parameter(name='bandwidth',
                           label='Bandwidth',
                           unit='Hz',
                           parameter_class=ManualParameter,
                           vals=vals.Numbers(1, 1e6))

        self.add_parameter(name='center_frequency',
                           unit='Hz',
                           parameter_class=ManualParameter,
                           vals=vals.Numbers(100e3, 20e9))

        self.add_parameter(name='span_frequency',
                           unit='Hz',
                           parameter_class=ManualParameter,
                           vals=vals.Numbers(0, 20e9))

        self.add_parameter(name='start_frequency',
                           unit='Hz',
                           parameter_class=ManualParameter,
                           vals=vals.Numbers(100e3, 20e9))

        self.add_parameter(name='stop_frequency',
                           unit='Hz',
                           parameter_class=ManualParameter,
                           vals=vals.Numbers(100e3, 20e9))

        self.add_parameter(name='number_sweeps_all',
                           parameter_class=ManualParameter,
                           vals=vals.Ints(1, 100000))

        self.add_parameter(name='npts',
                           parameter_class=ManualParameter,
                           vals=vals.Ints(1, 100001))

        self.add_parameter(name='min_sweep_time',
                           parameter_class=ManualParameter,
                           vals=vals.OnOff())

        self.add_parameter(name='sweep_time',
                           parameter_class=ManualParameter,
                           vals=vals.Numbers(0, 1e5))

        self.add_parameter(name='sweep_type',
                           parameter_class=ManualParameter,
                           vals=vals.Enum('lin', 'linear', 'log',
                                          'logarithmic', 'pow', 'power', 'cw',
                                          'poin', 'point', 'segm', 'segment'))
Ejemplo n.º 5
0
    def __init__(self, parent, name, channel, ch_range, ovp_range, ocp_range):
        super().__init__(parent, name)

        self.vmax = ch_range[0]
        self.imax = ch_range[1]
        self.ovp_range = ovp_range
        self.ocp_range = ocp_range

        select_cmd = ":INSTrument:NSELect {};".format(channel)
        strstrip = lambda s: str(s).strip()

        self.add_parameter("set_voltage",
                           label='Target voltage output',
                           set_cmd="{} :SOURce:VOLTage:LEVel:IMMediate:AMPLitude {}".format(
                               select_cmd, '{}'),
                           get_cmd="{} :SOURce:VOLTage:LEVel:IMMediate:AMPLitude?".format(
                               select_cmd),
                           get_parser=float,
                           unit='V',
                           vals=vals.Numbers(min(0, self.vmax), max(0, self.vmax))
                          )
        self.add_parameter("set_current",
                           label='Target current output',
                           set_cmd="{} :SOURce:CURRent:LEVel:IMMediate:AMPLitude {}".format(
                               select_cmd, '{}'),
                           get_cmd="{} :SOURce:CURRent:LEVel:IMMediate:AMPLitude?".format(
                               select_cmd),
                           get_parser=float,
                           unit='A',
                           vals=vals.Numbers(0, self.imax)
                           )
        self.add_parameter('state',
                           label='Output enabled',
                           set_cmd='{} :OUTPut:STATe {}'.format(select_cmd, '{}'),
                           get_cmd='{} :OUTPut:STATe?'.format(select_cmd),
                           get_parser=strstrip,
                           vals=vals.OnOff()
                           )
        self.add_parameter('mode',
                           label='Get the output mode',
                           get_cmd='{} :OUTPut:MODE?'.format(select_cmd),
                           get_parser=strstrip,
                           val_mapping={'ConstantVoltage': 'CV',
                                        'ConstantCurrent': 'CC',
                                        'Unregulated': 'UR'}
                          )
        self.add_parameter("voltage",
                           label='Measured voltage',
                           get_cmd="{} :MEASure:VOLTage:DC?".format(
                               select_cmd),
                           get_parser=float,
                           unit='V',
                          )
        self.add_parameter("current",
                           label='Measured current',
                           get_cmd="{} :MEASure:CURRent:DC?".format(
                               select_cmd),
                           get_parser=float,
                           unit='A',
                           )
        self.add_parameter("power",
                           label='Measured power',
                           get_cmd="{} :MEASure:POWer?".format(
                               select_cmd),
                           get_parser=float,
                           unit='W',
                           )
        self.add_parameter("ovp_value",
                           label='Over Voltage Protection value',
                           set_cmd="{} :VOLTage:PROTection:LEVel {}".format(
                               select_cmd, '{}'),
                           get_cmd="{} :VOLTage:PROTection:LEVel?".format(
                               select_cmd),
                           get_parser=float,
                           unit='V',
                           vals=vals.Numbers(self.ovp_range[0], self.ovp_range[1])
                           )
        self.add_parameter('ovp_state',
                           label='Over Voltage Protection status',
                           set_cmd='{} :VOLTage:PROTection:STATe {}'.format(select_cmd, '{}'),
                           get_cmd='{} :VOLTage:PROTection:STATe?'.format(select_cmd),
                           get_parser=strstrip,
                           vals=vals.OnOff()
                           )
        self.add_parameter("ocp_value",
                           label='Over Current Protection value',
                           set_cmd="{} :CURRent:PROTection:LEVel {}".format(
                               select_cmd, '{}'),
                           get_cmd="{} :CURRent:PROTection:LEVel?".format(
                               select_cmd),
                           get_parser=float,
                           unit='A',
                           vals=vals.Numbers(self.ocp_range[0], self.ocp_range[1])
                           )
        self.add_parameter('ocp_state',
                           label='Over Current Protection status',
                           set_cmd='{} :CURRent:PROTection:STATe {}'.format(select_cmd, '{}'),
                           get_cmd='{} :CURRent:PROTection:STATe?'.format(select_cmd),
                           get_parser=strstrip,
                           vals=vals.OnOff()
                           )
Ejemplo n.º 6
0
    def __init__(self, name, address, **kwargs):
        """Initializes the Oxford Instruments PS 120 Magnet Power Supply.

        Args:
            name (str)    : name of the instrument
            address (str) : instrument address
            number (int)     : ISOBUS instrument number.
        """
        super().__init__(name, address, terminator="\r", **kwargs)

        self._address = address

        ### Add parameters ###

        # status parameters
        self.add_parameter(
            "remote_status",
            get_cmd=self._get_remote_status,
            set_cmd=self._set_remote_status,
            vals=vals.Ints(),
        )
        self.add_parameter(
            "control_mode",
            get_cmd=self._get_control_mode,
            set_cmd=self._set_control_mode,
            vals=vals.Ints(),
        )
        self.add_parameter("supply_status", get_cmd=self._get_supply_status)
        self.add_parameter("ramp_status", get_cmd=self._get_ramp_status)
        self.add_parameter("limit_status", get_cmd=self._get_limit_status)
        self.add_parameter(
            "activity",
            get_cmd=self._get_activity,
            set_cmd=self._set_activity,
            vals=vals.Ints(),
        )

        # switch parameters
        self.add_parameter(
            "switch_heater",
            get_cmd=self._get_switch_heater,
            set_cmd=self._set_switch_heater,
            vals=vals.OnOff(),
        )
        self.add_parameter("heater_current",
                           unit="mA",
                           get_cmd=self._get_heater_current)

        # field parameters
        self.add_parameter("field", unit="T", get_cmd=self._get_field)
        self.add_parameter(
            "field_blocking",
            unit="T",
            get_cmd=self._get_field,
            set_cmd=self.run_to_field_blocking,
            vals=vals.Numbers(-15, 15),
        )
        self.add_parameter(
            "field_non_blocking",
            unit="T",
            get_cmd=self._get_field,
            set_cmd=self.run_to_field_non_blocking,
            vals=vals.Numbers(-15, 15),
        )
        self.add_parameter(
            "field_setpoint",
            unit="T",
            get_cmd=self._get_field_setpoint,
            set_cmd=self._set_field_setpoint,
            vals=vals.Numbers(-15, 15),
        )
        self.add_parameter(
            "sweeprate_field",
            unit="T/min",
            get_cmd=self._get_sweeprate_field,
            set_cmd=self._set_sweeprate_field,
            vals=vals.Numbers(0, 0.5),
        )

        self.add_parameter("current", unit="A", get_cmd=self._get_current)
        self.add_parameter("magnet_current",
                           unit="A",
                           get_cmd=self._get_magnet_current)
        self.add_parameter("current_setpoint",
                           unit="A",
                           get_cmd=self._get_current_setpoint)
        self.add_parameter("sweeprate_current",
                           unit="A/min",
                           get_cmd=self._get_sweeprate_current)
        self.add_parameter("persistent_current",
                           unit="A",
                           get_cmd=self._get_persistent_current)

        # setup RS232 communication
        self.visa_handle.set_visa_attribute(
            visa.constants.VI_ATTR_ASRL_STOP_BITS,
            visa.constants.VI_ASRL_STOP_TWO)