aboutsummaryrefslogtreecommitdiff
path: root/qolab
diff options
context:
space:
mode:
Diffstat (limited to 'qolab')
-rw-r--r--qolab/hardware/scope/sds1104x.py29
-rw-r--r--qolab/hardware/scpi.py16
2 files changed, 24 insertions, 21 deletions
diff --git a/qolab/hardware/scope/sds1104x.py b/qolab/hardware/scope/sds1104x.py
index 4fe52aa..2a78857 100644
--- a/qolab/hardware/scope/sds1104x.py
+++ b/qolab/hardware/scope/sds1104x.py
@@ -3,8 +3,8 @@ Created by Eugeniy E. Mikhailov 2021/11/29
"""
from qolab.hardware.scope import ScopeSCPI
+from qolab.hardware.scpi import response2numStr
from qolab.data.trace import Trace
-import re
import numpy as np
class SDS1104X(ScopeSCPI):
@@ -17,26 +17,13 @@ class SDS1104X(ScopeSCPI):
self.numberOfChannels = 4
self.maxRequiredPoints = 1000; # desired number of points per channel, can return twice more
- def response2numStr(self, strIn, firstSeparator=None, unit=None):
- # A typical reply of Siglent is in the form 'TDIV 2.00E-08S'
- # i.e. "<prefix><firstSeparator><numberString><unit>
- # prefix='TDIV', firstSeparator=' ', numberString='2.00E-08', unit='S'
- # this function parses the reply
- spltStr = re.split(firstSeparator, strIn)
- prefix = spltStr[0]
- rstr = spltStr[1]
- spltStr = re.split(unit, rstr)
- numberString = spltStr[0]
- unit = spltStr[1]
- return (prefix, numberString, unit)
-
def mean(self, chNum):
# get mean on a specific channel calculated by scope
# PAVA stands for PArameter VAlue
qstr = f'C{chNum}:PAVA? MEAN'
rstr = self.query(qstr);
# reply is in the form 'C1:PAVA MEAN,3.00E-02V'
- prefix, numberString, unit = self.response2numStr(rstr, firstSeparator=',', unit='V')
+ prefix, numberString, unit = response2numStr(rstr, firstSeparator=',', unit='V')
return(float(numberString))
def getAvailableNumberOfPoints(self, chNum):
@@ -46,13 +33,13 @@ class SDS1104X(ScopeSCPI):
qstr = f'SAMPLE_NUM? C{chNum}'
rstr = self.query(qstr)
# reply is in the form 'SANU 7.00E+01pts'
- prefix, numberString, unit = self.response2numStr(rstr, firstSeparator=' ', unit='pts')
+ prefix, numberString, unit = response2numStr(rstr, firstSeparator=' ', unit='pts')
return(int(float(numberString)))
def getSampleRate(self):
rstr = self.query('SAMPLE_RATE?');
# expected reply is like 'SARA 1.00E+09Sa/s'
- prefix, numberString, unit = self.response2numStr(rstr, firstSeparator=' ', unit='Sa/s')
+ prefix, numberString, unit = response2numStr(rstr, firstSeparator=' ', unit='Sa/s')
return(int(float(numberString)))
def calcSparsingAndNumPoints(self, availableNpnts=None, maxRequiredPoints=None):
@@ -107,28 +94,28 @@ class SDS1104X(ScopeSCPI):
qstr = f'C{chNum}:VDIV?'
rstr = self.query(qstr)
# expected reply to query: 'C1:VDIV 1.04E+00V'
- prefix, numberString, unit = self.response2numStr(rstr, firstSeparator=' ', unit='V')
+ prefix, numberString, unit = response2numStr(rstr, firstSeparator=' ', unit='V')
return(float(numberString))
def getChanOffset(self, chNum):
qstr = f'C{chNum}:OFST?'
rstr = self.query(qstr)
# expected reply to query: 'C1:OFST -1.27E+00V'
- prefix, numberString, unit = self.response2numStr(rstr, firstSeparator=' ', unit='V')
+ prefix, numberString, unit = response2numStr(rstr, firstSeparator=' ', unit='V')
return(float(numberString))
def getTimePerDiv(self):
qstr = f'TDIV?'
rstr = self.query(qstr)
# expected reply to query: 'TDIV 2.00E-08S'
- prefix, numberString, unit = self.response2numStr(rstr, firstSeparator=' ', unit='S')
+ prefix, numberString, unit = response2numStr(rstr, firstSeparator=' ', unit='S')
return(float(numberString))
def getTrigDelay(self):
qstr = f'TRIG_DELAY?'
rstr = self.query(qstr)
# expected reply to query: 'TRDL -0.00E+00S'
- prefix, numberString, unit = self.response2numStr(rstr, firstSeparator=' ', unit='S')
+ prefix, numberString, unit = response2numStr(rstr, firstSeparator=' ', unit='S')
return(float(numberString))
diff --git a/qolab/hardware/scpi.py b/qolab/hardware/scpi.py
index 279ef24..71ab556 100644
--- a/qolab/hardware/scpi.py
+++ b/qolab/hardware/scpi.py
@@ -2,6 +2,22 @@
provide basic class to operate SCPI capable instruments
"""
+import re
+
+def response2numStr(strIn, firstSeparator=None, unit=None):
+ # Often an instrument reply is in the form 'TDIV 2.00E-08S' (for example Siglent Scope)
+ # i.e. "<prefix><firstSeparator><numberString><unit>
+ # prefix='TDIV', firstSeparator=' ', numberString='2.00E-08', unit='S'
+ # this function parses the reply
+ spltStr = re.split(firstSeparator, strIn)
+ prefix = spltStr[0]
+ rstr = spltStr[1]
+ spltStr = re.split(unit, rstr)
+ numberString = spltStr[0]
+ unit = spltStr[1]
+ return (prefix, numberString, unit)
+
+
class SCPIinstr:
""" Basic class which support SCPI commands """
"""