-
Notifications
You must be signed in to change notification settings - Fork 314
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Keithley2400 driver #235
Keithley2400 driver #235
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
from qcodes import VisaInstrument | ||
from qcodes.utils.validators import Strings | ||
|
||
|
||
class Keithley_2400(VisaInstrument): | ||
|
||
def __init__(self, name, address, **kwargs): | ||
super().__init__(name, address, terminator='\n', **kwargs) | ||
|
||
self.add_parameter('rangev', | ||
get_cmd='SENS:VOLT:RANG?', | ||
get_parser=float, | ||
set_cmd='SOUR:VOLT:RANG {:f}', | ||
label='Voltage range') | ||
|
||
self.add_parameter('rangei', | ||
get_cmd='SENS:CURR:RANG?', | ||
get_parser=float, | ||
set_cmd='SOUR:CURR:RANG {:f}', | ||
label='Current range') | ||
|
||
self.add_parameter('compliancev', | ||
get_cmd='SENS:VOLT:PROT?', | ||
get_parser=float, | ||
set_cmd='SENS:VOLT:PROT {:f}', | ||
label='Voltage Compliance') | ||
|
||
self.add_parameter('compliancei', | ||
get_cmd='SENS:CURR:PROT?', | ||
get_parser=float, | ||
set_cmd='SENS:CURR:PROT {:f}', | ||
label='Current Compliance') | ||
|
||
self.add_parameter('volt', | ||
get_cmd=':READ?', | ||
get_parser=self._volt_parser, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Issue found: Trailing whitespace |
||
set_cmd=':SOUR:VOLT:LEV {:.8f}', | ||
label='Voltage', | ||
units='V') | ||
|
||
self.add_parameter('curr', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Issue found: Trailing whitespace There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Issue found: Trailing whitespace There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Issue found: Trailing whitespace |
||
get_cmd=':READ?', | ||
get_parser=self._curr_parser, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Issue found: Trailing whitespace There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Issue found: Trailing whitespace There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Issue found: Trailing whitespace |
||
set_cmd=':SOUR:CURR:LEV {:.8f}', | ||
label='Current', | ||
units='A') | ||
|
||
self.add_parameter('mode', | ||
vals=Strings(), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm guessing you know (or can figure out) what the options for |
||
get_cmd=':SOUR:FUNC?', | ||
set_cmd=self._set_mode_and_sense, | ||
label='Mode') | ||
|
||
self.add_parameter('sense', | ||
vals=Strings(), | ||
get_cmd=':SENS:FUNC?', | ||
set_cmd=':SENS:FUNC "{:s}"', | ||
label='Sense mode') | ||
|
||
self.add_parameter('output', | ||
get_parser=int, | ||
set_cmd=':OUTP:STAT {:d}', | ||
get_cmd=':OUTP:STAT?') | ||
|
||
self.add_parameter('nplcv', | ||
get_cmd='SENS:VOLT:NPLC?', | ||
get_parser=float, | ||
set_cmd='SENS:VOLT:NPLC {:f}', | ||
label='Voltage integration time') | ||
|
||
self.add_parameter('nplci', | ||
get_cmd='SENS:CURR:NPLC?', | ||
get_parser=float, | ||
set_cmd='SENS:CURR:NPLC {:f}', | ||
label='Current integration time') | ||
|
||
self.add_parameter('resistance', | ||
get_cmd=':READ?', | ||
get_parser=self._resistance_parser, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Issue found: Trailing whitespace There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Issue found: Trailing whitespace There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Issue found: Trailing whitespace |
||
label='Voltage', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This label is probably not correct? |
||
units='V') | ||
|
||
def _set_mode_and_sense(self, msg): | ||
# This helps set the correct read out curr/volt | ||
if msg == 'VOLT': | ||
self.sense('CURR') | ||
elif msg == 'CURR': | ||
self.sense('VOLT') | ||
else: | ||
raise AttributeError('Mode does not exist') | ||
self.write(':SOUR:FUNC {:s}'.format(msg)) | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Issue found: Trailing whitespace There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Issue found: Trailing whitespace There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Issue found: Trailing whitespace |
||
def reset(self): | ||
self.write(':*RST') | ||
|
||
def _volt_parser(self, msg): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Issue found: Method could be a function There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Issue found: Method could be a function There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Issue found: Method could be a function |
||
MerlinSmiler = [float(x) for x in msg.split(',')] | ||
return MerlinSmiler[0] | ||
|
||
def _curr_parser(self, msg): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Issue found: Method could be a function There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Issue found: Method could be a function There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Issue found: Method could be a function |
||
MerlinSmilerIkke = [float(x) for x in msg.split(',')] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This made me LOL, but you'll need to use self explanatory variable names :D There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And to bring in a few more nice python patterns too: v, i = map(float, msg.split(','))
return i There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think @ThomasKanne was receiving 4 or 5 values here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see - I might still vote for this pattern though, as a way to document what all is in this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. AFAIK and according to somebody: http://www.artima.com/weblogs/viewpost.jsp?thread=98196 volt, *_ = [float(x) for x in msg.split(',')]
return volt There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure, I don't care about map, list comprehension is probably clearer. I just don't like making this unknown list and pulling out a random element from it. We could also solve this with a comment describing what |
||
return MerlinSmilerIkke[1] | ||
|
||
def _resistance_parser(self, msg): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Issue found: Method could be a function There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Issue found: Method could be a function There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Issue found: Method could be a function |
||
JohanSmiler = [float(x) for x in msg.split(',')] | ||
return JohanSmiler[0]/JohanSmiler[1] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @ThomasKanne what happens here if the current reading is zero? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @MerlinSmiles what would be the science behaviour in this case? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would think |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Issue found: Trailing whitespace
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Issue found: Trailing whitespace