-
Notifications
You must be signed in to change notification settings - Fork 319
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
Kepco Magnet driver #914
Kepco Magnet driver #914
Changes from 2 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,65 @@ | ||
from qcodes.instrument.base import Instrument | ||
from qcodes.utils.validators import Numbers | ||
import qcodes as qc | ||
|
||
from typing import Union | ||
|
||
class KepcoMagnet(Instrument): | ||
MAX_AMP = 20 | ||
|
||
""" | ||
This is the qcodes driver for controlling the field using the Kepco BOP 20-20M. | ||
|
||
This is a virtual driver only and will not talk to your instrument. | ||
""" | ||
|
||
def __init__(self, name, parameter, max_field, volt_to_amp, field_to_amp,axis,rate=0.2, **kwargs): | ||
super().__init__(name, **kwargs) | ||
|
||
self.v1 = parameter | ||
|
||
self.max_field = max_field | ||
self.volt_to_amp = volt_to_amp | ||
self.field_to_amp = field_to_amp | ||
self.axis=axis | ||
self.rate=rate | ||
|
||
self.v1.vals = Numbers(-self.MAX_AMP / volt_to_amp, | ||
self.MAX_AMP / volt_to_amp) | ||
|
||
self.add_parameter('minmax', | ||
label='Maximum field value', | ||
unit='T', | ||
vals=Numbers()) | ||
|
||
|
||
self.add_parameter('{}_BField'.format(axis), | ||
label='{} magnetic field'.format(axis), | ||
unit='T', | ||
get_cmd=self.get_field, | ||
set_cmd=self.set_field, | ||
vals=Numbers(-max_field, max_field)) | ||
|
||
def set_field(self, value: Union[int, float]) -> None: | ||
instrument_value = value * self.field_to_amp / self.volt_to_amp | ||
delay=0.1 | ||
step = (self.rate * self.field_to_amp / self.volt_to_amp) * delay / 60 | ||
range = abs(self.v1() - instrument_value) | ||
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. Codeacy suggests not using range because thats a buildin function that you overwrite |
||
npoints = round(range/step) | ||
qc.Loop(self.v1.sweep(self.v1(), instrument_value, num=npoints), delay=delay).each(self.v1).run() | ||
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. As discussed with @Dominik-Vogel this can be done better by setting inter_delay and step of the parameter |
||
|
||
def get_field(self) -> Union[int, float]: | ||
""" | ||
Returns: | ||
number: value at which was set at the sample | ||
""" | ||
value = self.v1.get() / self.field_to_amp * self.volt_to_amp | ||
return value | ||
|
||
def get_idn(self): | ||
vendor = 'Ithaco (DL Instruments)' | ||
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 this needs updating to match this instrument |
||
model = '1211' | ||
serial = None | ||
firmware = None | ||
return {'vendor': vendor, 'model': model, | ||
'serial': serial, 'firmware': firmware} |
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.
It would be good to explain a bit more that this actually controls a different parameter. By this description I would expect that this is a control for a instrument which can only be controlled manually