LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

DAQmx Base task control

I would like to use DAQmx Base to switch between two tasks on my PCI-6221 board. One is AO and one is AI. I wasn't sure how to accomplish this, so I downloaded a sample vi from the ni website:

http://sine.ni.com/apps/we/niepd_web_display.display_epd4?p_guid=F69F54F7B6415C3FE0340003BA7CCD71&p_node=201214&p_source=external

Unfortunately this program was written for DAQmx and I haven't been able to translate all of it to DAQmx Base. The two subvi's that don't seem to have Base equivalents are Control Task.vi and the property nodes, which show an error: "this property is not valid for this class".

I'm not sure if I'll be able to get this vi working if I can fix these issues, but it would be a start!  I am using LV7.1 so am not able to update to the full DAQmx at this time, but I've been able to work around the limitations of Base so far....  Thanks for any advice.

Maggie
0 Kudos
Message 1 of 6
(3,368 Views)

Hello Maggie,

If you would like to use DAQmx, you definitely can with LabVIEW 7.1.  This is recommended.  DAQmx was originally released with LabVIEW 7.0.  If you would like to use DAQmx with LabVIEW 7.1 you can download the driver here

Next, this example switches between two input tasks based upon a stop trigger.  I'm not sure this is exactly what you are looking for based upon your post.  Also, this example will not port directly to DAQmx Base since DAQmx base does not support property nodes.

Regardless of whether you choose to upgrade to DAQmx, or stay with DAQmx Base you can create two tasks (one AI one AO) and have them both running.  There are many examples that show how to setup and run either AI or AO for both DAQmx and DAQmx Base.  The concepts in the examples can be combined into one program.  DAQmx examples are found in Example Finder under Hardware Input and Output >> DAQmx.  Example Finder can be found in LabVIEW under the help menu.  DAQmx Base examples can be found in your start menu under Programs >> National Instruments >> NI-DAQmx Base >> Examples.

I hope this clarifies things.

Jesse O.
Applications Engineering
National Instruments

Jesse O. | National Instruments R&D
0 Kudos
Message 2 of 6
(3,350 Views)
Hi Jesse, thanks for your fast response. I forgot to mention that I am using Linux RH. According to the readme DAQmx only works in LV8.0 or later versions for Linux. Am I misunderstanding this?

I should have been more explicit originally about what I'm trying to do. I have been able to have two tasks running simultaneously without a problem. However, I need to switch between the two tasks (I think) because my AO Voltage must be determined from an AI measurement, and I would like to update AO at 100Hz or greater. Right now I have a working VI in which I have a sequence structure that switches between AO and AI and I pass the AI measurement to determine AO voltage. Each time I have to restart the task, run a finite number of samples, and close the task, so the fastest I can update is around 4Hz which is not sufficient.

How else can I change the voltage setting while running an AO task?

Maggie
0 Kudos
Message 3 of 6
(3,347 Views)

Hello Maggie,

You are correct that DAQmx 8 is only supported by LabVIEW 8 on a machine running RH Linux.  I still believe that the application you first mentioned is not exactly what you are looking for. 

If you are wanting you can continuously read in data and write that data back out to your analog output channel.  You do not need to start and stop the two tasks.  I have posted code below that performs hardware timed analog output it uses a loop to update your analog output. This application uses a hardware timed single point sample mode.  It would be system and code dependent, but you should probably be able to run at 100Hz.  You could also use continuous acquisition, however you will have to deal with the delay generated by using the onboard FIFO.  You could apply this code's concept to your application and add analog input to it.


Regards,

Jesse O.
Applications Engineering
National Instruments

Jesse O. | National Instruments R&D
0 Kudos
Message 4 of 6
(3,323 Views)
Hi Jesse, Thank you! This is exactly what I need. I am able to update at very large frequencies (over 10kHz). You mentioned "the delay generated by using the onboard FIFO" and I'm not sure what that means.

As of now my program can only execute the while loop 8000 times. If I attempt to take more than 8k samples I get the following error:  -233700 AO FIFO is full and generation is not started. DAQmxBase does not use an intermediate buffer to hold the samples.

I am using "finite samples" mode. If I switch to Hardware timed single point I get another error: "Requested values is not a supported value for this property" which I presume means that my PCI 6221 board does not support this? However, in this mode I don't get the other buffer error.

Having perused some other posts, the only suggestion I come across is to read data faster than you aquire it, but that doesn't seem to work for me. 8k samples is a fixed upper limit.

Any ideas?

I've attached my program in case that's helpful.
0 Kudos
Message 5 of 6
(3,312 Views)

Hello mktrias,

I'm glad what I provided before was useful.  The hardware timed single point acquisition is only supported in Windows, and this is why you are getting the error.  The delay I was referring to before with a buffered output is that your analog output buffer (FIFO) is roughly 8000 samples.  This means that if you are updating your buffer during your output it will take time for the new samples to be generated (because samples are already present in the buffer).

I believe you are also getting errors (after 8k samples) because of your finite generation.  Finite tasks are typically used to generate a set of outputs and then you stop the task.  In your case you seem to want to continuously output samples.  If this is the case either use software timed or continuous output.  There are examples showing how to code either of these.  You can typically find them here:

/usr/local/natinst/LabVIEW-8.0/examples/daqmxbase/dynamic/ao

The software timed output example is called Gen Mult Volt Updates-SW Timed.vi and the two continuous examples (one with and one without regeneration) start with Cont Gen Voltage Wfm-Int Clk.  Regeneration means that when all the samples you have written to the FIFO have been used it will use the samples you previously wrote again.  The non-regeneration example shows that you need to be continuously sending data to the analog output FIFO before it finish/empties its FIFO.

Finally, if you look at either of the continuous acquisition example you will see that the error cluster from the DAQ task is unbundled and used to stop the while loop if an error occurs.  This is not present in the posted code, and it makes it harder to determine when and where an error is occurring.

I hope this helps,

Jesse O.
Applications Engineering
National Instruments

Jesse O. | National Instruments R&D
0 Kudos
Message 6 of 6
(3,293 Views)