aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEugeniy E. Mikhailov <evgmik@gmail.com>2021-12-29 23:31:30 -0500
committerEugeniy E. Mikhailov <evgmik@gmail.com>2021-12-29 23:31:30 -0500
commit34608b4334c22b2ecac1beb5d4f55537b17df31e (patch)
tree6a7220a50df917db3b178e2c9566a2c6631b1741
parent594f42b93ed44c10c2a009629cea280b75ffe72b (diff)
downloadqolab-34608b4334c22b2ecac1beb5d4f55537b17df31e.tar.gz
qolab-34608b4334c22b2ecac1beb5d4f55537b17df31e.zip
safety net for better scope trace grab protection
-rw-r--r--qolab/hardware/scope/sds1104x.py21
1 files changed, 14 insertions, 7 deletions
diff --git a/qolab/hardware/scope/sds1104x.py b/qolab/hardware/scope/sds1104x.py
index 493be48..657f599 100644
--- a/qolab/hardware/scope/sds1104x.py
+++ b/qolab/hardware/scope/sds1104x.py
@@ -104,14 +104,21 @@ class SDS1104X(ScopeSCPI):
# FP = 1 corresponds to the second data point
self.write(cstr)
+ trRaw = Trace(f'Ch{chNum}')
+
qstr = f'C{chNum}:WAVEFORM? DAT2'
- wfRaw=self.query_binary_values(qstr, datatype='b', header_fmt='ieee', container=np.array, chunk_size=(Npnts+100))
# expected full reply: 'C1:WF DAT2,#9000000140.........'
- trRaw = Trace(f'Ch{chNum}')
- trRaw.values = wfRaw.reshape(wfRaw.size,1)
- if decimate and sparsing != 1:
- numtaps = 3; # not sure it is the best case
- trRaw.values = scipy.signal.decimate(trRaw.values, sparsing, 3, axis=0)
+ try:
+ wfRaw=self.query_binary_values(qstr, datatype='b', header_fmt='ieee', container=np.array, chunk_size=(Npnts+100))
+ trRaw.values = wfRaw.reshape(wfRaw.size,1)
+ if decimate and sparsing != 1:
+ numtaps = 3; # not sure it is the best case
+ trRaw.values = scipy.signal.decimate(trRaw.values, sparsing, 3, axis=0)
+ except ValueError as err:
+ # most likely we get crazy number of points
+ # self.read() # flushing the bogus output of previous command
+ print(f'Error: getting waveform failed for {qstr=}')
+ wfRaw=np.array([])
trRaw.config['unit'] = 'Count'
trRaw.config['tags']['Decimate'] = decimate
return(trRaw, availableNpnts, Npnts)
@@ -226,7 +233,7 @@ if __name__ == '__main__':
instr=rm.open_resource('TCPIP::192.168.0.62::INSTR')
scope = SDS1104X(instr)
print(f'ID: {scope.idn}')
- print(f'Ch1 mean: {scope.mean(1)}')
+ # print(f'Ch1 mean: {scope.mean(1)}')
print(f'Ch1 available points: {scope.getAvailableNumberOfPoints(1)}')
print(f'Sample Rate: {scope.getSampleRate()}')
print(f'Time per Div: {scope.getTimePerDiv()}')