Skip to content

Commit

Permalink
Merge pull request #47 from ljsplitthoff/E36313A
Browse files Browse the repository at this point in the history
Keysight E36313A power source
  • Loading branch information
lakhotiaharshit authored Apr 7, 2020
2 parents cce401a + d0d57cb commit ff67617
Showing 1 changed file with 82 additions and 0 deletions.
82 changes: 82 additions & 0 deletions qcodes_contrib_drivers/drivers/Keysight/Keysight_E36313A.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
from qcodes import VisaInstrument
from qcodes import Instrument
from qcodes.instrument.channel import InstrumentChannel


class E36313AChannel(InstrumentChannel):
"""
"""
def __init__(self, parent: Instrument, name: str, chan: int) -> None:
"""
Args:
parent: The instrument to which the channel is
attached.
name: The name of the channel
chan: The number of the channel in question (1-3)
"""
# Sanity Check inputs
if name not in ['ch1', 'ch2', 'ch3']:
raise ValueError("Invalid Channel: {}, expected 'ch1' or 'ch2' or 'ch3'"
.format(name))
if chan not in [1, 2, 3]:
raise ValueError("Invalid Channel: {}, expected '1' or '2' or '3'"
.format(chan))

super().__init__(parent, name)

self.add_parameter('source_voltage',
label="Channel {} Voltage".format(chan),
get_cmd='VOLT? (@{:d})'.format(chan),
get_parser=float,
set_cmd='VOLT {{:.8G}} (@{:d})'.format(chan),
unit='V')

self.add_parameter('source_current',
label="Channel {} Current".format(chan),
get_cmd='CURR? (@{:d})'.format(chan),
get_parser=float,
set_cmd='CURR {{:.8G}} (@{:d})'.format(chan),
unit='A')

self.add_parameter('voltage',
get_cmd='MEAS:VOLT? (@{:d})'.format(chan),
get_parser=float,
label='Channel {} Voltage'.format(chan),
unit='V')

self.add_parameter('current',
get_cmd='MEAS:CURR? (@{:d})'.format(chan),
get_parser=float,
label='Channel {} Current'.format(chan),
unit='A')

self.add_parameter('enable',
get_cmd='OUTP? (@{:d})'.format(chan),
set_cmd='OUTP {{:d}} (@{:d})'.format(chan),
val_mapping={'on': 1, 'off': 0})

self.channel = chan


class E36313A(VisaInstrument):
"""
This is the qcodes driver for the Keysight E36313A programmable DC power supply
"""
def __init__(self, name, address, **kwargs):
super().__init__(name, address, terminator='\n', **kwargs)

# The E36313A supports two channels
for ch_num in [1, 2, 3]:
ch_name = "ch{:d}".format(ch_num)
channel = E36313AChannel(self, ch_name, ch_num)
self.add_submodule(ch_name, channel)

self.connect_message()

def get_idn(self):
IDN = self.ask_raw('*IDN?')
vendor, model, serial, firmware = map(str.strip, IDN.split(','))
IDN = {'vendor': vendor, 'model': model,
'serial': serial, 'firmware': firmware}
return IDN

0 comments on commit ff67617

Please sign in to comment.