Skip to content

Commit

Permalink
Merge pull request #96 from simonzihlmann/fix_ITest_driver
Browse files Browse the repository at this point in the history
ITest: fix get function of state parameter
  • Loading branch information
FarBo authored May 19, 2021
2 parents 8207b74 + 3ad5150 commit f7dd516
Showing 1 changed file with 50 additions and 51 deletions.
101 changes: 50 additions & 51 deletions qcodes_contrib_drivers/drivers/Bilt/ITest.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class iTestChannel(InstrumentChannel):
"""
A single channel of iTest.
"""

def __init__(self, parent: Instrument,
name: str,
chan_num: int) -> None:
Expand All @@ -29,12 +29,12 @@ def __init__(self, parent: Instrument,
chan_num: The number of the channel in question.
"""
super().__init__(parent, name)

self.chan_num = chan_num
# Get channel id
i, c = round(chan_num/4.)+1, chan_num%4
self.chan_id = 'i{};c{};'.format(i,c)

self.add_parameter('v',
label='Channel {} voltage'.format(chan_num),
unit='V',
Expand All @@ -44,15 +44,15 @@ def __init__(self, parent: Instrument,
set_cmd=partial(self._parent._set_voltage, chan_num),
vals=vals.Numbers(-50, 50)
)

self.add_parameter('i',
label='Channel {} current'.format(chan_num),
unit='A',
docstring='Current of the channel in ampere.',
get_cmd=partial(self._parent._get_current, chan_num),
get_parser=float
)

self.add_parameter('ramp_slope',
label='Channel {} ramp slope'.format(chan_num),
unit='V/ms',
Expand All @@ -62,7 +62,7 @@ def __init__(self, parent: Instrument,
set_cmd=partial(self._parent._set_ramp_slope, chan_num),
vals=vals.Numbers(0, 1)
)

self.add_parameter('output_mode',
label='Channel {} output mode'.format(chan_num),
docstring='Mode of the output {exp, ramp}.',
Expand All @@ -72,33 +72,34 @@ def __init__(self, parent: Instrument,
set_parser=str,
vals=vals.Enum('ramp', 'exp')
)

self.add_parameter('v_range',
label = 'Channel {} voltage range'.format(chan_num),
docstring='Range of the channel in volt.',
set_cmd=partial(self._parent._set_chan_range, chan_num),
set_parser=float,
get_cmd=partial(self._parent._get_chan_range, chan_num),
get_parser=float)

self.add_parameter('state',
docstring='State of the channel {on, off}.',
get_cmd=partial(self._parent._get_chan_state, chan_num),
set_cmd=partial(self._parent._set_chan_state, chan_num),
val_mapping=create_on_off_val_mapping(on_val='on', off_val='off'))

val_mapping=create_on_off_val_mapping(on_val='1',
off_val='0'))

self.add_parameter('pos_sat',
get_cmd=partial(self._parent._get_chan_pos_sat, chan_num),
get_parser=str,
set_cmd=partial(self._parent._set_chan_pos_sat, chan_num),
set_parser=str,)

self.add_parameter('neg_sat',
get_cmd=partial(self._parent._get_chan_neg_sat, chan_num),
get_parser=str,
set_cmd=partial(self._parent._set_chan_neg_sat, chan_num),
set_parser=str,)

self.add_parameter('bilt_name',
set_cmd=partial(self._parent._set_chan_name, chan_num),
set_parser=str,
Expand All @@ -118,7 +119,7 @@ def __init__(self, parent: Instrument,
get_parser=float,
set_cmd=None,
vals=vals.Numbers(1e-3, 10),
initial_value=1)
initial_value=1e-3)

self.add_parameter('synchronous_threshold',
docstring='Threshold to unblock communication in volt.',
Expand Down Expand Up @@ -147,7 +148,7 @@ def stop(self) -> None:
class iTestMultiChannelParameter(MultiChannelInstrumentParameter):
"""
"""

def __init__(self, channels, param_name, *args, **kwargs):
super().__init__(channels, param_name, *args, **kwargs)

Expand All @@ -156,7 +157,7 @@ class ITest(VisaInstrument):
"""
This is the QCoDeS python driver for the iTest device from Bilt.
"""

def __init__(self,name:str,
address:str,
num_chans:int=16,
Expand All @@ -167,7 +168,7 @@ def __init__(self,name:str,
**kwargs: Any) -> None:
"""
Instantiate the instrument.
Args:
name: The instrument name used by qcodes
address: The VISA name of the resource
Expand All @@ -181,38 +182,38 @@ def __init__(self,name:str,
"synchronous_threshold".
synchronous_delay: Time between to voltage measurement in second.
synchronous_threshold: Threshold to unblock communication in volt.
Returns:
ITest object
"""
super().__init__(name, address=address,
terminator='\n',
device_clear=False,
**kwargs)

self.idn = self.get_idn()
self.num_chans = num_chans
self.chan_range = range(1,self.num_chans+1)

# Create the channels
channels = ChannelList(parent=self,
name='Channels',
chan_type=iTestChannel,
multichan_paramclass=iTestMultiChannelParameter)

for i in self.chan_range:

channel = iTestChannel(self, name='chan{:02}'.format(i),
chan_num=i)
channel.synchronous_enable(synchronous_enable)
channel.synchronous_delay(synchronous_delay)
channel.synchronous_threshold(synchronous_threshold)
channels.append(channel)
self.add_submodule('ch{:02}'.format(i),channel)

channels.lock()
self.add_submodule('channels',channels)

if init_start:
for channel in self.channels:
channel.v.set(0)
Expand All @@ -226,7 +227,7 @@ def _set_voltage(self, chan:int,
v_set:float) -> None:
"""
Set cmd for the chXX_v parameter
Args:
chan: The 1-indexed channel number
v_set: The target voltage
Expand All @@ -244,38 +245,38 @@ def _set_voltage(self, chan:int,
def _get_voltage(self, chan:int) -> float:
"""
Get cmd for the chXX_v parameter
Args:
chan: The 1-indexed channel number
Returns:
Voltage
"""
chan_id = self.chan_to_id(chan)

return float(self.ask('{}MEAS:VOLT?'.format(chan_id)))


def _get_current(self, chan:int) -> float:
"""
Get cmd for the chXX_i parameter
Args:
chan: The 1-indexed channel number
Returns:
Current
"""
chan_id = self.chan_to_id(chan)

return float(self.ask('{}MEAS:CURR?'.format(chan_id)))


def _set_ramp_slope(self, chan:int,
slope:float) -> None:
"""
Set slope of chXX for ramp mode
Args:
chan The 1-indexed channel number
slope Slope of chXX in V/ms
Expand All @@ -287,10 +288,10 @@ def _set_ramp_slope(self, chan:int,
def _get_ramp_slope(self, chan:int) -> str:
"""
Get slope of chXX
Args:
chan: The 1-indexed channel number
Returns:
chXX_slope parameter
"""
Expand All @@ -302,30 +303,30 @@ def _set_output_function(self, chan:int,
outf:str) -> None:
"""
Set how to perform output voltage update
Args:
chan: The 1-indexed channel number
ouf: Mode
"""
chan_id = self.chan_to_id(chan)

if outf=='exp':
mode = '0'
elif outf=='ramp':
mode = '1'
else:
raise ValueError('Got unexpected output function mode: {}.'.format(mode))

self.write(chan_id + 'trig:input ' + mode)


def _get_output_function(self, chan:int) -> str:
"""
Get output volage update function
Args:
chan: The 1-indexed channel number
Returns:
mode
"""
Expand All @@ -343,7 +344,7 @@ def _set_chan_range(self, chan:int,
volt: float) -> None:
"""
Set output voltage range
Args:
chan : The 1-indexed channel number
volt : Voltage range (1.2 or 12)
Expand All @@ -355,15 +356,15 @@ def _set_chan_range(self, chan:int,
def _get_chan_range(self, chan:int) -> str:
"""
Get output voltage range
Args:
chan: The 1-indexed channel number
Returns:
volt: Output voltage range
"""
chan_id = self.chan_to_id(chan)

return self.ask(chan_id + 'VOLT:RANGE?')[:-2]


Expand Down Expand Up @@ -395,23 +396,21 @@ def _get_chan_neg_sat(self, chan:int) -> str:
return self.ask(chan_id + 'VOLT:SAT:NEG ?')


def _get_chan_state(self, chan:int) -> bool:
def _get_chan_state(self, chan:int) -> str:
"""
Get channel power state
Args:
chan: The 1-indexed channel number
Returns:
state: Power state
state: Power state
"""
chan_id = self.chan_to_id(chan)
state = self.ask(chan_id + 'OUTP ?')

if state == '1':
return True
elif state == '0':
return False

if state in ['1', '0'] :
return state
else:
raise ValueError('Unknown state output: {}'.format(state))

Expand All @@ -420,7 +419,7 @@ def _set_chan_state(self, chan:int,
state:str) -> None:
"""
Set channel power state
Args:
chan: The 1-indexed channel number
state: power state
Expand Down Expand Up @@ -448,7 +447,7 @@ def chan_to_ic(self, chan:int) -> Tuple[int, int]:
to iX;c;
Args:
chan: The 1-indexed channel number
Returns:
i,c: i=card number, c=channel number of card i
"""
Expand Down

0 comments on commit f7dd516

Please sign in to comment.