PXI

cancel
Showing results for 
Search instead for 
Did you mean: 

How many tasks can I have in NI-DAQmx system?

I am working out of the office this week - please send your response to grecos@core.com as well as my normal email dave_greco@trimble.com.
 
I am designing a new test platform that will run on C# (because we like object oriented text based programming and because the IDE is free).  For hardware we'll use your PXI modules (because your hardware is ultra-reliable).  I'm starting with the following PXI modules 6259, 4072, 6509, 2575, and 2569, but we made add other modules later as future requirements demand.  I am doing the system software architecture now.  I've done some dabbling with Ni_daqmx, and I loathe "tasks" and "channels", but am determined to make them work.
 
The difficulty I'm having revolves around the overhead with setting up tasks and channels and with the concept of tasks and channels.  Help hasn't helped much.  Tasks seem to work great if you intend to always collect the same large amount of data from many sources and always will do it in exactly the same way. 
 
We want something much more akin to random access memory.  We'll have UUTs of different kinds coming on and off at random times.  Sometimes a test will need a simple DC voltage, and other times another test will need 2 seconds worth of data at 1MS/s.   It can cost around 150msec to make that change (stop the current task, creat another one, configure anohter channel, start up a new task, blah, blah, task this, channle that - for the life of me I can't understand what this damn taks concept does for me but make matters more complicated and bog down my system).
 
I can just barely glean from the help that I can have only one analog input task at once, but I can have sevferal taks of several different kinds running at the same time ( a digital output task and another task for digital input, and another task for analong input, etc.) .  It does seem that I can set realys without having to put them into a channel and a task (Thank goodness for that - I just wanna turn on a relay I have no idea what a relay "channel" might be.)
 
In the PXI system I described above I'll have two devices that are analog input devices, the DMM and the Daq.  Even with two devices, can I only have one analog input task running?  Does that mean I've got to waste 150msec just to switch from the DMM to the Daq? (Do you understand my frustration with "tasks"? - I should be able to say "read DMM" and turn around and say "read Daq channel 0" without having to jump thru task and channle hoops and waste a bunch of time doing it).
 
I'll also have Daq digital IO and two 6509 digital io modules.  Do I have to cram all of that into some "task" concept too?  The Daq card has got many other kinds of wonderful capability (frequency measurement, counters, analog output).  How many tasks can I have for that stuff?  On the DMM card I can measure capacitance amoung other things.  Will I have a capacitance task?  The idea of a "capacitance task" hurts my head.
 
Golly I hate tasks.  Please help.
 
I am working out of the office this week - please send your response to grecos@core.com as well as my normal email dave_greco@trimble.com.
 
Dave
0 Kudos
Message 1 of 11
(6,002 Views)
Dave,

Thanks for posting to the NI Forums.

For the good of the community we like to keep conversations that start of the forums on the forums rather than moving to email.  If you want to move to email support I recommend contacting NI through the email route.

I will answer your questions here.  If you need more direct contact please feel free to contact us through support@ni.com.

For some the concept of tasks may seem daunting, however, for many applications it makes life a lot more simple.  A task at a very fundamental level is simply a collection of channels with a single type (AI, DI, DO, etc.)  and a single timing configuration (sampling rate, continuous vs. finite, etc.).  It is a way to organize configuration data.  

The concept of a task is an abstraction like OO programming.  Like OO programming it may take some time to understand but can be a time saver in the end.  Also like OO programming it does add some initial programming overhead.  It is much more simple to simply type a printf statement in C than to have to create a bunch of classes just to output text to the screen. You can accomplish the same thing not using OO programming, but in the end OO programming is extremely useful, because it groups useful information and methods together in one place.

With very simple applications OO programming sometimes does not make sense.  But as a program gets more and more complex OO programming becomes more and more useful.  It takes some learning but it is worth it.

I believe the concept of a task does the same thing.  It does not change the actual functionality of the device or add excessive overhead.  It is just an abstraction that pulls configuration data about a specific "task" and methods the task can perform into a single logical place.

