10-16-2008 01:36 AM
Hi all
I need to know if identical acquisition can exist in various locations in a block diagram.
I know it can but I don't know if that is the right or "legal" way to program in Labview, maybe there is a "righter" way to sample from multiple locations? I attached an example which I extracted from an old program of mine.
There a task is created, ai2 is measured then the task is stopped and cleared, in the following the sequence the same is repeated, I needed to measure the same channel at multiple locations in my program and it worked, sometimes I got an error though and I am wondering if this could be the reason? (I don´t remember the name of the error)
Hope somebody understands my strangely written question
10-16-2008 02:40 AM
First of all, the attachment is missing...
But from reading your description, i would suggest you to split acquisition from your program at all; the aim is to create a demon (or server, call it like you want 🙂 ) for dataacquisition and use this demon in your application.
The most common way to implement such a demon would be an action engine (also called functional global variable).
hope this helps,
Norbert
PS: The error occurs because you cannot access the same hardware at the same time from different parts in your software.
10-16-2008 04:04 AM
Hi Norbert and thanks, I am going to try this but here is the vi;)
10-16-2008 08:53 AM
Ice_man,
When code is duplicated it is an indication that a loop or subVIs or both may be better architectures for the program.
I would put all the initialization stuff (everything through DAQmx Start Task.vi outside the while loop. Then put the DAQmx Read.vi inside the loop. Some kind of Wait or time delay should also be inside the loop. The Stop Task and Clear Task VIs follow the loop. The sequence structure is not needed. Use dataflow with the error wires and the Task reference wires to control the order of operations.
If your program is more complex than the example posted, Norbert's suggestion of placing the DAQ Read in a parallel loop is a good way. Even in that case, only the Read VI is called on each iteration of the loop. For an example of this kind of program look at the Producer/Consumer design pattern which ships with LV.
Lynn