Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
131 changes: 131 additions & 0 deletions docs/examples/Qcodes example with Keysight 33500B.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"pyqtgraph plotting not supported, try \"from qcodes.plots.pyqtgraph import QtPlot\" to see the full error\n"
]
}
],
"source": [
"import qcodes as qc\n",
"from qcodes.instrument_drivers.Keysight.Keysight_33500B import Keysight_33500B"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"ks = Keysight_33500B('ks', 'TCPIP0::K-33522B-00256::inst0::INSTR')"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"# SET up a sawtooth\n",
"ks.ch1_function_type('RAMP')\n",
"ks.ch1_ramp_symmetry(100)\n",
"ks.ch1_amplitude_unit('VPP')\n",
"ks.ch1_amplitude(1)\n",
"ks.ch1_offset(0)\n",
"ks.ch1_frequency(2e3)\n",
"ks.sync_source(1)"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"# Start it\n",
"ks.sync_output('ON')\n",
"ks.ch1_output('ON')\n"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"ks.ch1_frequency(1e3)"
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"# stop it\n",
"ks.sync_output('OFF')\n",
"ks.ch1_output('OFF')"
]
},
{
"cell_type": "code",
"execution_count": 13,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"ks.close()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.5.2"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
99 changes: 99 additions & 0 deletions qcodes/instrument_drivers/Keysight/Keysight_33500B.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
from qcodes import VisaInstrument, validators as vals
from pyvisa.errors import VisaIOError
import logging

log = logging.getLogger(__name__)


class Keysight_33500B(VisaInstrument):

def __init__(self, name, address, **kwargs):

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

# stupid helper functions
def setcmd(channel, setting):
return 'SOURce{}:'.format(channel) + setting + ' {}'

def getcmd(channel, setting):
return 'SOURce{}:'.format(channel) + setting + '?'

for chan in [1, 2]:

self.add_parameter('ch{}_function_type'.format(chan),
label='Channel {} function type'.format(chan),
set_cmd=setcmd(chan, 'FUNCtion'),
get_cmd=getcmd(chan, 'FUNCtion'),
vals=vals.Enum('SIN', 'SQU', 'TRI', 'RAMP',
'PULS', 'PRBS', 'NOIS', 'ARB',
'DC')
)

self.add_parameter('ch{}_frequency_mode'.format(chan),
label='Channel {} frequency mode'.format(chan),
set_cmd=setcmd(chan, 'FREQuency:MODE'),
get_cmd=getcmd(chan, 'FREQuency:MODE'),
vals=vals.Enum('CW', 'LIST', 'SWEEP', 'FIXED')
)

self.add_parameter('ch{}_frequency'.format(chan),
label='Channel {} frequency'.format(chan),
set_cmd=setcmd(chan, 'FREQuency'),
get_cmd=getcmd(chan, 'FREQUency'),
get_parser=float,
unit='Hz',
# TODO: max. freq. actually really tricky
vals=vals.Numbers(1e-6, 30e6)
)

self.add_parameter('ch{}_amplitude_unit'.format(chan),
label='Channel {} amplitude unit'.format(chan),
set_cmd=setcmd(chan, 'VOLTage:UNIT'),
get_cmd=getcmd(chan, 'VOLTage:UNIT'),
vals=vals.Enum('VPP', 'VRMS', 'DBM')
)

self.add_parameter('ch{}_amplitude'.format(chan),
label='Channel {} amplitude'.format(chan),
set_cmd=setcmd(chan, 'VOLTage'),
get_cmd=getcmd(chan, 'VOLTage'),
unit='', # see amplitude_unit
get_parser=float)

self.add_parameter('ch{}_offset'.format(chan),
label='Channel {} voltage offset'.format(chan),
set_cmd=setcmd(chan, 'VOLTage:OFFSet'),
get_cmd=getcmd(chan, 'VOLTage:OFFSet'),
unit='V',
get_parser=float
)
self.add_parameter('ch{}_output'.format(chan),
label='Channel {} output state'.format(chan),
set_cmd='OUTPut{}'.format(chan) + ' {}',
get_cmd='OUTPut{}?'.format(chan),
val_mapping={'ON': 1, 'OFF': 0}
)

self.add_parameter('ch{}_ramp_symmetry'.format(chan),
label='Channel {} ramp symmetry'.format(chan),
set_cmd=setcmd(chan, 'FUNCtion:RAMP:SYMMetry'),
get_cmd=getcmd(chan, 'FUNCtion:RAMP:SYMMetry'),
get_parser=float,
vals=vals.Numbers(0, 100)
)

self.add_parameter('sync_source',
label='Source of sync function',
set_cmd='OUTPut:SYNC:SOURce {}',
get_cmd='OUTPut:SYNC:SOURce?',
val_mapping={1: 'CH1', 2: 'CH2'},
vals=vals.Enum(1, 2)
)

self.add_parameter('sync_output',
label='Sync output state',
set_cmd='OUTPut:SYNC {}',
get_cmd='OUTPut:SYNC?',
val_mapping={'ON': 1, 'OFF': 0},
vals=vals.Enum('ON', 'OFF')
)