LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

How many tasks are available in NI-DAQmx?

I am working with a 6528 board connected to totally independent switches and controls (20 input and 13 output). I need to be able to independently control and monitor each one. I have not been able to figure out how to do this unless I create a task for each independent line but am concerned about the quantity of tasks available for this. I won't be getting the board for another week yet but would like to have the software ready for it when I do have it. The current partial implementation in use has been to dynamically create and destroy a task each time the GUI switch is changed, this doesn't seem to be a very efficient way (time consuming).
 
My initial thoughts were to create all of the channels under one task but I haven't found a way to set the lines individually (like set a named line to a value or a mirror to the ReadNthChannel). I suppose I could keep track of each bit internally and send them all.
 
It's looking like my monitoring for status change should be done the same way, a task for each line monitored for easy translation to something displayed to the user and a quick response to something having gone wrong. It just doesn't feel right though.
 
I am seriously thinking of going to the traditional interface but that is the last resort.
 
Lloyd 
0 Kudos
Message 1 of 8
(4,069 Views)
Hi Lloyd,

I hope you're doing well.  There may be a few different ways to implement what you are working on, and they should not require dynamically creating and destroying a task each time you change a digital output value through your Front Panel.  For the digital output, the simplest would be using the method you've mentioned: by sending an array of all the bit values.  The implementation for this has already been done in fact in one of the shipping examples (Help»Find Examples, then Hardware Input and Output»DAQmx»Digital Generation»Write Dig Chan.vi).  This example has an array, who's size is the number of bits/lines in the task, of booleans and allows you to control the values of all of these lines.  The same is done for digital input as well under Hardware Input and Output»DAQmx»Digital Measurements»Read Dig Chan.vi.  If you want to run the both of these simultaneously in one VI, you can combine them and have the DAQmx Read and DAQmx Writes together in the same While loop.  Hopefully this is helpful, but if you are having trouble still, please let us know.  I would stick to DAQmx whenever possible, as the drivers should be able to accomplish what you are looking to do, and they are much more efficient (not to mention they are the DAQ drivers that are continually being supported and updated).

Thaison V
Applications Engineer
National Instruments
0 Kudos
Message 2 of 8
(4,048 Views)

What is a VI? I am using CVI and I've seen the references to a VI but have no idea what it is.

I know that there is a limit to how many tasks that can be defined and I'm trying to avoid coming close to the limits as I've been bitten by limit caused bugs before thus the question about how many can be created. If it's over 100 then that should be good enough for me as there's only 48 channels.

The problem with sending the array of bits is this panel is dynamically creatable bit by bit so I figured I just keep track of the bit related information (names, labels, response types, etc.) and deal with it from that. I had noticed the ability on the input side to be able to control which input bit you are reading so I figured that NI would create a symmetrical interface (being able to read and write things in the same style), but I haven't been able to find it. This is the sort of thing they teach in Object Programming 101. It increases the productivity of the programmers as they only would have to spend the time to understand one interface style instead of two, I don't understand the "advantages" of the inability to address the outputs individually by name within a task. I ended up creating a task for each output bit and tracking the task, something I find as wasteful as I'm sure 24 tasks with one channel each takes up more overhead than one task with 24 channels (which is something I can do with the input side).

As for the creating and destroying the interface each time a bit was written, I agree. The programmer that did that stole it from one of the examples and didn't understand the potential time problems that can cause and he was unable to figure out how to address one bit at a time on the output either so he used what worked.

Lloyd

0 Kudos
Message 3 of 8
(4,043 Views)

VI stands for Virtual Instrument.  It is more of a LabView nomenclature.

Loosely interpretted, it is how you can write a generic function in labview to be callable from other programs.

0 Kudos
Message 4 of 8
(4,038 Views)
Hi Lloyd,

I pointed to the LabVIEW Example by mistake, but CVI has the equivelant examples of what I was discussing as well.  These example projects should be found under C:\Program Files\National Instruments\CVIXX\samples\DAQmx\Digital\Generate Values\Write Dig Chan\WriteDigChan.prj and C:\Program Files\National Instruments\CVI71\samples\DAQmx\Digital\Read Values\Read Dig Chan\ReadDigChan.prj .

As for the limit on tasks, there is not hard-set limit we have set for how many tasks can be created.  If you are destroying each task anyway (which I am assuming you are using DAQmxClearTask for), then this probably won't be an issue for you anyway.

Finally, about addressing individual channels within one task (having one task with all channels included), you mentioned you are able to do this for Digital Input, but not for output.  How are you implementing this exactly on the input end?  Input and output tasks should be pretty similar, so I am wondering what method you are using exactly that doesn't translate to the output side of things.  Let us know, and we'll try to keep giving you suggestions!

Thaison V
Applications Engineer
National Instruments
0 Kudos
Message 5 of 8
(4,008 Views)

I am using DAQmx_Read_ChannelsToRead thru "DAQmxSetReadAttribute" to read a single channel, I have not been able to find the equivalent entry on the write side. It took a little find that, I expected to be able to call a function with the name of the channel and get the value back but having to do two function calls (three if you also want to be able to read the whole set at a later time) isn't too bad.

I redesigned it so it creates a task for each output and isn't destroying the tasks other than at the end and it seems to be working fine (at least in simulated mode). It caused me to have two different styles of programming to handle it and I know the person that will be maintaining it later will be in for more exploration than should be necessary but it is what it is.

Using the traditional stuff I would have been able to use a single common style but take the chance of support ending on the next cards we use and having to do this then and have to maintain three different ways of doing it.

What is the maximum quantity of tasks that you know have been created? I understand that my "mileage" may vary but knowing that there are applications with 30 or more tasks running would make me feel more comfortable with running 20 or so in my app.

 

Thanks,

Lloyd

0 Kudos
Message 6 of 8
(3,999 Views)
With CVI 7.1 and  Nidaqmx 7.4 under winXP SP2, I have had more than 60 concurrent tasks active spread over analog input, output and DIO cards without issue.  I don't know what the limit is, but it seems to be plenty for the average program.
0 Kudos
Message 7 of 8
(3,994 Views)

That makes me feel much more comfortable with what I'm doing. I figured that this would be the case but then I figured I'd be able to treat the input and output in similar ways.

 

Thanks,

Lloyd

0 Kudos
Message 8 of 8
(3,987 Views)