@@ -49,14 +49,21 @@ def capture(self, channels: int, samples: int, timegap: float,) -> np.ndarray:
49
49
samples : int
50
50
Number of samples to fetch. Maximum 10000 divided by number of channels.
51
51
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.
60
67
61
68
Example
62
69
-------
@@ -73,7 +80,7 @@ def capture(self, channels: int, samples: int, timegap: float,) -> np.ndarray:
73
80
Raises
74
81
------
75
82
ValueError
76
- If :channels: > 4 or
83
+ If :channels: is not 1, 2 or 4, or
77
84
:samples: > 10000 / :channels:, or
78
85
:channel_one_map: is not one of CH1, CH2, CH3, MIC, CAP, SEN, AN8, or
79
86
:timegap: is too low.
@@ -109,7 +116,6 @@ def capture_nonblocking(
109
116
Example
110
117
-------
111
118
>>> import time
112
- >>> import numpy as np
113
119
>>> from PSL.oscilloscope import Oscilloscope
114
120
>>> scope = Oscilloscope()
115
121
>>> x = scope.capture_nonblocking(1, 3200, 1)
@@ -140,7 +146,7 @@ def _check_args(self, channels: int, samples: int, timegap: float):
140
146
e2 = f"{ channels } channels."
141
147
raise ValueError (e1 + e2 )
142
148
143
- min_timegap = 0.5 + 0.375 * (channels > 1 or self . trigger_enabled )
149
+ min_timegap = self . _lookup_mininum_timegap (channels )
144
150
if timegap < min_timegap :
145
151
raise ValueError (f"timegap must be at least { min_timegap } ." )
146
152
@@ -149,6 +155,16 @@ def _check_args(self, channels: int, samples: int, timegap: float):
149
155
e2 = f"Valid channels are { list (self .channels .keys ())} ."
150
156
raise ValueError (e1 + e2 )
151
157
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
+
152
168
def _capture (self , channels : int , samples : int , timegap : float ):
153
169
self ._invalidate_buffer ()
154
170
chosa = self .channels [self .channel_one_map ].chosa
@@ -191,7 +207,7 @@ def _capture(self, channels: int, samples: int, timegap: float):
191
207
self .device .get_ack ()
192
208
193
209
def _invalidate_buffer (self ):
194
- for c in self .channels :
210
+ for c in self .channels . values () :
195
211
c .samples_in_buffer = 0
196
212
c .buffer_idx = None
197
213
0 commit comments