Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

data acquisition sub-vis in loops

The requirement to place initialization of DAQmx tasks outside of loops in LabView makes it very difficult to encapsulate these tasks in a sub-vi for use within a loop. Each task must consist of 2 separate objects, the initialization and the actual execution, which must be connected across the loop boundary. The programmer must remember the association of the two parts and remember that if the task is used somewhere, the associated initialization must also be used.

 

How does anyone else manage this problem? Or am I the only person that wants to put a DAQmx task in a sub-vi?

0 Kudos
Message 1 of 8
(3,707 Views)

I'm not sure I understand the difficulty. You have a subVI with a case for initialization. This passes a\the task back to the mian. The main then passes the task back to the subVI and you select the acquisition case. When done, you pass the task back to the subVI for the stop task case. Keeping the task in a shift register is pretty simple when you use a state macine. You are using a state macine, aren't you?

0 Kudos
Message 2 of 8
(3,694 Views)

Where can I find an example of this method?

It doesn't make much sense to me as described.

 

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

Hi Tech,

 

Thanks for answering, Dennis. Tech, keeping the task in a shift register will make it accessible to future loop iterations. This is particularly useful when implement a daqmx task in a state machine. For some more info on state machines, check out this tutorial. Also, why do you have to have daqmx tasks inside loops? Perhaps there is a better way to do this.

 

Best,

Sean Ferguson
Application Engineering Specialist | RF and Reconfigurable Test
0 Kudos
Message 4 of 8
(3,659 Views)

 


@Sean F wrote:

Hi Tech,

 

Thanks for answering, Dennis. Tech, keeping the task in a shift register will make it accessible to future loop iterations. This is particularly useful when implement a daqmx task in a state machine. For some more info on state machines, check out this tutorial. Also, why do you have to have daqmx tasks inside loops? Perhaps there is a better way to do this.

 

Best,


 

I don't see how keeping the task in a shift register will solve the problem of having to keep track of the association between the initialization and the task. They will still be separate objects. It also appears to be unnecessary to use a shift register, since what I do now with the initialization outside the loop is to just connect directly to the task inside the loop, with no shift register involved.

 

I briefly looked at the description of the State Diagram Tool kit. It appears to be suitable for "large scale application development". What I am doing does not qualify as "large scale application development", and my Basic LabView Development system does not have the State Diagram Tool kit. Even if I had the State Diagram Tool kit, a state machine is far too complex for the simple applications I am developing.

 

I develop small applications which exercise various components to determine low long they last and how they ultimately fail. This requires simultaneously stimulating the components and collecting data regarding their performance via a multifunction DAQ card until some (usually very large) number of cycles has occurred or some error threshold is reached. The logical way to do this is to put the stimulation and data collection sub-vis inside a loop and run until whatever. However, the initialization can not be put inside the loop because the overhead involved causes the timing relationship between the stimulation task and the data collection task to become unpredictable.

 

The result of this is (apparently) that LabView code that contains associated DAQmx initializations and tasks can not be encapsulated in a sub-vi and then subsequently be used inside a loop. This seems to break the LabView paradigm of being able to encapsulate any piece of code into a sub-vi. If a sub-vi containing DAQmx initialization is buried several layers down in a program and it must be put inside a loop, it can be very difficult to break out the initialization part and provide a data path for its output back to where the task it creates is supposed to be executed.

 

0 Kudos
Message 5 of 8
(3,644 Views)

Hi Tech,


I don't quite understand the problem you're having. Starting from the cont acquire and graph analog voltage internal clock example ( Help » Find Examples » Hardware Input and Output » DAQmx » Analog Measurements » Voltage ), I encapsulated  
DAQmx Create Channel and DAQmx Timing in a sub-vi and simply passed the reference to the remainder of the code (DAQmx start, DAQmx read, DAQmx Clear Task). So, there is no problem encapsulating DAQmx tasks in sub VIs. Maybe you could clarify where exactly you're running into trouble.

 

Best,

 

Sean

Sean Ferguson
Application Engineering Specialist | RF and Reconfigurable Test
0 Kudos
Message 6 of 8
(3,619 Views)

There is no problem encapsulating the initialization and the task execution separately.

 

The problem is that once that is done, the programmer has two objects that are associated with each other. The programmer must remember this association, and the fact that neither of the two objects may be used without using the other object.


@Sean F wrote:

Hi Tech,


I don't quite understand the problem you're having. Starting from the cont acquire and graph analog voltage internal clock example ( Help » Find Examples » Hardware Input and Output » DAQmx » Analog Measurements » Voltage ), I encapsulated  
DAQmx Create Channel and DAQmx Timing in a sub-vi and simply passed the reference to the remainder of the code (DAQmx start, DAQmx read, DAQmx Clear Task). So, there is no problem encapsulating DAQmx tasks in sub VIs. Maybe you could clarify where exactly you're running into trouble.

 

Best,

 

Sean


 

0 Kudos
Message 7 of 8
(3,609 Views)

If I were to wrap the DAQmx driver calls into subVIs within a simple state machine architecture my VI might look something like this.  The shift registers allow you to set the task handle within the loop, and then pass it onward to subsequent iterations:

 

2010-11-30_165356.png

 

If you have other parameters to pass between loop iterations it might make more sense to bundle these parameters together (including the task handle) into a single type-def cluster.  Does this sound like what you want to do?

 

 

Best Regards,

John Passiak
Message 8 of 8
(3,605 Views)