-
Notifications
You must be signed in to change notification settings - Fork 320
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
Update CryogenicSMS driver #1346
Changes from 3 commits
a6159ed
a2b043c
f7b3cbb
b5b3eaa
7ad34dc
28c5ee5
a0185fd
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 |
---|---|---|
|
@@ -3,10 +3,11 @@ | |
# Please refer to Cryogenic's Magnet Power Supply SMS120C manual for further details and functionality. | ||
# This magnet PS model is not SCPI compliant. | ||
# Note: Some commands return more than one line in the output, | ||
some are unidirectional, with no return (eg. 'write' rathern than 'ask'). | ||
some are unidirectional, with no return (eg. 'write' rather than 'ask'). | ||
|
||
This magnet PS driver has been tested with: | ||
FTDI chip drivers (USB to serial), D2XX version installed. | ||
Cryogenic SMS120C and SMS60C (though the default init arguments are not correct for the latter) | ||
|
||
""" | ||
|
||
|
@@ -54,10 +55,10 @@ class CryogenicSMS120C(VisaInstrument): | |
_re_float_exp = r'[-+]?(\d+(\.\d*)?|\.\d+)([eE][-+]?\d+)?' | ||
|
||
def __init__(self, name, address, coil_constant=0.113375, current_rating=105.84, | ||
current_ramp_limit=0.0506, reset=False, timeout=5, terminator='\r\n', **kwargs): | ||
current_ramp_limit=0.0506, reset=False, timeout=5, **kwargs): | ||
|
||
log.debug('Initializing instrument') | ||
super().__init__(name, address, terminator=terminator, **kwargs) | ||
super().__init__(name, address, terminator='\r\n', **kwargs) | ||
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 is slightly dangerous. Even if you were passing the default value this will now result in a I would add some lines like the following to the start of the function above
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. That's a great way of retaining backwards compatibility (when named arguments are used)! |
||
|
||
self.visa_handle.baud_rate = 9600 | ||
self.visa_handle.parity = visa.constants.Parity.none | ||
|
@@ -136,7 +137,7 @@ def __init__(self, name, address, coil_constant=0.113375, current_rating=105.84, | |
|
||
|
||
def get_idn(self): | ||
r""" | ||
""" | ||
Overwrites the get_idn function using constants as the hardware | ||
does not have a proper \*IDN function. | ||
lukabavdaz marked this conversation as resolved.
Show resolved
Hide resolved
|
||
""" | ||
|
@@ -154,6 +155,9 @@ def query(self, msg): | |
value : parsed value extracted from output message | ||
""" | ||
value = self.ask(msg) | ||
|
||
#BUG: The SMS60C sometimes returns an incorrect \x13 at the beginning of the string | ||
value = value.strip('\x13') | ||
m = re.match(r'((\S{8})\s)+(([^:]+)(:([^:]+))?)', value) | ||
if m: | ||
if m[2] == '------->': | ||
|
@@ -254,8 +258,11 @@ def _get_maxField(self): # Get the maximum B field, returns a float (in Amps or | |
maxField = float(m[1]) | ||
return maxField | ||
|
||
# Get current magnetic field, returns a float (assume in Tesla) | ||
# Get current magnetic field, returns a float (if unit is Tesla, otherwise raises an exception) | ||
def _get_field(self): | ||
if self._get_unit() != 1: | ||
raise Exception('Controller is not in TESLA mode, switch to TESLA to get the field') | ||
|
||
_, value = self.query('GET OUTPUT') | ||
m = re.match(r'({}) TESLA AT ({}) VOLTS'.format(CryogenicSMS120C._re_float_exp,CryogenicSMS120C._re_float_exp), value) | ||
field = float(m[1]) | ||
|
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.
Could you document what needs to change?