Programming Flow
- Updated2025-10-10
- 2 minute(s) read
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
To acquire measurements in single point source mode complete the following steps.
- Measure with NI-DCPower Measure Multiple.
- 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.
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.
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.
Related Information
- Programming States
- Single Point Source Mode
- Sequence Source Mode
A sequence is composed of steps that specify a series of outputs for an NI-DCPower channel. In a simple sequence, you can specify either a series of voltage outputs or a series of current outputs. Advanced sequencing allows you to configure multiple properties per sequence step.
- Advanced Sequencing
Use advanced sequencing instead of the NI-DCPower Set Sequence function when you want more options for configuring a channel differently between sequence steps.
- Pulsing
The source unit can output configurable voltage pulses or current pulses.