Skip to content

Commit 01378f5

Browse files
committed
Update minumum permitted time gap based on testing
1 parent 924b57d commit 01378f5

File tree

2 files changed

+29
-13
lines changed

2 files changed

+29
-13
lines changed

PSL/oscilloscope.py

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,21 @@ def capture(self, channels: int, samples: int, timegap: float,) -> np.ndarray:
4949
samples : int
5050
Number of samples to fetch. Maximum 10000 divided by number of channels.
5151
timegap : float
52-
Timegap between samples in microseconds. Will be rounded to the closest
53-
1 / 8 µs. The minimum timegap depends on the type of measurement:
54-
When sampling a single, untriggered channel with 10 bits of resolution,
55-
the timegap must be exactly 0.5 µs (2 Msps).
56-
When sampling a single channel with 12 bits of resolution, the timegap
57-
must be 2 µs or greater (500 ksps).
58-
When sampling two or more channels, the timegap must be 0.875 µs or
59-
greater (1.1 Msps).
52+
Time gap between samples in microseconds. Will be rounded to the closest
53+
1 / 8 µs. The minimum time gap depends on the type of measurement:
54+
+--------------+------------+----------+------------+
55+
| Simultaneous | No trigger | Trigger | No trigger |
56+
| channels | (10-bit) | (10-bit) | (12-bit) |
57+
+==============+============+==========+============+
58+
| 1 | 0.5 µs | 0.75 µs | 1 µs |
59+
+--------------+------------+----------+------------+
60+
| 2 | 0.875 µs | 0.875 µs | N/A |
61+
+--------------+------------+----------+------------+
62+
| 4 | 1.75 µs | 1.75 µs | N/A |
63+
+--------------+------------+----------+------------+
64+
Sample resolution is set automatically based on the above limitations; i.e.
65+
to get 12-bit samples only one channel may be sampled, there must be no
66+
active trigger, and the time gap must be 1 µs or greater.
6067
6168
Example
6269
-------
@@ -73,7 +80,7 @@ def capture(self, channels: int, samples: int, timegap: float,) -> np.ndarray:
7380
Raises
7481
------
7582
ValueError
76-
If :channels: > 4 or
83+
If :channels: is not 1, 2 or 4, or
7784
:samples: > 10000 / :channels:, or
7885
:channel_one_map: is not one of CH1, CH2, CH3, MIC, CAP, SEN, AN8, or
7986
:timegap: is too low.
@@ -109,7 +116,6 @@ def capture_nonblocking(
109116
Example
110117
-------
111118
>>> import time
112-
>>> import numpy as np
113119
>>> from PSL.oscilloscope import Oscilloscope
114120
>>> scope = Oscilloscope()
115121
>>> x = scope.capture_nonblocking(1, 3200, 1)
@@ -140,7 +146,7 @@ def _check_args(self, channels: int, samples: int, timegap: float):
140146
e2 = f"{channels} channels."
141147
raise ValueError(e1 + e2)
142148

143-
min_timegap = 0.5 + 0.375 * (channels > 1 or self.trigger_enabled)
149+
min_timegap = self._lookup_mininum_timegap(channels)
144150
if timegap < min_timegap:
145151
raise ValueError(f"timegap must be at least {min_timegap}.")
146152

@@ -149,6 +155,16 @@ def _check_args(self, channels: int, samples: int, timegap: float):
149155
e2 = f"Valid channels are {list(self.channels.keys())}."
150156
raise ValueError(e1 + e2)
151157

158+
def _lookup_mininum_timegap(self, channels: int) -> float:
159+
channels_idx = {
160+
1: 0,
161+
2: 1,
162+
4: 2,
163+
}
164+
min_timegaps = [[0.5, 0.75], [0.875, 0.875], [1.75, 1.75]]
165+
166+
return min_timegaps[channels_idx[channels]][self.trigger_enabled]
167+
152168
def _capture(self, channels: int, samples: int, timegap: float):
153169
self._invalidate_buffer()
154170
chosa = self.channels[self.channel_one_map].chosa
@@ -191,7 +207,7 @@ def _capture(self, channels: int, samples: int, timegap: float):
191207
self.device.get_ack()
192208

193209
def _invalidate_buffer(self):
194-
for c in self.channels:
210+
for c in self.channels.values():
195211
c.samples_in_buffer = 0
196212
c.buffer_idx = None
197213

PSL/packet_handler.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77
>>> version = device.get_version()
88
>>> device.disconnect()
99
"""
10-
from functools import partial
1110
import logging
1211
import struct
1312
import time
13+
from functools import partial
1414
from typing import List, Union
1515

1616
import serial

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy