From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Dynamic Signal Acquisition

cancel
Showing results for 
Search instead for 
Did you mean: 

NI-DAQmx Multiple Tasks on one card?

Hello all. Just to give a bit of background, I've been using LabVIEW, DAQ, GPIB etc for years. This is my first encounter with DAQmx though.

It seems to me that a DAQmx "task" effectively takes exclusive control of the DAQ card it is open on. In other words, if TASK1 includes AO0 on a card and TASK2 includes AO1 on the same card then I can not have both tasks open at the same time. To be more precise, it lets me open two tasks, and I can then control the output of either one. However, if I try to set AO0 after setting AO1 (or vice versa) then I get an error -50103.

Could someone please advise whether this is intended to be the case? If this is correct then this is a major problem that needs to be addressed by NI. I'm sure that in the old NI-DAQ you could effectively treat each AO or AI port as a separate entity, regardless of which physical card it was located on.

The nature of the task means that I can not group both outputs to become one task - they need to be treated completely separately. Also, I can not close either task, as with this card that makes the AO go to 0V.

I'd much rather have direct control of the outputs instead of all this "task" and "channel" stuff - it all just gets in the way, and can actually make the code less structured. Just my controversial opinion!

All help gratefully received - this is a big problem.
Message 1 of 14
(25,460 Views)
I'm assuming you're using a 4461 since that's the only DSA board supported by DAQmx that has analog output. If not, some of my advice may not be valid, but hopefully it will still be useful. While DAQmx allows you to create an arbitrary number of AI or AO tasks, you can only have one of the tasks in the reserved state at a given time depending on your hardware. This is true for the 4461 since there is one AO timing engine that is shared between the two channels. This is why you are getting the -50103 reservation error from the second task when the first task is already running. If you want to use two tasks in this fashion, your program will have to explicitly reserve/unreserve each task as necessary in order to eliminate reservation conflicts. For more information on the state model in DAQmx, I would recommend looking at the Key NI-DAQmx Concepts->Tasks->Task State Model chapter in the NI-DAQmx Help file. However, from your post, it seems what you really want to do is use both channels together in the same task. If this is the case, you can simply create both channels in the same task and treat them as a single unit. Also, I thought I would mention that you can specify the idle output behavior for your AO channels on this device. To do this, you can use the DAQmx Channel Property Node and select the Analog Output->General Properties->Output Configuration->Idle Output Behavior attribute from the menu. Your choices for the output behavior are zero volts, high impedance, and maintain existing value. I believe the default is high impedance which may be why you see the outputs going to 0 volts.
Message 2 of 14
(25,451 Views)
Reddog - many, many thanks for your excellent reply. I hadn't tried the "Control Task" VI.

You are correct that this is a PXI-4461 - sorry, I should have stated that.

A bit of detail...

What I'm trying to do is this - at present we have one PXI-4461. We will be buying more of these cards shortly. I suspect that what I'm trying to do is not quite what these cards were designed for. We are making a unit that, conceptually, is a number of ADCs in, some digital logic, and a number of DACs out. The automated test consists of applying a number of very precise DC voltages to the ADCs using 4461 AO channels, then communicating with the logic to find out that value it is reading, then ramping up the voltage, querying the logic again, etc. On the output side, we will tell the logic to output value x, then measure this voltage using a 4461 AI channel, then increment the logic output value, read the AI again, etc. Pretty simple stuff really.

As the DUT has very high-resolution ADCs and DACs, we need the ATE system to be much more accurate than the DUT. This is why we went for the 4461, as it has 24-bits and BNC connectors for low-noise connection directly to the DUT. Obviously the 4461's 2MHz sample rate is over-kill for us!

I saw straight away that the 4461 is not capable of dealing with single output values - it can only output waveforms (it would be much easier if it could do single values!). I then decided to try outputting a 1D array of minimum length (2 samples) at maximum output rate, and use the AO.IdleOutputBehaviour>>Maintain Existing Value property to make the output stay where I left it. I then set about making subVI's called Open, Write and Close, each of which would deal with a Task containing one channel each. The intention was to open as many instances of these VIs as were required for the number of channels needed. See the attached screenshots from my test harness that deals with the two channels.

