diff options
author | Eugeniy E. Mikhailov <evgmik@gmail.com> | 2024-07-18 23:50:46 -0400 |
---|---|---|
committer | Eugeniy E. Mikhailov <evgmik@gmail.com> | 2024-07-18 23:50:46 -0400 |
commit | 94eed1a5e960361c265d502037fe41a6c8999684 (patch) | |
tree | 31f4a73c23c25a7f62b4698c9699d47bb339f49c /qolab/hardware/scope | |
parent | 09b5471495c730436a6bc9dd1c95c0268b1a7c3b (diff) | |
download | qolab-94eed1a5e960361c265d502037fe41a6c8999684.tar.gz qolab-94eed1a5e960361c265d502037fe41a6c8999684.zip |
improved heuristic
Diffstat (limited to 'qolab/hardware/scope')
-rw-r--r-- | qolab/hardware/scope/rigolds1054z.py | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/qolab/hardware/scope/rigolds1054z.py b/qolab/hardware/scope/rigolds1054z.py index c658793..85c0ac4 100644 --- a/qolab/hardware/scope/rigolds1054z.py +++ b/qolab/hardware/scope/rigolds1054z.py @@ -138,8 +138,8 @@ class RigolDS1054z(ScopeSCPI): # if RAW is used the scope should be in STOP state self.write(f":WAVeform:SOURce CHAN{chNum}") - self.write(":WAVeform:MODE RAW") # {NORMal|MAXimum|RAW} RAW gives maximum number of points - self.write(":WAVeform:FORMat BYTE") # {WORD|BYTE|ASCii}, scope is 8 bit, BYTE is enough + self.write(":WAVeform:MODE RAW") # {NORMal|MAXimum|RAW} RAW gives maximum number of points + self.write(":WAVeform:FORMat BYTE") # {WORD|BYTE|ASCii}, scope is 8 bit, BYTE is enough preamble = self.query(":WAVeform:PREamble?").split(",") """ Format is @@ -163,11 +163,13 @@ class RigolDS1054z(ScopeSCPI): print(preamble) Npnts = int(preamble[2]) wfRaw = np.zeros(Npnts, dtype=np.int8) - maxreadable = 250000 # the maximum number of bytes readable in one go - chunk_size = maxreadable + maxreadable = 250_000 # the maximum number of bytes readable in one go + chunk_size = 70_000 # unfortunately large chunk size prone to read errors errCnt = 0 strt = 1 stp = min(maxreadable, Npnts) + errorFreeChunkSize = [] + errorProneChunkSize = [] while (strt <= Npnts): stp = strt - 1 + chunk_size stp = min(stp, Npnts) @@ -186,13 +188,18 @@ class RigolDS1054z(ScopeSCPI): if len(wfRawChunk) == 0: continue # we need to repeat chunk read wfRaw[strt-1:stp] = wfRawChunk - chunk_size = min(maxreadable, int(chunk_size*1.2)) + errorFreeChunkSize.append(chunk_size) + chunk_size = min(maxreadable, int(chunk_size*1.1)) strt += chunk_size except VisaIOError: errCnt += 1 + errorProneChunkSize.append(chunk_size) print(f"ERROR count is {errCnt} while reading raw chunk the scope") print(f"Current pointers are {strt=} {stp=} with {chunk_size=}") - chunk_size = max(1, int(np.ceil(chunk_size/2))) + if len(errorFreeChunkSize) > 10: + chunk_size = int(np.mean(errorFreeChunkSize)) + else: + chunk_size = max(1, int(np.mean(errorProneChunkSize)*0.8)) print(f"new {chunk_size=}") pass # we repeat this loop iteration again |