Complete the following steps to program your instrument.

Opening a Session

To open a session, call NI-DCPower Initialize With Independent Channels.

For any application you write, you must open a session to establish communication with the specified device(s) or channel(s) by initializing.

Initializing returns an instrument handle with the session configured to a known state. Initialization can take a significant amount of time compared to other NI-DCPower functions, so you should not include it in a loop when repeatedly acquiring data. Ideally, your program should call NI-DCPower Initialize With Independent Channels one time. If the reset parameter is set to TRUE, device channels are reset to the default state, which may include resetting relays.

Initiating Generation and Acquisition

To apply the configuration and start generation, use NI-DCPower Initiate With Channels.

Measuring, Querying, or Fetching

The source mode that you select for configuring channels determines how NI-DCPower acquires measurements.

To acquire measurements in single point source mode complete the following steps.

  1. Measure with NI-DCPower Measure Multiple.
  2. To query the output state, call NI-DCPower Query In Compliance.

NI-DCPower automatically acquires measurements when you configure the following functions:

  • NI-DCPower Create Advanced Sequence With Channels
  • NI-DCPower Set Sequence
  • NI-DCPower Configure Output Function set to Pulse Voltage or Pulse Current

NI-DCPower automatically acquires the measurements by coercing the NI-DCPower Measure When property to Automatically After Source Complete. NI-DCPower returns the measurement values in an array.

Tip If you want the measure unit to operate independently of the source unit in this context, set the NI-DCPower Measure When property to a value other than Automatically After Source Complete.

Closing the Session

To close a session, use NI-DCPower Close.

Closing a session is essential for freeing resources, including deallocating memory, destroying threads, and freeing operating system resources. Ensure that you close every session that you initialize, even if an error occurs during the program. When debugging your application, it is common to abort execution before you close.

Note Aborting the execution is not likely to cause problems, but NI does not recommend doing so.

The channels continue to operate in their last configured state when you close a session. If you close a session while the output channels are enabled and actively sourcing or sinking power, the channels continue to source or sink power until you disable or reset them.