Keithley 213 voltage source driver: set_cmd producing error #4694
-
Hello, I am just getting started with QCoDes and I am trying to write a driver for a Keithley 213 voltage source. I have been following the examples in the documentation quite closely, however, I am having trouble with the Here is the code for my driver so far: from time import sleep, time
import numpy as np
import matplotlib.pyplot as plt
import qcodes as qc
from qcodes.instrument import (
Instrument,
VisaInstrument,
MultiParameter,
InstrumentChannel,
InstrumentModule,
)
from qcodes.utils import validators as vals
from qcodes.parameters import Parameter
class KeithleyChannel(InstrumentChannel):
"""
Class to hold the four Keithley channels, i.e.
port: 1, 2, 3, 4.
"""
def __init__(self, parent: Instrument, name: str, channel: str) -> None:
"""
Args:
parent: The Instrument instance to which the channel is to be attached.
name: The `colloquial name of the channel
channel: The name used by Keithley, i.e either 'P1', 'P2', 'P3' or 'P4'.
"""
if channel not in ["P1", "P2", "P3", "P4"]:
raise ValueError('Channel must be set to either port: "P1", "P2", "P3" or "P4"')
super().__init__(parent, name)
self.volt = Parameter(
"volt",
get_cmd = f"C0{channel}V?",
get_parser = float,
set_cmd = f"OUTPUT09;C0 {channel} A1 V{{}} X", # This string is not reaching the instrument as desired.
label = "Voltage",
unit = "V",
instrument= self,
)
self.channel = channel
class Keithley213(VisaInstrument):
"""
QCoDes driver for the Keithley 213 Quad voltage source.
"""
def __init__(self, name: str, address: str, **kwargs) -> None:
"""
Args:
name: Name to use internally in QCoDes
address: VISA resource address
"""
super().__init__(name, address, **kwargs)
for ch in ["P1", "P2", "P3", "P4"]:
ch_name = f"{ch}"
channel = KeithleyChannel(self, ch_name, ch_name)
self.add_submodule(ch_name, channel)
self.error_query = Parameter(
"ErrorQuery",
get_cmd = f"E?",
instrument= self,
)
self.connect_message() When I run station = qc.Station()
keith = Keithley213('keithley', 'GPIB0::9::INSTR')
station.add_component(keith)
keith.P1.volt(3)
print(keith.error_query()) I get an error code E1 from the device which corresponds to an unrecognized command. The command I am trying to implement is straight from an example in the manual: I have also tried multiple variations of this command, all with what should be correct syntax according to the manual. I think the Does anyone know why the command is not parsing correctly? Thanks :) |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
I would suggest that you set a higher logging level when communicating with the instrument to see if it is actually sending the command that you expect. See here for how that can be done https://qcodes.github.io/Qcodes/examples/logging/logging_example.html#Temporarily-elevating-the-logging-level You can also verify that you can send the command using There should be no need to subclass for an example like this |
Beta Was this translation helpful? Give feedback.
I would suggest that you set a higher logging level when communicating with the instrument to see if it is actually sending the command that you expect. See here for how that can be done https://qcodes.github.io/Qcodes/examples/logging/logging_example.html#Temporarily-elevating-the-logging-level
You can also verify that you can send the command using
keith.write(command)
and see if that works as expectedThere should be no need to subclass for an example like this