Changeset 4608
- Timestamp:
- 08/25/08 20:51:26 (5 years ago)
- Location:
- developers/werner/ahrt/host/tmc
- Files:
-
- 5 edited
-
lib/instrument.py (modified) (2 diffs)
-
lib/scope.py (modified) (8 diffs)
-
lib/wave.py (modified) (3 diffs)
-
python.c (modified) (1 diff)
-
usbtmc.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
developers/werner/ahrt/host/tmc/lib/instrument.py
r4601 r4608 39 39 self.value = None 40 40 elif value != self.value: 41 self.value = value 41 42 if self.out_convert: 42 43 value = self.out_convert(value) … … 45 46 self.instr.send((self.set_cmd, self.path)[self.set_cmd is None]+ 46 47 " "+self.args+str(value)) 47 self.value = value48 48 49 49 -
developers/werner/ahrt/host/tmc/lib/scope.py
r4601 r4608 3 3 # scope.py - Oscilloscope control 4 4 # 5 6 # Found screen dump algorithm here: 7 # http://www.circuitsonline.net/forum/view/message/652573#652573 5 8 6 9 # … … 20 23 # TODO: make range configurable 21 24 22 def scale_125(n, fuzz): 25 def scale_125(n = None, fuzz = None, min = None, max = None): 26 res = None 23 27 for e in range(-9, 1+1): 24 28 for m in [1, 2, 5]: … … 28 32 s = str(m)+"0"*e 29 33 r = float(s) 30 if r >= n*(1-fuzz) and r <= n*(1+fuzz):34 if n is not None and r >= n*(1-fuzz) and r <= n*(1+fuzz): 31 35 return s 36 if min is not None and r >= min: 37 return s 38 if max is not None and r <= max: 39 res = s 40 if res is not None: 41 return res 42 raise hell 32 43 33 44 … … 97 108 98 109 def wave(self, start = None, end = None, step = None): 99 return self.scope.download_wave(self, start, end, step) 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 100 142 101 143 … … 197 239 def rigol_channel_data(s, t0, td, v0, vd): 198 240 res = analog_wave() 199 i = 2 02200 while i != 8 00:201 div = (i-5 02)/50.0241 i = 212 242 while i != 812: 243 div = (i-512)/50.0 202 244 t = t0+div*td 203 245 div = (125-ord(s[i]))/25.0 … … 212 254 for b in range(0, 16): 213 255 res.append(digital_wave()) 214 i = 4 12215 while i != 16 12:216 div = (i-10 12)/100.0256 i = 424 257 while i != 1624: 258 div = (i-1024)/100.0 217 259 t = t0+div*td 218 260 for b in range(0, 8): … … 223 265 224 266 267 def rigol_to_ppm(s): 268 lut = [] 269 i = 0 270 while i != 256: 271 lut.append(chr(i & 0xc0)+chr((i & 0x38) << 2)+chr((i & 3) << 5)) 272 i += 1 273 res = "P6 320 234 255\n" 274 i = 0 275 while i != 320*234: 276 res += lut[ord(s[i])] 277 i += 1 278 return res 279 280 225 281 class rigol_ds1000c(scope): 226 282 channels = 2 227 283 div_hor = 12 228 284 div_vert = 10 285 samples_per_div = 600 #@@@ not exactly true. needs more investigation 229 286 230 287 def __init__(self): … … 274 331 data = self.query(":WAV:DATA? DIG") 275 332 return rigol_la_data(data, self.hor.pos, self.hor.scale) 333 334 def sampling_rate(self): 335 return float(self.query(":ACQ:SAMP? CH1")) 336 337 def screendump(self): 338 self.send(":HARDCOPY") 339 return rigol_to_ppm(self.query(":LCD:DATA?")) -
developers/werner/ahrt/host/tmc/lib/wave.py
r4601 r4608 111 111 raise hell 112 112 self.data.append((t, y)) 113 114 def extend(self, wave): 115 if len(self.data) and len(wave.data) and \ 116 wave.data[0][0] < self.data[-1][0]: 117 raise hell 118 self.data.extend(wave.data) 113 119 114 120 def get_one(self, t): … … 154 160 self.initial = None 155 161 self.data = [] 156 self.cursor = None157 162 self.t_end = None 158 163 … … 173 178 self.data.append(t) 174 179 self.t_end = t 180 181 def extend(self, wave): 182 if wave.t_end is None: 183 return 184 if self.t_end is None: 185 self.t_end = wave.t_end 186 self.data = wave.data 187 self.initial = wave.initial 188 return 189 if wave.data[0] < self.t_end: 190 raise hell 191 if self.initial ^ (len(self.data) & 1) == wave.initial: 192 self.data.extend(wave.data) 193 else: 194 self.data.extend(wave.data[1:]) 195 self.t_end = wave.t_end 175 196 176 197 def get_one(self, t): -
developers/werner/ahrt/host/tmc/python.c
r4526 r4608 18 18 19 19 20 #define BUF_SIZE 819220 #define BUF_SIZE (1024*1024) 21 21 #define ERROR fprintf(stderr, "ERROR %d\n", __LINE__) 22 22 /* @@@FIXME: raise exceptions */ -
developers/werner/ahrt/host/tmc/usbtmc.c
r4601 r4608 15 15 * http://www.home.agilent.com/upload/cmc_upload/All/usbtmc.html 16 16 * http://www.home.agilent.com/upload/cmc_upload/All/usbtmc.tar 17 * 18 * The Rigol protocol variant is based on this driver: 19 * http://www.circuitsonline.net/forum/view/message/652371#652371 17 20 */ 18 21 … … 43 46 #endif 44 47 45 #define SIZE_IOBUFFER 409648 #define SIZE_IOBUFFER (1024*1024) /* memory is cheap ;-) */ 46 49 47 50 #define DEV_DEP_MSG_OUT 1 … … 669 672 if (d->rigol && payload > 64-12) { 670 673 got = usb_bulk_read(d->handle, d->ep_bulk_in, 671 (void *) tmp+64 -12, payload-12, d->timeout);672 dump("RECV", tmp+64 -12, got);674 (void *) tmp+64, payload-(64-12), d->timeout); 675 dump("RECV", tmp+64, got); 673 676 } 674 677
Note: See TracChangeset
for help on using the changeset viewer.
