LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Analog Current Generation

Solved!
Go to solution

Hi all,

As I'm sure that my question shows, I'm quite new to LabVIEW. I'm trying to write a simple VI that will generate a constant user selected current, and ideally, the user should be able to modify the current mid-execution. My program compiles and runs just fine, but I'm not reading any current or voltage being generated (using NI 9266) on a multimeter. I've verified that the wiring is correct and the module is functioning properly using MAX. Any thoughts? I've attached my code for reference.MyCode.PNG 

0 Kudos
Message 1 of 4
(884 Views)
Solution
Accepted by topic author ChemMan314

Hi ChemMan314, 
If I understood your question correctly, you want to have a user to input the current and this current is generated from the NI 9266. 

Have you looked into the example in LabVIEW? 

I am sure you will able to understand the example and make the modification accordingly. 

Sample.png

 

I have made a simple VI based on my understanding of your question just as a reference. 

As you can see, the slider represents the user input of the current into the DAQmx Write API while the VI is running and I included in an array so that I can see the current being displayed in the waveform graph. 

Have a look into the code and if you need to modify it, please feel free to do so.

Message 2 of 4
(850 Views)

Thank you, this helps a lot. Just to clarify, I have two questions. 

 

First, why ore you inputting the data in the form of an array? Is there an advantage to inputting data as an array of length 1 vs. as a double?

 

Also, what's the purpose of checking the status of the task as an exit condition for the while loop? I understand that it will exit the loop after the task is completed, but what does completing the task mean in context of generating a constant current?

 

Again, pardon my ignorance, I really appreciate the support.

0 Kudos
Message 3 of 4
(768 Views)

Hi ChemMan314, 


Glad to help!

 

Using data input in the form of an array

Is there an advantage to inputting data as an array of length 1 vs. as a double?

Rather than advantage, I used the array because the input for the waveform graph requires an array input. Otherwise, it would not show any plot on the graph. 
So if we used Shift Register to hold the values from the user slider and keep it within the loop, it will become an array. You can look into the Help file for Shift Register concept and how we can actually retain these values within loop in the form of array. Now since the user values are in an array, we can simply use as an input to the waveform graph. 

 

Purpose of checking the status of the task as an exit condition for the while loop?

I am using these DAQmx API in the While Loop. 
So while the loop is running, in case if there is an unexpected error  that occurs, the status condition actually helps to catch error and exit the loop safely. In simple application, of course this does not seem like a big issue. However, if you are running bigger applications and using complex hardware, we have to consider these things when writing codes in LabVIEW. 

 

If you need any more information, you can look into the Help section for each of the things I mentioned earlier by using the shortcut key Ctrl+H and hover your mouse to the LabVIEW code to see the details. 

 

Cheers!

0 Kudos
Message 4 of 4
(746 Views)