LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How can I programmatically change the voltage range settings in a DAQ Assistant

Solved!
Go to solution

Hi,

 

First post here.  

 

I need to be able to change the voltage range properties of a daqmx DAQ Assistant based on user input.  My hardware, an SCXI-1102C does not allow changing this property on a running task, so I'd like to either set the analog input voltage range before the DAQ Assistant activates, or pause the DAQ Assistant immediately after it starts, set the values and then resume.

 

I don't know how to edit the task ahead of time because the DAQ assistant creates the task when it runs, and there is no task before that.

 

In the attached picture, I have a conditional section, set to run only if the while loop iteration is 0.  I take the task from the Daq assistant, send it to a stop task vi, set the property, and then send the task on to the start task vi. I can watch it run with the debug light on, and everything seems to work correctly, but on the second (and all the other) iteration of the loop, I read out AI.Max and it seems like the DAQ Assistant has re set it back to 5V.  Can anyone see what is going wrong here?

 

BTW, this is continuous acquisition and the code does not produce error messages when it runs.

 

I did come across a similar question that someone posted here back in 2006, but his question was specifically aimed at a Labview API (VB, I think), and not an actual G solution.

 

Attached are the actual vi in question and a png image of the block diagram.

 

Thanks! 

 

 

Ruby K

Download All
0 Kudos
Message 1 of 5
(5,211 Views)
Solution
Accepted by topic author Ruby K.

First, if you want to start getting beyond the basics with DAQ, you are going to have to stop using the DAQ assistant and do it with lower level DAQmx VI's.  There are hundreds of examples in the example finder.  You can even right click on the DAQ assistant and select open front panel.  That will create a subVI that you can open and see what is going on behind the scenes.  Do it.  I think you'll find the DAQ task is being recreated on each (though I'm not 100% of how the settings are established or maintained in each section of that subVI).

 

The second problem is you have a bit of a race condition on iteration 0.  Those two DAQ property nodes are running at the same time.  So when you read the AI.Max, it may be happening before or after the AI.Max is set in your case structure.

 

Third, make sure you wire up your error wires.

Message 2 of 5
(5,176 Views)

Thanks for the response.

 

"Open Front Panel"... That's brilliant. I had played around with "Generate NI-DAQmx Code" there, but that option does not generate code thats anywhere near as readable as just converting the DAQ Assistant to a subVI like you suggest.

 

The subVI just takes all these values in as a1D array -- perfect.

 

The only reason I wanted to use the DAQ Assistant is because I built a fairly complex application around them and did a bunch of testing to make sure that it worked correctly at all the sampling rates that I'll need.  I then realized that I was going to want to change the values for AI.Max and Min, and just wanted a simple fix without disturbing too much.

 

Thanks again

 

0 Kudos
Message 3 of 5
(5,168 Views)

If you want more control over DAQmx Assistants, check out my blog where I recently posted some VI tools to programmatically call MAX Assistants:

 

Programmatically Call NI DAQmx Assistants

 

There are vi's to create and edit channels, tasks, and scales.

0 Kudos
Message 4 of 5
(4,880 Views)

Hi Ruby,

 

The code generated by the DAQ assistant is not as simple as it could be. The first place to start looking for examples is in the example finder under Help. If you're looking to acquire an analog input voltage, you should go to:

 

Help»Find Examples»Hardware Input and Output»DAQmx»Analog Measurements»Voltage and select an example. A good example for hardware timed analog input would be  Cont Acq & Graph Voltage-Int Clk. From here, you can easily make modifications to your analog input task.

 

Best,

 

Sean F.

Sean Ferguson
Application Engineering Specialist | RF and Reconfigurable Test
0 Kudos
Message 5 of 5
(4,838 Views)