Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

Multiple Devices, Tasks and Threads

I am learning both visual studio and measurement studio at the same time, therefore this question may seem simplistic. My application will need the use of 6 individual DAQ devices, 2 - multi-function DAQ's and 4 digital I/O boards, all in a PXI chassis. In order to run all these devices I assume I will need to create a Task for each one and each Task will run on a separate thread. Is my assumption correct? I only need to sample each at 10s/second it is not necessary to have the devices all synchronized to the same start signal. Thanks.........

0 Kudos
Message 1 of 7
(6,355 Views)

Hi LSMZ,

 

Yes, your assumption is correct.  Each device will need a new task.  Here's a knowledge base article on the subject, http://digital.ni.com/public.nsf/allkb/4AABFC713B77FE0886256EBA00766454?OpenDocument , it has a useful follow on link related to your question as well.

 

Best Regards,

Bobby Breyer
Applications Engineer
National Instruments
0 Kudos
Message 2 of 7
(6,330 Views)

Thanks Bobby.........

Does each task require its own thread? It does not appear so. I have 2 separate tasks now running on their own respective Windows forms but I did not create a new thread for the 2nd form or 2nd task.

Or does the creation of an additional form in the application automatically create a thread for the added form?

0 Kudos
Message 3 of 7
(6,322 Views)

You're correct, each tasks does not require its own thread.  I think your should be running both taks in the same form for the UI.  Is there a reason you're running them separately?

 

Regards,

Bobby Breyer
Applications Engineer
National Instruments
0 Kudos
Message 4 of 7
(6,312 Views)

Hey Bobby-

 

I was basically experimenting around with the concepts of tasks and threads when I wanted to see if a 2nd device with a different function would run on a 2nd form.. Here's my problem:

I have a PXI chassis with a PXI-8109 controller, 2- PXI-6281 DAQ's and 4 - PXI-6528 DIO's. Each DAQ is connected to a SCXI chassis. One SCXI is populated to handle about 40 thermocouples and

the 2nd SCXI is setup for about 30 pressure transducers. The DIO's will handle about 40 digital inputs and 40 digital outputs. I need a sample rate of only 10s/s and the DAQ's don't need a synchronized start.

 

I was planning on doing the following: Setup DAQ1 to convert the TC's connected to the SCXI at 10s/s with the DAQ1 internal clock. Setup DAQ2 to convert the pressure transducers and the DIO modules to function

like the software timed example, except instead of using the VB timer (not accurate), I would use the callback routine for DAQ1 to read the data from DAQ2 and the DIO modules. So the DAQ1 internal clock would pace all

of the reads. I would therefore have 6 individual tasks all paced by the 1st task and this should all work from 1 windows form. Will this scheme work? Any better suggestions?

 

Thanks Bobby

 

LSMZ

0 Kudos
Message 5 of 7
(6,290 Views)

Hi LSMZ,

 

It looks like I was incorrect in what I stated before.  It looks like you can use different devices in the same tasks, so long as it's the same measurement.  This forum post discusses that, http://forums.ni.com/t5/Multifunction-DAQ/How-do-I-have-a-common-sample-clock-across-multiple-cards-... .  For your DIO, those will need to be in a different task.  The underlying question remains the same though, can the second task be paced from the first.  Yes, if you have the right trigger for the measurement.  Could you explain what your call back routine would do?

 

Thanks,

Bobby Breyer
Applications Engineer
National Instruments
0 Kudos
Message 6 of 7
(6,284 Views)

Bobby-

 

Here's what I'm doing and at least so far, it appears to be working.

Setup DAQ1 as the 1st task to perform thermocouple conversions on the SCXI chassis using the internal clock of DAQ1 at 10s/s.

Setup DAQ2 as a 2nd task to perform pressure gage conversions on the 2nd SCXI chassis.

Setup Digital Input on the PXI DIO modules as a 3rd task to perform DI.

Setup a single module (SCXI-1124) in one of the SCXI chassis to perform analog output as a 4th task.

Start (verify) only the 1st task. Perform a begin read on task1(DAQ1).

 

In the callback for task1, I finish reading DAQ1 and then perform a read on task 2 and task 3 and a write on task 4.

The last step is a begin read on task1 to start another cycle.

 

I am displaying values for each task and have voltage sources connected to the various inputs and a voltmeter connected to the analog out and am seeing the correct numbers.

I know I am not getting DAQ1 and DAQ2 started in sync, rather they are running in series rather than in parallel. However for my application, this not a problem.

 

LSMZ

0 Kudos
Message 7 of 7
(6,279 Views)