Unlike the entirely abstract concept of an Object, a Task is run on a physical device and therefore has physical limitations.  You can create multiple tasks of the same type, but you can only run a one timed task of each type on a single board at a time.  In other words you can have multiple AI tasks running at the same time but they need to run on different boards or only one can be timed (have a rate).  You can also have multiple timed AI tasks configured for a single board but only one can actually be running at a time.

The reason you can only have a single timed task running at a time is because the M-Series boards (and many other boards as well) have a single timing engine for each type of acquisition or generation.  There is a single timing engine for AI, one for AO, and so forth.  You cannot have channel 1 running at 1 MS/s and another running at 50 kS/s.

However, tasks can exist even when they are not being actively run.  You can create all the tasks you need at the beginning of your program and simply start and stop them as you need.  After the task is stopped you do not need to clear the task until the end of your program.  You can further increase performance by moving the Task into the latest state possible without actually starting the task.  This can be done by calling myTask.Control(TaskAction.Action).  The Task states are further explained in the NI-DAQmx Help Manual.

The concept of a  task will need to be used with any device that is being programmed using NI-DAQmx.  The 6259 and 6509 will need to be programmed using DAQmx.  With the 2575 and 2569 you have the choice of either using the NI-DAQmx API or the NI-SWITCH API.  The SWITCH API does not use the concept of tasks.  For the 4072 you will need to use the NI-DMM API.  This API also does not use the concept of tasks.

Hopefully this information is helpful.  Let me know if you have any additional questions or concerns.

Regards,

Neil S.
Applications Engineer
National Instruments

Message 2 of 11
(5,998 Views)

Thanks Neil, that does help.  Perhaps what you wrote here is in the help somewhere, but I couldn't find it.  Understanding the whys as well as the whats helps me work with the system instead of against it.  I'm beginning to get the picture.  Bear with me a bit more while I wrestle with making this work smoothly in my OO app.

We may never use analog output, or the PFIs, or 90% of the other terrific whizbangs available.  Almost everything this system will do is: 1) set relays and digital outputs to some state and then 2) maybe delay a little bit before taking a measurement.  I'll do this about 100 times for each UUT. Each of those will be a test object.  There will be as many as 12 UUT objects running in parallel starting and stopping at various times.  Each test object will request relay and DO settings from some hardware supervisor object.   At any given time, several hundred test objects will be in a queue waiting for their respective requests to be granted.  Once granted, they'll then request some sort of AI and wait for that.  Then they'll release their relays and DOs and go out of scope.

Much of my difficulty comes down to sample rates and number of samples.  One test object may really need 2million samples at the max rate; another may be perfectly content with 100 samples at 1kHz.  Still another might choose to 90 samples at 1.1kHz.  Those last two examples illustrate a sticking point.  The two objects could probably co-operate and compromise on the some common setup, but from a OO point of view, each test object should not have any "awareness" of any other test object, but should be concerned only with its own duties.

I could allow every test object to set its own configuration at every read.  This would maintain the OO nature but would slow the system with configuration overhead - most of which would be silly and avoidable.

Perhaps a reasonable alternative would be to provide some kind of AI wrapper that includes a relatively small set of numSample/sampleRate pairs in an enumeration.  The wrapper could also provide a custom configuration that should be used rarely.  In effect, the wrapper tells all of the test objects "Choose from one of these two or three standard AI configs and things will go fairly quickly.  If you must do something weird, be aware that I'll have to change gears first to switch to your special needs, and then again after you to go back to what most everyone else needs.  Changing gears will slow you down and will slow other test objects too."

You said that sample rate dictates when I must change tasks and suffer some time doing so.  I recall that merely changing the number of samples also requires a task change even if the rate is the same.  Can you elaborate on that please?

Is there any reason why I shouldn't just always sample at the maximum rate?  For a DC measurement I suppose this means I'd have to analize thousands of data when only a few would get me reasonable filtering.  But I can do quite alot of analysis in a msec whereas changing configuration can take 150msec.

