From a6159ed024384924d9f9bf572f18534433ad13d3 Mon Sep 17 00:00:00 2001 From: lukabavdaz Date: Sun, 28 Oct 2018 01:59:12 +0200 Subject: [PATCH 1/5] Update CryogenicSMS driver Remove typos, hardcode terminator, properly raise exceptions when attempting to measure the field in 'AMPS' mode. The commit also makes the driver compatible with SMS60C by removing an incorrect value at the start of some replies. --- .../cryogenic/CryogenicSMS120C.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/qcodes/instrument_drivers/cryogenic/CryogenicSMS120C.py b/qcodes/instrument_drivers/cryogenic/CryogenicSMS120C.py index 04aae6eb188..235d0400498 100644 --- a/qcodes/instrument_drivers/cryogenic/CryogenicSMS120C.py +++ b/qcodes/instrument_drivers/cryogenic/CryogenicSMS120C.py @@ -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) 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. """ @@ -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]) From a2b043cd47f2a90b4551d022eebf2194a2541c06 Mon Sep 17 00:00:00 2001 From: lukabavdaz Date: Sun, 28 Oct 2018 02:37:58 +0200 Subject: [PATCH 2/5] Remove trailing whitespace --- qcodes/instrument_drivers/cryogenic/CryogenicSMS120C.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qcodes/instrument_drivers/cryogenic/CryogenicSMS120C.py b/qcodes/instrument_drivers/cryogenic/CryogenicSMS120C.py index 235d0400498..07047996618 100644 --- a/qcodes/instrument_drivers/cryogenic/CryogenicSMS120C.py +++ b/qcodes/instrument_drivers/cryogenic/CryogenicSMS120C.py @@ -155,7 +155,7 @@ 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) From f7b3cbb3b248b2b345eebed82827a4acda431a0a Mon Sep 17 00:00:00 2001 From: lukabavdaz Date: Sun, 28 Oct 2018 02:46:40 +0200 Subject: [PATCH 3/5] Remove all trailing whitespace --- qcodes/instrument_drivers/cryogenic/CryogenicSMS120C.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qcodes/instrument_drivers/cryogenic/CryogenicSMS120C.py b/qcodes/instrument_drivers/cryogenic/CryogenicSMS120C.py index 07047996618..37176c37882 100644 --- a/qcodes/instrument_drivers/cryogenic/CryogenicSMS120C.py +++ b/qcodes/instrument_drivers/cryogenic/CryogenicSMS120C.py @@ -262,7 +262,7 @@ def _get_maxField(self): # Get the maximum B field, returns a float (in Amps or 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]) From b5b3eaa5a5cdc6b95f8ff12b52b99eec381acd81 Mon Sep 17 00:00:00 2001 From: Jens Hedegaard Nielsen Date: Tue, 30 Oct 2018 01:13:18 +0100 Subject: [PATCH 4/5] change the escape of *IDN Co-Authored-By: lukabavdaz --- qcodes/instrument_drivers/cryogenic/CryogenicSMS120C.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qcodes/instrument_drivers/cryogenic/CryogenicSMS120C.py b/qcodes/instrument_drivers/cryogenic/CryogenicSMS120C.py index 37176c37882..61cbf60b7e7 100644 --- a/qcodes/instrument_drivers/cryogenic/CryogenicSMS120C.py +++ b/qcodes/instrument_drivers/cryogenic/CryogenicSMS120C.py @@ -139,7 +139,7 @@ def __init__(self, name, address, coil_constant=0.113375, current_rating=105.84, def get_idn(self): """ Overwrites the get_idn function using constants as the hardware - does not have a proper \*IDN function. + does not have a proper ``*IDN`` function. """ idparts = ['Cryogenic', 'Magnet PS SMS120C', 'None', '1.0'] From 7ad34dc0ce5de544440f1b9b02188ba71c773093 Mon Sep 17 00:00:00 2001 From: lukabavdaz Date: Tue, 30 Oct 2018 01:32:40 +0100 Subject: [PATCH 5/5] SMS60C usage documentation Also makes terminator more backwards compatible (when named arguments are used). --- qcodes/instrument_drivers/cryogenic/CryogenicSMS120C.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/qcodes/instrument_drivers/cryogenic/CryogenicSMS120C.py b/qcodes/instrument_drivers/cryogenic/CryogenicSMS120C.py index 61cbf60b7e7..acaeb674ddc 100644 --- a/qcodes/instrument_drivers/cryogenic/CryogenicSMS120C.py +++ b/qcodes/instrument_drivers/cryogenic/CryogenicSMS120C.py @@ -8,6 +8,9 @@ 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) + Both the coil_constant and current_rating should be based on calibration data accompanying the magnet. + The SMS60C current_rating should be slightly below 60, as indicated by its name. + Examples of values for a 2T magnet using SMS60C are: coil_constant=0.0380136, current_rating=52.61 """ @@ -58,6 +61,11 @@ def __init__(self, name, address, coil_constant=0.113375, current_rating=105.84, current_ramp_limit=0.0506, reset=False, timeout=5, **kwargs): log.debug('Initializing instrument') + + if 'terminator' in kwargs.keys(): + kwargs.pop('terminator') + log.warning('Passing terminator to CryogenicSMS is no longer supported and has no effect') + super().__init__(name, address, terminator='\r\n', **kwargs) self.visa_handle.baud_rate = 9600