aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEugeniy E. Mikhailov <evgmik@gmail.com>2021-11-30 09:58:26 -0500
committerEugeniy E. Mikhailov <evgmik@gmail.com>2021-11-30 09:58:26 -0500
commit8b49ddd1df224cd260259596b7e5c40eb3693560 (patch)
treeb0eebabe979438132d5793953739e9a142c95849
parent1940f9f4f0cd55267a5d208de65f8282996315f8 (diff)
downloadqolab-8b49ddd1df224cd260259596b7e5c40eb3693560.tar.gz
qolab-8b49ddd1df224cd260259596b7e5c40eb3693560.zip
added scope time trace
-rw-r--r--scope.py32
1 files changed, 23 insertions, 9 deletions
diff --git a/scope.py b/scope.py
index 31f39ce..5fc2a03 100644
--- a/scope.py
+++ b/scope.py
@@ -62,11 +62,9 @@ class SDS1104x(Scope):
prefix, numberString, unit = self.response2numStr(rstr, firstSeparator=' ', unit='Sa/s')
return(int(float(numberString)))
- def getRawWaveform(self, chNum, availableNpnts=None, sampleRate=None, maxRequiredPoints=None):
+ def getRawWaveform(self, chNum, availableNpnts=None, maxRequiredPoints=None):
if availableNpnts == None:
availableNpnts = self.getAvailableNumberOfPoints(chNum)
- if sampleRate == None:
- sampleRate = self.getSampleRate()
if maxRequiredPoints == None:
maxRequiredPoints = self.maxRequiredPoints
@@ -100,7 +98,7 @@ class SDS1104x(Scope):
qstr = f'C{chNum}:WAVEFORM? DAT2'
wfRaw=self.query_binary_values(qstr, datatype='b', header_fmt='ieee', container=np.array)
# expected full reply: 'C1:WF DAT2,#9000000140.........'
- return(wfRaw)
+ return(wfRaw, availableNpnts, sparsing)
def getChanVoltsPerDiv(self, chNum):
qstr = f'C{chNum}:VDIV?'
@@ -123,17 +121,32 @@ class SDS1104x(Scope):
prefix, numberString, unit = self.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')
+ return(float(numberString))
+
- def getWaveform(self, chNum, availableNpnts=None, sampleRate=None, maxRequiredPoints=None):
- wfRaw = self.getRawWaveform(chNum, availableNpnts=availableNpnts, sampleRate=sampleRate, maxRequiredPoints=maxRequiredPoints)
+ def getWaveform(self, chNum, availableNpnts=None, maxRequiredPoints=None):
+ wfRaw, availableNpnts, sparsing = self.getRawWaveform(chNum, availableNpnts=availableNpnts, maxRequiredPoints=maxRequiredPoints)
vertDivOnScreen = 10
VoltageOffset = self.getChanOffset(chNum)
VoltsPerDiv = self.getChanVoltsPerDiv(chNum)
- return( wfRaw * VoltsPerDiv * vertDivOnScreen/250 -VoltageOffset )
+ return( wfRaw * VoltsPerDiv * vertDivOnScreen/250 -VoltageOffset, availableNpnts, sparsing)
- def getTimeTrace(self):
+ def getTimeTrace(self, sparsing=1, Npnts=None):
sampleRate = self.getSampleRate()
timePerDiv = self.getTimePerDiv()
+ trigDelay = self.getTrigDelay()
+ if Npnts == None:
+ # using channel 1 as reference
+ Npnts = self.getAvailableNumberOfPoints(1)
+ time = np.arange(Npnts) / sampleRate * sparsing;
+ horizDivOnScreen = 14
+ time = time - timePerDiv * horizDivOnScreen/2 - trigDelay
+ return(time)
if __name__ == '__main__':
@@ -149,7 +162,8 @@ if __name__ == '__main__':
print(scope.getTimePerDiv())
print(scope.getChanVoltsPerDiv(1))
print(scope.getChanOffset(1))
- wf = scope.getWaveform(1)
+ wf = scope.getWaveform(4)
+ time = scope.getTimeTrace()