|
| 1 | +## NI-VISA DMM Measurement |
| 2 | + |
| 3 | +This is a MeasurementLink example that performs a DMM measurement using NI-VISA |
| 4 | +and an NI Instrument Simulator v2.0. |
| 5 | + |
| 6 | +### Features |
| 7 | + |
| 8 | +- Uses the open-source `PyVISA` package to access NI-VISA from Python |
| 9 | +- Uses the open-source `PyVISA-sim` package to simulate instruments in software |
| 10 | +- Pin-aware, supporting a custom instrument type and a single session/pin/site |
| 11 | +- Includes InstrumentStudio and MeasurementLink UI Editor project files |
| 12 | +- Includes a TestStand sequence showing how to configure the pin map, register |
| 13 | + instrument resources with the session management service, and run a measurement |
| 14 | +- Demonstrates how to share instrument resources with other measurement services |
| 15 | + when running measurements from TestStand, without using NI gRPC Device Server |
| 16 | + |
| 17 | +### Required Driver Software |
| 18 | + |
| 19 | +- NI-488.2 and/or NI-Serial |
| 20 | +- NI-VISA |
| 21 | +- Optional: NI Instrument Simulator software |
| 22 | + |
| 23 | +Note: there is no Python instrument driver for the NI Instrument Simulator, so |
| 24 | +this example directly performs low-level, device-specific commands and queries. |
| 25 | + |
| 26 | +### Required Hardware |
| 27 | + |
| 28 | +By default, this example does not require hardware; it uses PyVISA-sim to |
| 29 | +simulate the instrument in software. |
| 30 | +[`NIInstrumentSimulatorV2_0.yaml`](./NIInstrumentSimulatorV2_0.yaml) defines the |
| 31 | +behavior of the simulated instrument. |
| 32 | + |
| 33 | +To use NI Instrument Simulator hardware: |
| 34 | +- Disable software simulation by setting `USE_SIMULATION = False` in both |
| 35 | + [`measurement.py`](./measurement.py) and |
| 36 | + [`teststand_fixture.py`](./teststand_fixture.py). |
| 37 | +- Connect the NI Instrument Simulator over GPIB or serial. |
| 38 | +- By default, the pin map included with this example uses the resource name |
| 39 | + `GPIB0::3::INSTR`, which matches the NI Instrument Simulator's factory default |
| 40 | + settings when connected via GPIB. |
| 41 | + - If this doesn't match your configuration, edit |
| 42 | + [`NIVisaDmmMeasurement.pinmap`](./NIVisaDmmMeasurement.pinmap) and replace |
| 43 | + `GPIB0::3::INSTR` with the desired resource name (e.g. `ASRL1::INSTR`). |
| 44 | + - To modify the NI Instrument Simulator configuration (e.g. GPIB address, |
| 45 | + serial configuration), use the `Instrument Simulator Wizard` included with |
| 46 | + the NI Instrument Simulator software. |
| 47 | + |
| 48 | +### Session Management |
| 49 | + |
| 50 | +This example has a slightly different approach to session management than the |
| 51 | +examples for NI PXI modular instruments. |
| 52 | + |
| 53 | +The examples for NI PXI modular instruments use the NI gRPC Device Server to |
| 54 | +share a single driver session between multiple operating system processes. When running |
| 55 | +measurements outside of TestStand, each measurement re-initalizes the |
| 56 | +instrument. When running measurements in TestStand, the `ProcessSetup` callback |
| 57 | +initializes the instrument once per sequence execution, which avoids |
| 58 | +the overhead of re-initializing the instrument for each measurement. |
| 59 | + |
| 60 | +This VISA example does not use NI gRPC Device Server. The measurement logic and |
| 61 | +TestStand code module open and close VISA driver sessions as needed in multiple |
| 62 | +operating system processes. However, the instrument initialization behavior is |
| 63 | +the same as before: outside of TestStand, each measurement re-initializes the |
| 64 | +instrument; in TestStand, the `ProcessSetup` callback initalizes the instrument |
| 65 | +once per sequence execution. This approach works for VISA because multiple |
| 66 | +processes (TestStand, multiple measurement services) can connect to the same |
| 67 | +instrument without resetting any instrument state. |
| 68 | + |
| 69 | +In both cases, the `ProcessSetup` callback registers the instrument with the |
| 70 | +session management service, the measurement logic uses the session management |
| 71 | +service to reserve and unreserve the instrument, and the `ProcessCleanup` |
| 72 | +callback unregisters the instrument with the session management service. This |
| 73 | +ensures that only one measurement at a time has access to the instrument. |
0 commit comments