Example Code

Measuring Resistance Using an NI Programmable Power Supply or SMU


  • DMM

Code and Documents




The NI PXI-4110 programmable power supply and NI PXI-4130 source measure unit offer the ability to simultaneously source and measure both current and voltage. Since the sourcing and measuring performed by these instruments are controlled and monitored via PC software, engineers have the flexibility to use these devices for a variety of applications beyond simple power sourcing. One simple example of such an application is using the PXI-4110 or PXI-4130 as an ohmmeter for resistance measurements. The code attached below shows how the PXI-4110 or PXI-4130 can be used to take resistance measurements in LabVIEW.

Connection Diagram


A resistance measurement consists of two main parts:  1) sourcing a constant current across a load and 2) measuring the developed voltage.

Once the measured voltage is known, Ohm’s law is used to calculate resistance:

Typically, DMMs (Digital Multimeters) provide an on-board precision current source to source the excitation needed for resistance measurements, so that their inherent voltage measurement functionality can then be used to read the voltage.  For instance, the PXI-4071 DMM offers resistance measurements from 0 to 50 GΩ with 10 Ω of resolution down to 0 to 100 Ω with 10 µΩ resolution.

Although simple resistance measurements are not the intended use case for the PXI-4110 or PXI-4130, their ability to both source and measure make it capable of performing such measurements.  Users that are already employing this module for other tasks can easily use the LabVIEW code example provided below to add additional functionality to their existing equipment.  This is just one example of the many ways in which software defined instruments such as the PXI-4110 programmable power supply and PXI-4130 source measure unit can be used to accommodate a variety of applications.

The code consists of the following steps:

  1. Initialize a session to the device.
  2. Set the function of the device to be constant current.  This will allow the device to output a specified current value at any voltage.  
  3. Change current limit from default of 100 mA to 20 mA.  Then set the current limit range to 20 mA.  The PXI-4110 has both a 1 A current range and a 20 mA current range; the 20 mA current range is used here to maximize precision.  The PXI-4130 has several current ranges available, 20 mA was chosen to simplify the example
  4. Configure the voltage limit.
  5. Configure the current limit.
  6. Enable the channel.
  7. Measure the voltage.
  8. Measure the current.
  9. Calculate the resistance: R = V/I.
  10. Disable the channel.
  11. Close the session to the device.

Related Links

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.