API Reference
This page provides the automatically generated documentation for the core classes and drivers.
Base Classes
Bases: ABC
Abstract Base Class for all instrument drivers following the 'Abstract Hardware' spec.
Source code in src/instrumation/drivers/base.py
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 | |
__getattr__(name)
Dynamic async wrapper for all driver methods.
Source code in src/instrumation/drivers/base.py
25 26 27 28 29 30 31 32 33 34 | |
check_errors()
abstractmethod
Queries SYST:ERR? and updates local error_stack.
Source code in src/instrumation/drivers/base.py
99 100 101 102 | |
clear_status()
abstractmethod
Executes *CLS.
Source code in src/instrumation/drivers/base.py
79 80 81 82 | |
connect()
abstractmethod
Establishes connection and performs identity/option discovery.
Source code in src/instrumation/drivers/base.py
41 42 43 44 | |
disconnect()
abstractmethod
Safely tears down connection.
Source code in src/instrumation/drivers/base.py
46 47 48 49 | |
format_frequency(val)
Ensures input is Hz and formats for SCPI (e.g. 1.5e9 -> '1.5 GHz').
Source code in src/instrumation/drivers/base.py
113 114 115 116 117 118 119 120 121 122 123 | |
load_state(index)
Recalls state from memory.
Source code in src/instrumation/drivers/base.py
108 109 110 | |
query_ascii(command)
Sends command, reads response, and checks for errors.
Source code in src/instrumation/drivers/base.py
64 65 66 | |
query_binary_values(command, datatype='f', is_big_endian=False)
High-speed binary data transfer.
Source code in src/instrumation/drivers/base.py
68 69 70 | |
safe_send(command)
Sends command and immediately checks SYST:ERR?.
Source code in src/instrumation/drivers/base.py
60 61 62 | |
save_state(index)
Saves current state to memory.
Source code in src/instrumation/drivers/base.py
104 105 106 | |
shutdown_safety()
abstractmethod
Emergency shutdown protocol (Outputs OFF, Power/Volt 0).
Source code in src/instrumation/drivers/base.py
94 95 96 97 | |
sync_config()
abstractmethod
Executes CLS and WAI for a clean slate.
Source code in src/instrumation/drivers/base.py
84 85 86 87 | |
wait_ready(timeout=30.0)
abstractmethod
Standard polling loop for *OPC?.
Source code in src/instrumation/drivers/base.py
89 90 91 92 | |
Bases: InstrumentDriver
Source code in src/instrumation/drivers/base.py
293 294 295 296 297 298 299 300 301 302 303 304 305 | |
Bases: InstrumentDriver
Source code in src/instrumation/drivers/base.py
307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 | |
get_mode()
Returns the current operation mode (CV, CC, or OFF).
Source code in src/instrumation/drivers/base.py
360 361 362 363 | |
measure_power()
Queries the actual measured output power (Watts).
Source code in src/instrumation/drivers/base.py
343 344 345 346 | |
measure_voltage()
Generalized alias for measure_voltage_actual.
Source code in src/instrumation/drivers/base.py
336 337 338 | |
set_autostart(state)
Sets the Power-ON state (SAFE/OFF or AUTO/ON).
Source code in src/instrumation/drivers/base.py
356 357 358 | |
set_current(current)
Generalized alias for set_current_limit.
Source code in src/instrumation/drivers/base.py
314 315 316 | |
set_foldback_delay(seconds)
Sets the delay for foldback protection.
Source code in src/instrumation/drivers/base.py
352 353 354 | |
set_foldback_mode(mode)
Sets the foldback protection mode (OFF, CC, or CV).
Source code in src/instrumation/drivers/base.py
348 349 350 | |
set_voltage_limit(voltage)
Generalized alias for Over-Voltage Protection (OVP).
Source code in src/instrumation/drivers/base.py
332 333 334 | |
Bases: InstrumentDriver
Source code in src/instrumation/drivers/base.py
365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 | |
get_peak_value()
Helper: Performs peak search and returns marker amplitude.
Source code in src/instrumation/drivers/base.py
385 386 387 388 | |
Bases: InstrumentDriver
Source code in src/instrumation/drivers/base.py
390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 | |
set_center_frequency(freq_hz)
Alias for set_center_freq.
Source code in src/instrumation/drivers/base.py
399 400 401 | |
wait_for_sweep()
Wait for the current sweep to complete.
Source code in src/instrumation/drivers/base.py
453 454 455 | |
Bases: InstrumentDriver
Source code in src/instrumation/drivers/base.py
457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 | |
Bases: InstrumentDriver
Source code in src/instrumation/drivers/base.py
479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 | |
Bases: InstrumentDriver
Source code in src/instrumation/drivers/base.py
159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 | |
clear_protection()
abstractmethod
Clears any tripped protection status.
Source code in src/instrumation/drivers/base.py
250 251 252 253 | |
get_current()
abstractmethod
Returns the set current value in CC mode.
Source code in src/instrumation/drivers/base.py
175 176 177 178 | |
get_input()
abstractmethod
Returns the input state (ON/OFF).
Source code in src/instrumation/drivers/base.py
215 216 217 218 | |
get_mode()
abstractmethod
Returns the active operating mode.
Source code in src/instrumation/drivers/base.py
165 166 167 168 | |
get_power()
abstractmethod
Returns the set power value in CP mode.
Source code in src/instrumation/drivers/base.py
205 206 207 208 | |
get_resistance()
abstractmethod
Returns the set resistance value in CR mode.
Source code in src/instrumation/drivers/base.py
195 196 197 198 | |
get_voltage()
abstractmethod
Returns the set voltage value in CV mode.
Source code in src/instrumation/drivers/base.py
185 186 187 188 | |
measure_current()
abstractmethod
Measures the actual current being drawn by the load.
Source code in src/instrumation/drivers/base.py
225 226 227 228 | |
measure_power()
abstractmethod
Measures the actual power being consumed by the load.
Source code in src/instrumation/drivers/base.py
230 231 232 233 | |
measure_voltage()
abstractmethod
Measures the actual input voltage at the load terminals.
Source code in src/instrumation/drivers/base.py
220 221 222 223 | |
set_current(amps)
abstractmethod
Sets the constant current value in CC mode.
Source code in src/instrumation/drivers/base.py
170 171 172 173 | |
set_input(state)
abstractmethod
Turns the load input ON (True) or OFF (False).
Source code in src/instrumation/drivers/base.py
210 211 212 213 | |
set_mode(mode)
abstractmethod
Sets the operating mode, typically CC, CV, CR, or CP.
Source code in src/instrumation/drivers/base.py
160 161 162 163 | |
set_ocp(current)
abstractmethod
Sets the over-current protection limit.
Source code in src/instrumation/drivers/base.py
240 241 242 243 | |
set_opp(power)
abstractmethod
Sets the over-power protection limit.
Source code in src/instrumation/drivers/base.py
245 246 247 248 | |
set_ovp(voltage)
abstractmethod
Sets the over-voltage protection limit.
Source code in src/instrumation/drivers/base.py
235 236 237 238 | |
set_power(watts)
abstractmethod
Sets the constant power value in CP mode.
Source code in src/instrumation/drivers/base.py
200 201 202 203 | |
set_resistance(ohms)
abstractmethod
Sets the constant resistance value in CR mode.
Source code in src/instrumation/drivers/base.py
190 191 192 193 | |
set_voltage(volts)
abstractmethod
Sets the constant voltage value in CV mode.
Source code in src/instrumation/drivers/base.py
180 181 182 183 | |
Bases: InstrumentDriver
Abstract Base for Frequency Counters / Timer/Counter instruments.
Source code in src/instrumation/drivers/base.py
255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 | |
measure_frequency(range='AUTO')
abstractmethod
Measures frequency. Range can be 'AUTO' or a specific range in Hz.
Source code in src/instrumation/drivers/base.py
258 259 260 261 | |
measure_period(range='AUTO')
abstractmethod
Measures period. Range can be 'AUTO' or a specific range in seconds.
Source code in src/instrumation/drivers/base.py
263 264 265 266 | |
measure_time_interval(start_trigger, stop_trigger)
abstractmethod
Measures time interval between two events (e.g. 'CH1', 'CH2').
Source code in src/instrumation/drivers/base.py
268 269 270 271 | |
set_auto_range(state)
abstractmethod
Enables or disables auto-ranging.
Source code in src/instrumation/drivers/base.py
288 289 290 291 | |
set_coupling(dc_ac)
abstractmethod
Sets input coupling — 'DC' or 'AC'.
Source code in src/instrumation/drivers/base.py
283 284 285 286 | |
set_impedance(ohms)
abstractmethod
Sets input impedance (50 or 1e6).
Source code in src/instrumation/drivers/base.py
273 274 275 276 | |
set_trigger_level(volts)
abstractmethod
Sets the trigger level voltage.
Source code in src/instrumation/drivers/base.py
278 279 280 281 | |
Oscilloscopes
Bases: RealDriver, Oscilloscope
Driver for Rigol DS1054Z Digital Oscilloscope.
Supports the MSO1000Z/DS1000Z Series (DS1054Z, DS1104Z, MSO1054Z, etc.). Implements edge trigger only; LA, :SOURce, :DECoder, :MASK, :FUNCtion commands are excluded (option-gated or -S variant features).
Source code in src/instrumation/drivers/rigol.py
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 | |
auto_scale()
:AUToscale — Automatically adjust scale for all channels.
Source code in src/instrumation/drivers/rigol.py
110 111 112 113 | |
clear_status()
*CLS — Clear status registers.
Source code in src/instrumation/drivers/rigol.py
95 96 97 | |
clear_waveform()
:CLEar — Clear waveform data.
Source code in src/instrumation/drivers/rigol.py
115 116 117 | |
force_trigger()
:TFORce — Force a trigger event.
Source code in src/instrumation/drivers/rigol.py
131 132 133 | |
get_acquire_type()
:ACQuire:TYPE? — Query acquisition mode.
Source code in src/instrumation/drivers/rigol.py
148 149 150 | |
get_channel_bw_limit(channel)
:CHANnel
Source code in src/instrumation/drivers/rigol.py
273 274 275 276 | |
get_channel_coupling(channel)
:CHANnel
Source code in src/instrumation/drivers/rigol.py
210 211 212 213 | |
get_channel_display(channel)
:CHANnel
Source code in src/instrumation/drivers/rigol.py
192 193 194 195 | |
get_channel_invert(channel)
:CHANnel
Source code in src/instrumation/drivers/rigol.py
288 289 290 291 | |
get_channel_offset(channel)
:CHANnel
Source code in src/instrumation/drivers/rigol.py
240 241 242 243 | |
get_channel_probe(channel)
:CHANnel
Source code in src/instrumation/drivers/rigol.py
255 256 257 258 | |
get_channel_scale(channel)
:CHANnel
Source code in src/instrumation/drivers/rigol.py
225 226 227 228 | |
get_edge_trigger_level()
:TRIGger:EDGe:LEVel? — Query trigger level voltage.
Source code in src/instrumation/drivers/rigol.py
373 374 375 | |
get_edge_trigger_slope()
:TRIGger:EDGe:SLOPe? — Query edge trigger slope.
Source code in src/instrumation/drivers/rigol.py
365 366 367 | |
get_edge_trigger_source()
:TRIGger:EDGe:SOURce? — Query edge trigger source.
Source code in src/instrumation/drivers/rigol.py
350 351 352 | |
get_id()
*IDN? — Query instrument identification.
Source code in src/instrumation/drivers/rigol.py
104 105 106 | |
get_sample_rate()
:ACQuire:SRATe? — Query current sample rate (samples/sec).
Source code in src/instrumation/drivers/rigol.py
172 173 174 | |
get_screenshot()
:DISPlay:DATA? — Capture display screenshot as PNG.
Source code in src/instrumation/drivers/rigol.py
572 573 574 575 | |
get_timebase_mode()
:TIMebase:MODE — Query timebase mode (MAIN, XY, ROLL).
Source code in src/instrumation/drivers/rigol.py
308 309 310 | |
get_timebase_offset()
:TIMebase[:MAIN]:OFFSet? — Query horizontal offset.
Source code in src/instrumation/drivers/rigol.py
332 333 334 | |
get_timebase_scale()
:TIMebase[:MAIN]:SCALe? — Query horizontal scale.
Source code in src/instrumation/drivers/rigol.py
320 321 322 | |
get_trigger_mode()
:TRIGger:MODE — Query trigger mode (EDGE, PULSE, etc.).
Source code in src/instrumation/drivers/rigol.py
338 339 340 | |
get_trigger_status()
:TRIGger:STATus? — Query trigger status.
Returns: TD (triggered), WAIT, AUTO, STOP, T'D, etc.
Source code in src/instrumation/drivers/rigol.py
392 393 394 395 396 397 | |
get_trigger_sweep()
:TRIGger:SWEep? — Query trigger sweep mode.
Source code in src/instrumation/drivers/rigol.py
388 389 390 | |
get_waveform(channel)
Fetch calibrated waveform data for a channel.
Queries :WAVeform:PREamble? and :WAVeform:DATA?, converts raw ADC codes to real voltage values using: V = (raw - yref) * yinc + yor and generates a time axis using: t = (n - xref) * xinc + xor
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
channel
|
int
|
1-4 |
required |
Returns:
| Type | Description |
|---|---|
MeasurementResult
|
MeasurementResult with value=(time_array, voltage_array), unit="V". |
Source code in src/instrumation/drivers/rigol.py
513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 | |
get_waveform_preamble()
:WAVeform:PREamble? — Query and parse the waveform preamble.
Returns a dict with keys: format, type, points, count, x_increment, x_origin, x_reference, y_increment, y_origin, y_reference.
Source code in src/instrumation/drivers/rigol.py
449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 | |
get_waveform_raw(channel)
:WAVeform:DATA? — Fetch raw waveform data as unsigned integers.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
channel
|
int
|
1-4 |
required |
Returns:
| Type | Description |
|---|---|
List[int]
|
List of raw ADC codes (unsigned 8-bit or 16-bit). |
Source code in src/instrumation/drivers/rigol.py
496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 | |
get_waveform_source()
:WAVeform:SOURce? — Query waveform data source.
Source code in src/instrumation/drivers/rigol.py
423 424 425 | |
get_waveform_x_increment()
:WAVeform:XINCrement? — Query X-axis increment (seconds/sample).
Source code in src/instrumation/drivers/rigol.py
472 473 474 | |
get_waveform_x_origin()
:WAVeform:XORigin? — Query X-axis origin (seconds).
Source code in src/instrumation/drivers/rigol.py
476 477 478 | |
get_waveform_x_reference()
:WAVeform:XREFerence? — Query X-axis reference point.
Source code in src/instrumation/drivers/rigol.py
480 481 482 | |
get_waveform_y_increment()
:WAVeform:YINCrement? — Query Y-axis increment (volts/code).
Source code in src/instrumation/drivers/rigol.py
484 485 486 | |
get_waveform_y_origin()
:WAVeform:YORigin? — Query Y-axis origin (volts).
Source code in src/instrumation/drivers/rigol.py
488 489 490 | |
get_waveform_y_reference()
:WAVeform:YREFerence? — Query Y-axis reference code.
Source code in src/instrumation/drivers/rigol.py
492 493 494 | |
measure_duty_cycle(channel=1)
:MEASure:DUTYcycle? — Measure duty cycle on a channel.
Source code in src/instrumation/drivers/rigol.py
562 563 564 565 | |
measure_frequency(channel=1)
:MEASure:FREQuency? — Measure frequency on a channel.
Source code in src/instrumation/drivers/rigol.py
557 558 559 560 | |
measure_v_peak_to_peak(channel=1)
:MEASure:VPP? — Measure Vpp on a channel.
Source code in src/instrumation/drivers/rigol.py
567 568 569 570 | |
preset(automation_optimized=True)
*RST — Factory default reset.
Source code in src/instrumation/drivers/rigol.py
90 91 92 93 | |
run()
:RUN — Start acquisition.
Source code in src/instrumation/drivers/rigol.py
119 120 121 | |
set_acquire_averages(count)
:ACQuire:AVERages — Set averaging count (2^n, n=1..10).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
count
|
int
|
Must be a power of 2 between 2 and 1024. |
required |
Source code in src/instrumation/drivers/rigol.py
152 153 154 155 156 157 158 159 160 161 162 | |
set_acquire_memory_depth(mdep)
:ACQuire:MDEPth — Set memory depth.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mdep
|
int
|
Memory depth in points (14k, 140k, or 14M for DS1054Z). |
required |
Source code in src/instrumation/drivers/rigol.py
164 165 166 167 168 169 170 | |
set_acquire_type(acquire_type)
:ACQuire:TYPE — Set acquisition mode.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
acquire_type
|
str
|
NORMal, AVERages, PEAK, or HRESolution. |
required |
Source code in src/instrumation/drivers/rigol.py
137 138 139 140 141 142 143 144 145 146 | |
set_channel_bw_limit(channel, bw)
:CHANnel
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
channel
|
int
|
1-4 |
required |
bw
|
str
|
20M (20 MHz) or OFF |
required |
Source code in src/instrumation/drivers/rigol.py
260 261 262 263 264 265 266 267 268 269 270 271 | |
set_channel_coupling(channel, coupling)
:CHANnel
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
channel
|
int
|
1-4 |
required |
coupling
|
str
|
AC, DC, or GND |
required |
Source code in src/instrumation/drivers/rigol.py
197 198 199 200 201 202 203 204 205 206 207 208 | |
set_channel_display(channel, state)
:CHANnel
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
channel
|
int
|
1-4 |
required |
state
|
bool
|
True=ON, False=OFF |
required |
Source code in src/instrumation/drivers/rigol.py
182 183 184 185 186 187 188 189 190 | |
set_channel_invert(channel, state)
:CHANnel
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
channel
|
int
|
1-4 |
required |
state
|
bool
|
True=ON, False=OFF |
required |
Source code in src/instrumation/drivers/rigol.py
278 279 280 281 282 283 284 285 286 | |
set_channel_offset(channel, offset)
:CHANnel
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
channel
|
int
|
1-4 |
required |
offset
|
float
|
DC offset voltage |
required |
Source code in src/instrumation/drivers/rigol.py
230 231 232 233 234 235 236 237 238 | |
set_channel_probe(channel, attenuation)
:CHANnel
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
channel
|
int
|
1-4 |
required |
attenuation
|
float
|
Probe ratio (e.g. 1.0, 10.0) |
required |
Source code in src/instrumation/drivers/rigol.py
245 246 247 248 249 250 251 252 253 | |
set_channel_scale(channel, scale)
:CHANnel
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
channel
|
int
|
1-4 |
required |
scale
|
float
|
Volts per division (e.g. 0.01 to 10.0) |
required |
Source code in src/instrumation/drivers/rigol.py
215 216 217 218 219 220 221 222 223 | |
set_channel_units(channel, units)
:CHANnel
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
channel
|
int
|
1-4 |
required |
units
|
str
|
VOLTage, WATT, AMPere, or UNKNown |
required |
Source code in src/instrumation/drivers/rigol.py
293 294 295 296 297 298 299 300 301 302 303 304 | |
set_edge_trigger_level(level)
:TRIGger:EDGe:LEVel — Set trigger level voltage.
Source code in src/instrumation/drivers/rigol.py
369 370 371 | |
set_edge_trigger_slope(slope)
:TRIGger:EDGe:SLOPe — Set edge trigger slope.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
slope
|
str
|
POSitive, NEGative, or RFALl |
required |
Source code in src/instrumation/drivers/rigol.py
354 355 356 357 358 359 360 361 362 363 | |
set_edge_trigger_source(source)
:TRIGger:EDGe:SOURce — Set edge trigger source.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source
|
str
|
CHANnel1, CHANnel2, CHANnel3, CHANnel4, EXT, or DEMath |
required |
Source code in src/instrumation/drivers/rigol.py
342 343 344 345 346 347 348 | |
set_timebase_offset(offset)
:TIMebase[:MAIN]:OFFSet — Set horizontal offset (seconds).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
offset
|
float
|
Time offset from trigger point |
required |
Source code in src/instrumation/drivers/rigol.py
324 325 326 327 328 329 330 | |
set_timebase_scale(scale)
:TIMebase[:MAIN]:SCALe — Set horizontal scale (seconds/div).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
scale
|
float
|
Seconds per division (e.g. 1e-9 to 50.0) |
required |
Source code in src/instrumation/drivers/rigol.py
312 313 314 315 316 317 318 | |
set_trigger(source, level, slope)
Configure edge trigger (Oscilloscope interface convenience method).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source
|
str
|
CHANnel1, CHANnel2, etc. |
required |
level
|
float
|
Trigger level in volts |
required |
slope
|
str
|
POSITIVE, NEGATIVE, or RFALL |
required |
Source code in src/instrumation/drivers/rigol.py
399 400 401 402 403 404 405 406 407 408 409 410 | |
set_trigger_sweep(sweep)
:TRIGger:SWEep — Set trigger sweep mode.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sweep
|
str
|
AUTO, NORMal, or SINGle |
required |
Source code in src/instrumation/drivers/rigol.py
377 378 379 380 381 382 383 384 385 386 | |
set_waveform_format(fmt)
:WAVeform:FORMat — Set waveform data format.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
fmt
|
str
|
WORD, BYTE, or ASCii |
required |
Source code in src/instrumation/drivers/rigol.py
438 439 440 441 442 443 444 445 446 447 | |
set_waveform_mode(mode)
:WAVeform:MODE — Set waveform readout mode.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mode
|
str
|
NORMal, MAXimum, or RAW |
required |
Source code in src/instrumation/drivers/rigol.py
427 428 429 430 431 432 433 434 435 436 | |
set_waveform_source(channel)
:WAVeform:SOURce — Select waveform data source.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
channel
|
int
|
1-4 (maps to CHANnel1..CHANnel4) |
required |
Source code in src/instrumation/drivers/rigol.py
414 415 416 417 418 419 420 421 | |
shutdown_safety()
Stop acquisition and sync.
Source code in src/instrumation/drivers/rigol.py
579 580 581 582 | |
single()
:SINGle — Single-shot acquisition.
Source code in src/instrumation/drivers/rigol.py
127 128 129 | |
stop()
:STOP — Stop acquisition.
Source code in src/instrumation/drivers/rigol.py
123 124 125 | |
sync_config()
CLS + WAI — Synchronize.
Source code in src/instrumation/drivers/rigol.py
99 100 101 102 | |
Results
Standardized object for measurement results.
Attributes:
| Name | Type | Description |
|---|---|---|
value |
Any
|
The measured value (float, complex, list, or numpy array). |
unit |
str
|
The physical unit of the measurement (e.g., 'V', 'Hz', 'dBm'). |
timestamp |
datetime
|
The time the measurement was taken. |
status |
str
|
Status of the measurement ('OK', 'ERROR', 'OVERLOAD', etc.). |
channel |
Optional[Union[int, str]]
|
Optional channel index for multi-channel instruments. |
metadata |
Optional[Dict[str, Any]]
|
Optional additional information from the driver. |
Source code in src/instrumation/results.py
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 | |
__float__()
Allows direct conversion to float if the value is a scalar.
Source code in src/instrumation/results.py
40 41 42 | |
__format__(format_spec)
Allows MeasurementResult to be used in f-strings with float formatting.
Source code in src/instrumation/results.py
34 35 36 37 38 | |
__getitem__(key)
Allows indexing into the MeasurementResult value.
Source code in src/instrumation/results.py
48 49 50 | |
__iter__()
Allows iterating over the MeasurementResult value.
Source code in src/instrumation/results.py
52 53 54 | |
__len__()
Allows MeasurementResult to be used with len() if the value is a collection.
Source code in src/instrumation/results.py
44 45 46 | |
to_dict()
Converts the result to a JSON-serializable dictionary.
Source code in src/instrumation/results.py
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 | |
to_json()
Returns the JSON string representation of the result.
Source code in src/instrumation/results.py
83 84 85 | |
Factory
Connect to an instrument and return a driver instance for it.
The address is resolved in priority order:
- Replay -- an address beginning with
replay://returns aReplayDriverthat reads from the file named after the prefix. - Simulation -- when :func:
is_sim_modeis true, a simulated driver registered fordriver_typeis returned instead of touching hardware. - Auto-discovery -- the literal address
"AUTO"searches for a matching instrument, trying the on-disk cache first, then mDNS, then the LAN ARP table, then a full VISA scan. - Real hardware -- any other address is opened directly, identified via
*IDN?, and routed to the matching vendor driver.
Parameters
resource_address : str
A VISA resource string such as "TCPIP::192.168.1.5::INSTR", a
replay:// file path, or the literal "AUTO" to auto-discover.
driver_type : str, optional
Instrument category used to select and validate the driver. One of
"SCOPE", "SA", "SG", "PSU", "DMM", "VNA",
"NA", "LOAD", "ELOAD", "COUNTER" or "GENERIC".
Defaults to "GENERIC", which accepts any instrument.
Returns
object A connected driver instance. The concrete class depends on which instrument was identified.
Raises
ValueError
If simulation mode is active, driver_type is not "GENERIC" and
no simulated driver is registered for that type; or if "AUTO"
discovery finds no matching instrument.
Notes
Resources found through "AUTO" discovery are written to
.visa_cache.json in the working directory, most recent first, so later
lookups try them before falling back to a full scan.
Examples
dmm = get_instrument("TCPIP::192.168.1.5::INSTR", "DMM") scope = get_instrument("AUTO", "SCOPE")
Source code in src/instrumation/factory.py
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 | |
Dynamically loads all available instrument drivers.
Source code in src/instrumation/factory.py
461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 | |
Transport Utilities
Detect which line-termination character an instrument responds to.
Tries each common terminator (LF, CR, CRLF) against a safe SCPI query and returns the first one that produces a valid response.
Steps
- Save the instrument's current read_termination setting.
- For each candidate terminator in ["\n", "\r", "\r\n"]: a. Set instrument.read_termination to the candidate. b. Send the query (default "IDN?"). c. If the response is non-empty and looks like a valid IDN? reply (contains at least one comma), return the candidate terminator.
- If none work, restore the original termination and raise RuntimeError.
- Restore the original termination before returning.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
instrument
|
Any
|
A connected VisaDriver or pyvisa Resource object with .write(), .query(), and .read_termination attributes. |
required |
query
|
str
|
The SCPI query to test with. Defaults to "*IDN?". |
'*IDN?'
|
Returns:
| Type | Description |
|---|---|
str
|
The working terminator string: "\n", "\r", or "\r\n". |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If no candidate terminator produces a valid response. |
Source code in src/instrumation/transport.py
224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 | |
Find the smallest safe timeout value for an instrument.
Tries a list of candidate timeout values (in milliseconds) against a safe SCPI query and returns the first one that completes without timing out.
Steps
- If candidates is None, use [100, 250, 500, 1000, 2500, 5000].
- Save the instrument's current timeout setting.
- Sort candidates ascending (smallest first).
- For each candidate timeout: a. Set instrument.timeout to the candidate. b. Send the query. c. If the response is non-empty, restore the original timeout and return the candidate. d. If a VisaIOError or timeout exception occurs, continue to the next.
- If no candidate works, restore the original timeout and raise RuntimeError.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
instrument
|
Any
|
A connected VisaDriver or pyvisa Resource object with .write(), .query(), and .timeout attributes. |
required |
query
|
str
|
The SCPI query to test with. Defaults to "*IDN?". |
'*IDN?'
|
candidates
|
Optional[List[int]]
|
List of timeout values in ms to try. Defaults to [100, 250, 500, 1000, 2500, 5000]. |
None
|
Returns:
| Type | Description |
|---|---|
int
|
The smallest timeout value (in ms) that worked. |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If no candidate timeout produces a valid response. |
Source code in src/instrumation/transport.py
267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 | |
Poll an instrument's status byte for the MAV (Message Available) bit.
Instead of reading immediately or sleeping blindly, this polls the Status Byte Register (STB) until bit 4 (MAV) is set, indicating the instrument has data ready to read.
Steps
- Record the start time.
- Loop until timeout is exceeded: a. Send "*STB?" or "STB?" to read the status byte. b. Parse the response as an integer. c. If bit 4 (value & 0x10) is set, return — data is ready. d. Sleep for poll_interval seconds.
- If the loop exits without MAV being set, raise InstrumentTimeout.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
instrument
|
Any
|
A connected VisaDriver or pyvisa Resource object. |
required |
timeout
|
float
|
Maximum seconds to wait for MAV. Defaults to 10.0. |
10.0
|
poll_interval
|
float
|
Seconds between polls. Defaults to 0.1. |
0.1
|
Raises:
| Type | Description |
|---|---|
InstrumentTimeout
|
If MAV is not set within the timeout period. |
Source code in src/instrumation/transport.py
322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 | |
Poll for operation-complete (*OPC?) with exponential backoff delay.
Sends *OPC? and waits for "1" as the response, but instead of polling at a fixed interval, uses exponential backoff to reduce bus traffic during long operations while still responding quickly to fast completions.
Steps
- Record the start time. Set current_delay = initial_delay.
- Loop until timeout is exceeded: a. Send "*OPC?" and read the response. b. If the response stripped is "1", return — operation complete. c. Sleep for current_delay seconds. d. Multiply current_delay by 2, capped at max_delay.
- If the loop exits without completion, raise InstrumentTimeout.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
instrument
|
Any
|
A connected VisaDriver or pyvisa Resource object. |
required |
timeout
|
float
|
Maximum seconds to wait. Defaults to 30.0. |
30.0
|
initial_delay
|
float
|
Starting poll delay in seconds. Defaults to 0.1. |
0.1
|
max_delay
|
float
|
Maximum delay between polls in seconds. Defaults to 1.0. |
1.0
|
Raises:
| Type | Description |
|---|---|
InstrumentTimeout
|
If *OPC? does not return "1" within the timeout. |
Source code in src/instrumation/transport.py
400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 | |
Send multiple SCPI queries and return a dictionary of results.
This is useful for fetching multiple instrument settings or readings in a single call, reducing round-trips and improving efficiency on slow connections. Failed queries are logged with their error messages rather than raising immediately (unless stop_on_error=True).
Steps
- Initialize an empty results dictionary.
- For each query in the list: a. Send the query via instrument.query(). b. Store the stripped response in results[query]. c. If the query fails and stop_on_error is True, raise the exception. d. If stop_on_error is False, store the error message as the value.
- For each (write_cmd, read_cmd) pair in write_then_read: a. Send write_cmd via instrument.write(), then read_cmd via instrument.query(). b. Store the stripped response in results[write_cmd]. c. Same stop_on_error/error-message behavior as queries.
- Return the results dictionary.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
instrument
|
Any
|
A connected VisaDriver or pyvisa Resource object. |
required |
queries
|
List[str]
|
List of SCPI query strings to send. |
required |
stop_on_error
|
bool
|
If True, raise on first error. If False (default), store error messages and continue with remaining queries. |
False
|
write_then_read
|
Optional[List[Tuple[str, str]]]
|
Optional list of (write_cmd, read_cmd) pairs for instruments that need a separate write before the read (e.g. writing a register address, then reading its value). Results are keyed by write_cmd. |
None
|
Returns:
| Type | Description |
|---|---|
dict
|
A dictionary mapping each query string (or write_then_read write_cmd) |
dict
|
to its response (or error message). |
Example
results = batch_query(dmm, ["IDN?", "MEAS:VOLT:DC?", "STB?"]) for cmd, resp in results.items(): ... print(f"{cmd} -> {resp}")
results = batch_query(inst, [], write_then_read=[("REG 0", "REG?")]) results["REG 0"]
Source code in src/instrumation/transport.py
448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 | |
Scanner Utilities
Find addresses that appear more than once with different identities.
On shared buses (GPIB, RS-485), two instruments configured with the same address will corrupt each other's responses. This function flags addresses that show up multiple times in a scan result with differing descriptions, which is the telltale sign of a bus conflict.
Steps
- Build a dict mapping each device "id" (address) to a list of its "desc" values across all scan results.
- For each address that has more than one distinct description:
a. Create a conflict entry with:
- "address": the duplicated address string
- "identities": the list of distinct descriptions seen
- "count": how many times it appeared b. Append it to the results list.
- Return the list of conflict entries. Empty list means no conflicts.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
devices
|
List[Dict[str, str]]
|
The list of device dicts returned by scan(), each having keys "type", "id", and "desc". |
required |
Returns:
| Type | Description |
|---|---|
List[Dict[str, Any]]
|
A list of dicts, each with keys "address" (str), "identities" (list |
List[Dict[str, Any]]
|
of str), and "count" (int). Empty list if no duplicates found, and |
List[Dict[str, Any]]
|
also for empty or |
Example
devices = scan() conflicts = find_duplicate_addresses(devices) for c in conflicts: ... print(f"CONFLICT on {c['address']}: {c['identities']}")
Source code in src/instrumation/scanner.py
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 | |