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
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 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 | |
__getattr__(name)
Dynamic async wrapper for all driver methods.
Source code in src/instrumation/drivers/base.py
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 | |
check_errors()
abstractmethod
Queries SYST:ERR? and updates local error_stack.
Source code in src/instrumation/drivers/base.py
141 142 143 144 | |
clear_status()
abstractmethod
Executes *CLS.
Source code in src/instrumation/drivers/base.py
121 122 123 124 | |
connect()
abstractmethod
Establishes connection and performs identity/option discovery.
Source code in src/instrumation/drivers/base.py
80 81 82 83 | |
disconnect()
abstractmethod
Safely tears down connection.
Source code in src/instrumation/drivers/base.py
85 86 87 88 | |
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
155 156 157 158 159 160 161 162 163 164 165 | |
load_state(index)
Recalls state from memory.
Source code in src/instrumation/drivers/base.py
150 151 152 | |
query_ascii(command)
abstractmethod
Sends command, reads response, and checks for errors.
Source code in src/instrumation/drivers/base.py
104 105 106 107 | |
query_binary_values(command, datatype='f', is_big_endian=False)
abstractmethod
High-speed binary data transfer.
Source code in src/instrumation/drivers/base.py
109 110 111 112 | |
safe_send(command)
abstractmethod
Sends command and immediately checks SYST:ERR?.
Source code in src/instrumation/drivers/base.py
99 100 101 102 | |
save_state(index)
Saves current state to memory.
Source code in src/instrumation/drivers/base.py
146 147 148 | |
shutdown_safety()
abstractmethod
Emergency shutdown protocol (Outputs OFF, Power/Volt 0).
Source code in src/instrumation/drivers/base.py
136 137 138 139 | |
supports(feature)
True if this driver implements feature (a method name).
A method counts as unsupported when the driver inherits the
library's generic _unsupported_feature default for it.
Source code in src/instrumation/drivers/base.py
185 186 187 188 189 190 191 192 | |
sync_config()
abstractmethod
Executes CLS and WAI for a clean slate.
Source code in src/instrumation/drivers/base.py
126 127 128 129 | |
wait_ready(timeout=30.0)
abstractmethod
Standard polling loop for *OPC?.
Source code in src/instrumation/drivers/base.py
131 132 133 134 | |
Bases: InstrumentDriver
Source code in src/instrumation/drivers/base.py
459 460 461 462 463 464 465 466 467 468 469 470 471 | |
Bases: InstrumentDriver
DC power supply.
Every per-output method takes channel: None means the default
(first) output, so single-output drivers may ignore it. CHANNELS
lists the addressable outputs.
Source code in src/instrumation/drivers/base.py
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 | |
get_mode()
Returns the current operation mode (CV, CC, or OFF).
Source code in src/instrumation/drivers/base.py
541 542 543 544 | |
measure_power(channel=None)
Queries the actual measured output power (Watts).
Source code in src/instrumation/drivers/base.py
524 525 526 527 | |
measure_voltage(channel=None)
Generalized alias for measure_voltage_actual.
Source code in src/instrumation/drivers/base.py
517 518 519 | |
set_autostart(state)
Sets the Power-ON state (SAFE/OFF or AUTO/ON).
Source code in src/instrumation/drivers/base.py
537 538 539 | |
set_current(current, channel=None)
Generalized alias for set_current_limit.
Source code in src/instrumation/drivers/base.py
495 496 497 | |
set_foldback_delay(seconds)
Sets the delay for foldback protection.
Source code in src/instrumation/drivers/base.py
533 534 535 | |
set_foldback_mode(mode)
Sets the foldback protection mode (OFF, CC, or CV).
Source code in src/instrumation/drivers/base.py
529 530 531 | |
set_voltage_limit(voltage, channel=None)
Generalized alias for Over-Voltage Protection (OVP).
Source code in src/instrumation/drivers/base.py
513 514 515 | |
Bases: InstrumentDriver
Source code in src/instrumation/drivers/base.py
546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 | |
get_peak_value()
Helper: Performs peak search and returns marker amplitude.
Source code in src/instrumation/drivers/base.py
566 567 568 569 | |
Bases: InstrumentDriver
Source code in src/instrumation/drivers/base.py
571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 | |
set_center_frequency(freq_hz)
Alias for set_center_freq.
Source code in src/instrumation/drivers/base.py
581 582 583 | |
wait_for_sweep()
Wait for the current sweep to complete.
Source code in src/instrumation/drivers/base.py
645 646 647 | |
Bases: InstrumentDriver
Source code in src/instrumation/drivers/base.py
649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 | |
Bases: InstrumentDriver
Source code in src/instrumation/drivers/base.py
671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 | |
Bases: InstrumentDriver
Source code in src/instrumation/drivers/base.py
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 | |
clear_protection()
Clears any tripped protection status.
Source code in src/instrumation/drivers/base.py
309 310 311 312 | |
get_current()
abstractmethod
Returns the set current value in CC mode.
Source code in src/instrumation/drivers/base.py
234 235 236 237 | |
get_input()
abstractmethod
Returns the input state (ON/OFF).
Source code in src/instrumation/drivers/base.py
274 275 276 277 | |
get_mode()
abstractmethod
Returns the active operating mode.
Source code in src/instrumation/drivers/base.py
224 225 226 227 | |
get_power()
abstractmethod
Returns the set power value in CP mode.
Source code in src/instrumation/drivers/base.py
264 265 266 267 | |
get_resistance()
abstractmethod
Returns the set resistance value in CR mode.
Source code in src/instrumation/drivers/base.py
254 255 256 257 | |
get_voltage()
abstractmethod
Returns the set voltage value in CV mode.
Source code in src/instrumation/drivers/base.py
244 245 246 247 | |
measure_current()
abstractmethod
Measures the actual current being drawn by the load.
Source code in src/instrumation/drivers/base.py
284 285 286 287 | |
measure_power()
abstractmethod
Measures the actual power being consumed by the load.
Source code in src/instrumation/drivers/base.py
289 290 291 292 | |
measure_voltage()
abstractmethod
Measures the actual input voltage at the load terminals.
Source code in src/instrumation/drivers/base.py
279 280 281 282 | |
set_current(amps)
abstractmethod
Sets the constant current value in CC mode.
Source code in src/instrumation/drivers/base.py
229 230 231 232 | |
set_input(state)
abstractmethod
Turns the load input ON (True) or OFF (False).
Source code in src/instrumation/drivers/base.py
269 270 271 272 | |
set_mode(mode)
abstractmethod
Sets the operating mode, typically CC, CV, CR, or CP.
Source code in src/instrumation/drivers/base.py
219 220 221 222 | |
set_ocp(current)
Sets the over-current protection limit.
Source code in src/instrumation/drivers/base.py
299 300 301 302 | |
set_opp(power)
Sets the over-power protection limit.
Source code in src/instrumation/drivers/base.py
304 305 306 307 | |
set_ovp(voltage)
Sets the over-voltage protection limit.
Source code in src/instrumation/drivers/base.py
294 295 296 297 | |
set_power(watts)
abstractmethod
Sets the constant power value in CP mode.
Source code in src/instrumation/drivers/base.py
259 260 261 262 | |
set_resistance(ohms)
abstractmethod
Sets the constant resistance value in CR mode.
Source code in src/instrumation/drivers/base.py
249 250 251 252 | |
set_voltage(volts)
abstractmethod
Sets the constant voltage value in CV mode.
Source code in src/instrumation/drivers/base.py
239 240 241 242 | |
Bases: InstrumentDriver
Abstract Base for Frequency Counters / Timer/Counter instruments.
Source code in src/instrumation/drivers/base.py
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 | |
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
317 318 319 320 | |
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
322 323 324 325 | |
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
327 328 329 330 | |
set_auto_range(state)
abstractmethod
Enables or disables auto-ranging.
Source code in src/instrumation/drivers/base.py
347 348 349 350 | |
set_coupling(dc_ac)
abstractmethod
Sets input coupling — 'DC' or 'AC'.
Source code in src/instrumation/drivers/base.py
342 343 344 345 | |
set_impedance(ohms)
abstractmethod
Sets input impedance (50 or 1e6).
Source code in src/instrumation/drivers/base.py
332 333 334 335 | |
set_trigger_level(volts)
abstractmethod
Sets the trigger level voltage.
Source code in src/instrumation/drivers/base.py
337 338 339 340 | |
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
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 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 | |
auto_scale()
:AUToscale — Automatically adjust scale for all channels.
Source code in src/instrumation/drivers/rigol.py
91 92 93 94 | |
clear_status()
*CLS — Clear status registers.
Source code in src/instrumation/drivers/rigol.py
76 77 78 | |
clear_waveform()
:CLEar — Clear waveform data.
Source code in src/instrumation/drivers/rigol.py
96 97 98 | |
force_trigger()
:TFORce — Force a trigger event.
Source code in src/instrumation/drivers/rigol.py
112 113 114 | |
get_acquire_type()
:ACQuire:TYPE? — Query acquisition mode.
Source code in src/instrumation/drivers/rigol.py
129 130 131 | |
get_channel_bw_limit(channel)
:CHANnel
Source code in src/instrumation/drivers/rigol.py
254 255 256 257 | |
get_channel_coupling(channel)
:CHANnel
Source code in src/instrumation/drivers/rigol.py
191 192 193 194 | |
get_channel_display(channel)
:CHANnel
Source code in src/instrumation/drivers/rigol.py
173 174 175 176 | |
get_channel_invert(channel)
:CHANnel
Source code in src/instrumation/drivers/rigol.py
269 270 271 272 | |
get_channel_offset(channel)
:CHANnel
Source code in src/instrumation/drivers/rigol.py
221 222 223 224 | |
get_channel_probe(channel)
:CHANnel
Source code in src/instrumation/drivers/rigol.py
236 237 238 239 | |
get_channel_scale(channel)
:CHANnel
Source code in src/instrumation/drivers/rigol.py
206 207 208 209 | |
get_edge_trigger_level()
:TRIGger:EDGe:LEVel? — Query trigger level voltage.
Source code in src/instrumation/drivers/rigol.py
354 355 356 | |
get_edge_trigger_slope()
:TRIGger:EDGe:SLOPe? — Query edge trigger slope.
Source code in src/instrumation/drivers/rigol.py
346 347 348 | |
get_edge_trigger_source()
:TRIGger:EDGe:SOURce? — Query edge trigger source.
Source code in src/instrumation/drivers/rigol.py
331 332 333 | |
get_id()
*IDN? — Query instrument identification.
Source code in src/instrumation/drivers/rigol.py
85 86 87 | |
get_sample_rate()
:ACQuire:SRATe? — Query current sample rate (samples/sec).
Source code in src/instrumation/drivers/rigol.py
153 154 155 | |
get_screenshot()
:DISPlay:DATA? — Capture display screenshot as PNG.
Source code in src/instrumation/drivers/rigol.py
553 554 555 556 | |
get_timebase_mode()
:TIMebase:MODE — Query timebase mode (MAIN, XY, ROLL).
Source code in src/instrumation/drivers/rigol.py
289 290 291 | |
get_timebase_offset()
:TIMebase[:MAIN]:OFFSet? — Query horizontal offset.
Source code in src/instrumation/drivers/rigol.py
313 314 315 | |
get_timebase_scale()
:TIMebase[:MAIN]:SCALe? — Query horizontal scale.
Source code in src/instrumation/drivers/rigol.py
301 302 303 | |
get_trigger_mode()
:TRIGger:MODE — Query trigger mode (EDGE, PULSE, etc.).
Source code in src/instrumation/drivers/rigol.py
319 320 321 | |
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
373 374 375 376 377 378 | |
get_trigger_sweep()
:TRIGger:SWEep? — Query trigger sweep mode.
Source code in src/instrumation/drivers/rigol.py
369 370 371 | |
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
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 | |
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
430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 | |
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
477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 | |
get_waveform_source()
:WAVeform:SOURce? — Query waveform data source.
Source code in src/instrumation/drivers/rigol.py
404 405 406 | |
get_waveform_x_increment()
:WAVeform:XINCrement? — Query X-axis increment (seconds/sample).
Source code in src/instrumation/drivers/rigol.py
453 454 455 | |
get_waveform_x_origin()
:WAVeform:XORigin? — Query X-axis origin (seconds).
Source code in src/instrumation/drivers/rigol.py
457 458 459 | |
get_waveform_x_reference()
:WAVeform:XREFerence? — Query X-axis reference point.
Source code in src/instrumation/drivers/rigol.py
461 462 463 | |
get_waveform_y_increment()
:WAVeform:YINCrement? — Query Y-axis increment (volts/code).
Source code in src/instrumation/drivers/rigol.py
465 466 467 | |
get_waveform_y_origin()
:WAVeform:YORigin? — Query Y-axis origin (volts).
Source code in src/instrumation/drivers/rigol.py
469 470 471 | |
get_waveform_y_reference()
:WAVeform:YREFerence? — Query Y-axis reference code.
Source code in src/instrumation/drivers/rigol.py
473 474 475 | |
measure_duty_cycle(channel=1)
:MEASure:DUTYcycle? — Measure duty cycle on a channel.
Source code in src/instrumation/drivers/rigol.py
543 544 545 546 | |
measure_frequency(channel=1)
:MEASure:FREQuency? — Measure frequency on a channel.
Source code in src/instrumation/drivers/rigol.py
538 539 540 541 | |
measure_v_peak_to_peak(channel=1)
:MEASure:VPP? — Measure Vpp on a channel.
Source code in src/instrumation/drivers/rigol.py
548 549 550 551 | |
run()
:RUN — Start acquisition.
Source code in src/instrumation/drivers/rigol.py
100 101 102 | |
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
133 134 135 136 137 138 139 140 141 142 143 | |
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
145 146 147 148 149 150 151 | |
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
118 119 120 121 122 123 124 125 126 127 | |
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
241 242 243 244 245 246 247 248 249 250 251 252 | |
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
178 179 180 181 182 183 184 185 186 187 188 189 | |
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
163 164 165 166 167 168 169 170 171 | |
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
259 260 261 262 263 264 265 266 267 | |
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
211 212 213 214 215 216 217 218 219 | |
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
226 227 228 229 230 231 232 233 234 | |
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
196 197 198 199 200 201 202 203 204 | |
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
274 275 276 277 278 279 280 281 282 283 284 285 | |
set_edge_trigger_level(level)
:TRIGger:EDGe:LEVel — Set trigger level voltage.
Source code in src/instrumation/drivers/rigol.py
350 351 352 | |
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
335 336 337 338 339 340 341 342 343 344 | |
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
323 324 325 326 327 328 329 | |
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
305 306 307 308 309 310 311 | |
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
293 294 295 296 297 298 299 | |
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
380 381 382 383 384 385 386 387 388 389 390 391 | |
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
358 359 360 361 362 363 364 365 366 367 | |
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
419 420 421 422 423 424 425 426 427 428 | |
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
408 409 410 411 412 413 414 415 416 417 | |
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
395 396 397 398 399 400 401 402 | |
shutdown_safety()
Stop acquisition and sync.
Source code in src/instrumation/drivers/rigol.py
560 561 562 563 | |
single()
:SINGle — Single-shot acquisition.
Source code in src/instrumation/drivers/rigol.py
108 109 110 | |
stop()
:STOP — Stop acquisition.
Source code in src/instrumation/drivers/rigol.py
104 105 106 | |
sync_config()
CLS + WAI — Synchronize.
Source code in src/instrumation/drivers/rigol.py
80 81 82 83 | |
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", "ACPSU",
"DAQ", "PEAKPM", "TEMP" or "GENERIC". Defaults to
"GENERIC", which accepts any instrument.
probe_asrl : bool, optional
When True (default), an explicit ASRL connection gets a best-effort
TDK-Lambda Z+ handshake (INST:NSEL 6) before *IDN? so the
unit can identify itself. During "AUTO" discovery this is
disabled: vendor-specific commands are never sent to arbitrary
serial devices (gh #150).
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
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 | |
Dynamically loads all available instrument drivers.
Source code in src/instrumation/factory.py
601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 | |
Transport Utilities
Generic wrapper for VISA instruments.
Opens a VISA resource on construction and clears its status register.
Parameters
address : str
VISA resource string, for example "TCPIP::192.168.1.5::INSTR".
timeout : int, optional
Read timeout in milliseconds, applied to the opened resource.
Defaults to 5000.
Notes
Construction never raises. If the resource cannot be opened, the error is
printed and :attr:inst is set to None, leaving an object whose methods
are all no-ops. Check driver.inst is not None before relying on it.
Attributes
rm : pyvisa.ResourceManager
The shared resource manager from :func:~instrumation.factory.get_rm.
address : str
The resource address this driver was constructed with.
inst : pyvisa.Resource or None
The open resource, or None if the connection failed.
Source code in src/instrumation/transport.py
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 | |
close()
Close the VISA resource, leaving the shared resource manager open.
Safe to call when the driver never connected. The resource manager is a process-wide singleton shared with every other driver, so it is deliberately not closed here.
Source code in src/instrumation/transport.py
113 114 115 116 117 118 119 120 121 | |
query_value(command)
Send a query and return the stripped response.
Parameters
command : str
SCPI query to send, for example "MEAS:VOLT:DC?".
Returns
str or None
The stripped response string on success. Returns None if
the query raised, or if the driver never connected -- so a
failed read is never mistaken for a genuine 0.0 reading.
Notes
The previous behaviour of returning 0.0 on failure was ambiguous
with a real zero reading; callers should treat None as "no data".
Callers that need to know why the read failed should check
self.inst first and use the underlying resource directly.
Source code in src/instrumation/transport.py
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 | |
write(command)
Send a command without reading a response.
Parameters
command : str
SCPI command to send, for example "OUTP ON".
Notes
Silently does nothing if the driver never connected. Write errors are
caught and printed rather than raised -- so a successful return does
not guarantee the command reached the device. This matches the
forgiving contract of :meth:query_value (and
:class:SerialDriver): a failed connection leaves the object usable
but inert, and callers that must know a write landed should check
self.inst first and use the underlying resource directly.
Source code in src/instrumation/transport.py
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 | |
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
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 | |
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
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 | |
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
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 | |
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
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 | |
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
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 | |
Configuration
Returns the configuration dictionary for the test station.
Resolution precedence (highest wins):
1. Environment variables (VISA_ADDRESS, SERIAL_PORT,
INSTRUMENT_TYPE, LOG_FILE)
2. A config file, located via the INSTRUMATION_CONFIG env var or
instrumation.{json,yaml,yml} in the current directory or the
user's home directory
3. Built-in defaults
Example::
config = get_config()
visa = config["visa_address"]
Source code in src/instrumation/config.py
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 | |
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 124 125 126 127 128 129 | |