Changeset 4610
- Timestamp:
- 08/26/08 04:54:54 (5 years ago)
- File:
-
- 1 edited
-
developers/werner/ahrt/host/tmc/lib/scope.py (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
developers/werner/ahrt/host/tmc/lib/scope.py
r4608 r4610 4 4 # 5 5 6 # Found screen dump algorithm here:6 # Found Rigol screen dump algorithm here: 7 7 # http://www.circuitsonline.net/forum/view/message/652573#652573 8 # 9 # Rigol data retrieval is heavily based on 10 # http://prive.bitwizard.nl/rigol/rigol-0.1rew3.tgz 11 # 8 12 9 13 # … … 24 28 25 29 def scale_125(n = None, fuzz = None, min = None, max = None): 30 epsilon = 1e-15 26 31 res = None 27 32 for e in range(-9, 1+1): … … 34 39 if n is not None and r >= n*(1-fuzz) and r <= n*(1+fuzz): 35 40 return s 36 if min is not None and r >= min :41 if min is not None and r >= min-epsilon: 37 42 return s 38 if max is not None and r <= max :43 if max is not None and r <= max+epsilon: 39 44 res = s 40 45 if res is not None: … … 108 113 109 114 def wave(self, start = None, end = None, step = None): 110 width = self.scope.div_hor*self.scope.hor.scale 111 if start is None and end is None: 112 start = self.scope.hor.pos 113 if start is not None and end is None: 114 end = start+width 115 elif start is None and end is not None: 116 start = end-width 117 if step is None: 118 return self.scope.download_wave(self, start, end, None) 119 else: 120 # @@@ put setting the horizontal system into download_wave 121 if step*self.scope.sampling_rate() < 1: 122 raise hell 123 span = step*self.scope.samples_per_div*self.scope.div_hor 124 if False and span >= start-end: 125 return self.scope.download_wave(self, start, end, None) 126 else: 127 scale = float(scale_125(max = step*self.scope.samples_per_div)) 128 orig_pos = self.scope.hor.pos 129 orig_scale = self.scope.hor.scale 130 self.scope.hor.scale = scale 131 span = self.scope.div_hor*self.scope.hor.scale 132 wave = analog_wave() 133 pos = start 134 while pos < end: 135 self.scope.hor.pos = pos 136 wave.extend(self.scope.download_wave(self, pos, pos+span, 137 None)) 138 pos += span 139 self.scope.hor.pos = orig_pos 140 self.scope.hor.scale = orig_scale 141 return wave 115 # @@@ move start and end adjustment here ! 116 return self.scope.download_wave(self, start, end, step) 142 117 143 118 … … 150 125 self.scope = scope 151 126 self.pos = setting(scope, ":TIM:OFFS", 152 lambda x: float(x)) 127 lambda x: float(x), 128 lambda x: "%.9f" % x) 153 129 self.scale = setting(scope, ":TIM:SCAL", 154 lambda x: float(x)) 130 lambda x: float(x), 131 lambda x: "%.9f" % x) 155 132 self.forget() 156 133 … … 265 242 266 243 244 def rigol_wave(scope, start, end, step, query, merge, fn, *args): 245 wave = None 246 orig_pos = scope.hor.pos 247 orig_scale = scope.hor.scale 248 249 width = scope.div_hor*orig_scale 250 if start is None: 251 start = orig_pos-width/2 252 if end is None: 253 end = orig_pos+width/2 254 if step is None: 255 step = 1/scope.sampling_rate() 256 257 scope.hor.scale = float(scale_125(max = step*scope.samples_per_div)) 258 while start < end: 259 scope.hor.pos = start+6*scope.hor.scale 260 data = scope.query(query) 261 data = fn(data, scope.hor.pos, scope.hor.scale, *args) 262 if wave is None: 263 wave = data 264 else: 265 merge(wave, data) 266 start += 12*scope.hor.scale 267 268 scope.hor.pos = orig_pos 269 scope.hor.scale = orig_scale 270 return wave 271 272 273 def rigol_extend_la(a, b): 274 i = 0 275 while i != 16: 276 a[i].extend(b[i]) 277 i += 1 278 279 267 280 def rigol_to_ppm(s): 268 281 lut = [] … … 283 296 div_hor = 12 284 297 div_vert = 10 285 samples_per_div = 600 #@@@ not exactly true. needs more investigation298 samples_per_div = 50 286 299 287 300 def __init__(self): … … 322 335 if self.ch[n] == channel: 323 336 c_num = n+1 324 data = self.query(":WAV:DATA? CHAN"+str(c_num)) 325 return rigol_channel_data(data, self.hor.pos, self.hor.scale, 326 channel.pos, channel.scale) 337 return rigol_wave(self, start, end, step, 338 ":WAV:DATA? CHAN"+str(c_num), 339 lambda a, b: a.extend(b), 340 rigol_channel_data, channel.pos, channel.scale) 327 341 328 342 # experimental 329 343 330 def download_la(self): 331 data = self.query(":WAV:DATA? DIG") 332 return rigol_la_data(data, self.hor.pos, self.hor.scale) 344 def download_la(self, start = None, end = None, step = None): 345 return rigol_wave(self, start, end, step, 346 ":WAV:DATA? DIG", 347 rigol_extend_la, rigol_la_data) 333 348 334 349 def sampling_rate(self):
Note: See TracChangeset
for help on using the changeset viewer.
