This guide by was written by Rohit B.@SQDLab (27rohitb@gmail.com), in July 2020.
I am writing this while trying to make driver for Rigol DS5072, which is a AWG.
I will be writing more in detail for VISA instruments, since the AWG programming is a VISA instruments.
from qcodes import VisaInstrument
class DG5072(VisaInstrument):
def __init__(self, name, address, **kwargs):
super().__init__(name, address, **kwargs)
There are mainly 3 additional components in qcodes here:
For instruments that have output channels like AWGs, qcodes has special module: qcodes.instrument.channel
, which contains all the info (parameters) etc for the given channel.
from qcodes.instrument.channel import InstrumentChannel, ChannelList
class RigolDS5072(InstrumentChannel):
def __init__(self, parent, name, channel):
super().__init__(parent, name)
Usually these Channels are added into main instrument using channellist in the init of the instrument. Like this:
channels = ChannelList(self, "Channels", RigolDS5072)
for i in channel_number in range(1,3):
channel = RigolDS5072Channel(self, "ch{}".format(channel_number), channel_number)
channels.append(channel)
channel.lock()
self.add_submodule('channels',channels)
By default Qcodes includes 3 type of parameters:
self.add_parameter()
) which has the following input parameters:Input parameter name | Detail |
---|---|
name | Name of the parameter |
instrument | (optional) The instrument it is associated with |
label | (optional) axis label, when graphed |
unit | (optional) unit for this param |
snapshot_get | (optional) permission for update during snapshot |
snapshot_value | (optional) permission to store value in snapshot |
snapshot_exclude | (optional) permission to include it in snapshot |
step | (optional) max increment that can be done |
scale | (optional) scale to multiply by, before setting this |
inter_delay | (optional) min. time btw successive set |
post_delay | (optional) time to wait after setting |
val_mapping | (optional) dict of type {data_val: inst_code} |
get_parser | (optional) transform the data from get to final output |
set_parser | (optional) Transform the input value to some input code |
vals | (optional) set Validators from qcodes.utils.validators |
max_val_age | (optional) max time after which the value is invalidated |
initial_value | (optional) set the default value for this param |
docstring | (optional) doc string for this param (not same as label) |
metadata | (optional) extra info to be included in JSON snapshot |
This parameters has associated setpoints (a list of other parneters that describe values, name and units of the setpoint axis)
Note: Parameters can also be combined here and here
Apart from the above parameter, user can make their own custom parameter by inheriting the python from qcodes import Parameter
and override the get_raw()
and set_raw()
functions.
It’s documentation is not in the source code, but at <qcodes-installation>/qcodes/instruments/functions.py
self.add_function()
It has the following input parameters:
Input Parameter Name | Detail |
---|---|
name | name of the function |
instrument | (optional) instrument it belongs to |
call_cmd | (optional) command to execute on the instrument |
args | (optional) list of Validators |
arg_parser | (optional) function that transforms input to instrument input. ONLY works if call_cmd is a string |
return_parser | (optional) function to transform data to output |
docstring | (optional) docstring |
This equivalent of python functions but for the device.
self.add_submodule(name, function)