Speaking of 150msec, your tip about controlling the task state carefully may be very helpful.  If I can get that down to 50msec or so, I'd be much less grumpy 🙂

In the end, if I can get average AI overhead to be no more than 10msec, I'll be very happy.

Thanks,

Dave

0 Kudos
Message 3 of 11
(5,954 Views)

Hello

 

Hope you guys are in good health.

 

I am working on a circuit builing where i have 10 connection one after another. I need to give the connection like this pattern 0 90 180 270 0 90 180 270 0 90 (degree phases). I have an function generator through which i applied voltage and which amplifies my applied voltage into 20 times. So i need to know how can establish the my 10 connection with any of those Ni 2575/SCB 68. Can anyone give me an idea???

 

I am trying to search and read about those for last 10days and i didnt find any useful hints to make my worker further. Can you please help me out ???

 

Hope i will get a response.Thanks in advance.

 

Have a nice day.

 

Regards;

 

Hassan

0 Kudos
Message 4 of 11
(4,997 Views)

Hello Hassan,

 

The 2575 is a multiplexing switch. It can connect one input to multiple different outputs one at a time, or vice versa. Are you trying to connect the output of the function generator to ten different inputs on your circuit?

 

You also mentioned the SCB 68, a connector block usually used for data acquisition cards. Are you also using a daq card, or were you thinking of the TBX-50, the connector block for the 2575?

 

Regards,

 

Luke B.

0 Kudos
Message 5 of 11
(4,978 Views)

Hello Luke;

 

Hope you are doing well.

 

Yes i exactly want to give 10 different connection like this pattern of phase 0 90 180 270 0 90 180 270 0 90. i want to use the switch.can you help me to go through it??

 

I tried to find something but i didnt get anything. or is there any other way i can give these 10 connection easily???

 

I really need help.

 

kind regards;

 

Hassan

 

 

0 Kudos
Message 6 of 11
(4,974 Views)

Hello Hassan,

 

Are your 10 connections differential (2 wires) or single ended (1 wire)?

 

How were you planning on controlling the switch? Do you have LabVIEW, or were you going to use another programming environment?

 

Regards,

 

Luke B.

0 Kudos
Message 7 of 11
(4,966 Views)

Hello Luke;

 

Hope you are doing well.

 

All the connections are one wired.And i am planning to use LABVIEW. I am new (very)in this area not have much more idea. Hope LABVIEW will work. The most important thing is there wont be any delay like no holding.All my 10 connections will be simultaneous.If i can get a controlling idea that would be appreciable.

 

Actaully i will apply the voltage and will use a funtion generator to amplify it.

 

Thank you.

 

Kind regards;

 

Hassan

0 Kudos
Message 8 of 11
(4,959 Views)

Hello Hassan,

 

The 2575 you have is a multiplexer switch. This help page describes what multiplexers do.

 

This switch is not designed to change the phase of the signal. The switch only makes connections between its input and outputs. Does your function generator output each of the phases you are looking for, or does it only output one phase?

 

Please also keep in mind that the 2575 uses mechanical relays, so it can take around 1ms for the mechanical relay to switch. I'm not sure what you meant by "no delay and no holding", but mechanical relays do take time to switch.

 

I was also wondering where the voltage that the function generator is amplifying comes from?

 

Regards,

 

Luke B.

0 Kudos
Message 9 of 11
(4,949 Views)

Hello Luke;

Hope you are doing fine.

Actually i understand the mechanical relay. Thanks for letting me know. Like i use function generator and amplifier thats how voltage amplify. Can you give an idea about the input and output port of 2575 (196 *1)??

 

Like  i want that i will apply voltage on function generator software panel and an amplifier will amplify the voltage in my desired value. Then somehow i want connect the switch with that output voltage and want to give a cnsecutive 10 connection of this phase: 0 90 180 270 0 90 180 270 0 90. I want to build different phases in LABVIEW. Now can i make clear my exact  problem?? Hope to hear from you.Thanks for all your help.

 

Have a nice day.

 

Kind regards;

Hassan

0 Kudos
Message 10 of 11
(4,946 Views)