Skip to content
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

Merged
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions qcodes/instrument_drivers/cryogenic/CryogenicSMS120C.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Copy link
Collaborator

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?


"""

Expand Down Expand Up @@ -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)
Copy link
Collaborator

Choose a reason for hiding this comment

The 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 TypeError: __init__() got multiple values for keyword argument 'terminator'

I would add some lines like the following to the start of the function above

if 'terminator' in kwargs.keys():
    kwargs.pop('terminator')
    warnings.warn('Passing terminator to CryogenicSMS is no longer supported and has no effect')

Copy link
Contributor Author

@lukabavdaz lukabavdaz Oct 30, 2018

Choose a reason for hiding this comment

The 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
Expand Down Expand Up @@ -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
"""
Expand All @@ -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] == '------->':
Expand Down Expand Up @@ -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])
Expand Down