I could deal with this by putting both Channels into one Task, but that would make the structure much more complicated. It also makes it difficult to update one channel without the other (as I need to do). I did try the 1 Task approach yesterday, with cacheing for the channel that doesn't need to be updated. This was obviously a pretty complicated way of sticking a DC voltage out of a channel! I did have problems with this approach too, which I won't go into just yet, as I'd prefer to continue trying to work out a way of doing this with multiple Tasks, one Channel per task.

First, the good news: Your excellent suggestion of unreserving almost works! I unreserve the channel in my Open VI, then within each Write I reserve, update the output, then unreserve. I can now update both channels as required, without getting any errors.

Now, the bad news: Updating one channel causes the other to revert to 0V. This is despite the AO.IdleOutputBehaviour>>Maintain Existing Value being set for each Channel/Task. I had my Write VI open, running with execution highlighting and saw that output 0 maintains its value while output 1 is reserved. Then, the instant that the "DAQmx Write" VI runs on AO1, AO0 drops to 0V.

All I'm after is a way of being able to set two outputs to a DC voltage each, independently. I can't believe how difficult this is.

All help gratefully received!
0 Kudos
Message 3 of 14
(25,438 Views)
Just for further information, I've tried doing the same thing using the Test Panels in MAX.

If I update AO0 to a voltage, it goes to that voltage and stays there. It even stays there if I exit the test panel and close MAX. However, if I update AO1 to a voltage, AO0 drops immediately to 0V.

I'm going to go back to trying to get both Channels to work properly within one Task. This was doing very odd things when I tried it yesterday, but this is not an ideal solution for the software structure. I would still like to find a way of being able to control each Channel independently.

Again, all help very grateully received.

Thanks
-Sean.
0 Kudos
Message 4 of 14
(25,423 Views)
Sean -

Unfortunately, there is not a way to do what you want from within a single task. The 4461 is designed on the hardware and software level to operate in the frequency domain. That is why generating DC voltages seems more complicated than it should be. Our E-Series and M-Series boards are designed to generate static voltages and you'll find that your initial software approach would work great with them.

That said, it actually isn't too difficult from the programming side to be able to control both channels of the AO to generate static voltages through a single task. I have attached a VI which does this. Hopefully this is what you are looking for. Let me know if it isn't.

-Jack
0 Kudos
Message 5 of 14
(25,387 Views)
Thanks for that Jack. Sorry to be a pain, but could you please re-send your VI as a LabVIEW 7.0 VI? I'm currently trying to get the company to part with the cash for 7.1! Thanks very much.
0 Kudos
Message 6 of 14
(25,375 Views)
Message 7 of 14
(25,370 Views)
Thanks Jack, absolutely wonderful. Got your VI running now, will make some high-level lego bricks based on this. I never thought DC would be so difficult!
0 Kudos
Message 8 of 14
(25,329 Views)
I do think NI need to look at the behaviour of the AO.IdleOutputBehaviour>>Maintain Existing Value property though - either it needs to maintain its value when the other channel is updated as expected, or it needs to be clear in the documentation in the card that, when operating one port, the other port will drop to 0V regardless of the settings.

Just a thought - I wasted lots of hours in trying to get the card to work using this principle. Jack's method of continuously outputting a DC level is a good work-around though. It would be much better if I could have independent tasks for the two channels though, and they stay where I put them!
0 Kudos
Message 9 of 14
(25,291 Views)

Hi,

 

I have a slightly different problem.  I am trying to generate 2 independent waveforms using the same DAQmx task with the PXI-4461.  The VI has no error, but only one waveform shows up at channel 0.  0 volt @ channel 1.

 

Is there a way for me to simultaneously generate 2 different signals at different output channels?

 

Thanks,

 

0 Kudos
Message 10 of 14
(20,169 Views)