06-25-2024 06:53 AM
I need to give power to a system and measure the result. I'm doing this in Labview to create an automated measurement station.
As I want to keep it modular, I have a VI to adjust the voltage of an output (this one seems to work properly, as I have the voltage I set after executing it, and the current measured seems reasonable) and another VI to only measure voltage, current and calculate power (I want to reuse them both later).
Both VIs follow the same structure: initialize niDCpower -> set parameters (in the case of the measuring VI there is none to set) -> niDCpower initiate -> measure -> niDCpower close.
Then after I set the voltage with the first, the handle is closed, I need to get a new handle and initiate DCpower. In this step is where I'm having the problem: after niDCpower initiate, the output voltage drops to 0. The only way I found to do it as I want is to keep the session open after the first VI (remove niDCPower close) and carry the instrument handle to the measurement VI, but I don't know if this is a good practice.
Is any other way of doing this?
I'm attaching the VIs here, voltage set is almost as the example.
Thanks in advance
06-25-2024 07:53 AM
jano2358@gmail.com wrote:
The only way I found to do it as I want is to keep the session open after the first VI (remove niDCPower close) and carry the instrument handle to the measurement VI, but I don't know if this is a good practice.
Yes, that is the best practice: open a session and keep it alive until you complete all your work. This is like powering up your laptop, completing all your work, and then powering it down. You won't restart your laptop every time you open a new application or webpage.
This help article explains the various states in the session model.
https://www.ni.com/docs/en-US/bundle/ni-dcpower/page/programming-states.html