Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

Simultaneous continuous pulse train operation WITH synchronized Analog IO

First of all I have a PCI MIO-16E-4 (aka PCI-6040) and am running Labview 7.1 with Daq-mx, I am trying to do three separate tasks at once.  I can do all of these tasks in separate vi's, but have problems when I integrate the tasks together into one vi.  These are the three separate tasks:
 
1) synchronized waveform Analog IO (one channel  input and one channel output).  Each analog IO takes approxamately 0.2 seconds and these analog IO's must be done pretty much continuoulsy (about 4 acquistions per second is good enough) and each acquisition is buffered with ~ 2000 pts in each waveform input and output. 
 
2) continuous pulse train generation on both counters
 
3) Analog voltage input using basically all the remaining channels of the board (not waveform, the lowest priority of all the tasks, I only need ~4 scalar data points per second for each of 9 channels). 
 
I am able to do all of these tasks separately, however I am having problems integrating all the tasks into one vi.
 
 
I modeled my task 1 after the example "Multi-Function-AI-AO.vi",
I modeled my task 2 after "Gen Dig Pulse Train-Continuous .vi"
and task 3 calls one daq-mx read function to read all 9 AI virtual channels
 
 
 
I think that the main problem is with loops.  I need to put all three tasks in a single loop while loop running every 200 ms so that I can turn tasks 1 and 2 on and off separately, but sometimes I get a error saying "50105 error occured at daqmx start task . . . the specified resource is reserved"
 
 
Also the pulse train usually runs at the frequency of the while loop and not at the frequency/duty cycle it is supposed to.
 
Any general advice about comining all these IO operations?
 
 
 
0 Kudos
Message 1 of 13
(4,543 Views)

Hello,

The main problem that I see from your description is that you are trying to perform Analog Input (AI) in two different tasks at the same time.  This is why you are getting the "specified resource is reserved" error.  All AI channels share one AI Sample Clock.  Therefore, you must have all AI channels that you plan to sample from in the same task.  I suggest putting all AI channels from Task 3 into Task 1.  You will have to acquire them at the same rate, but this should take care of the error you are seeing.

As for the pulse train, is it running at the correct frequency when you run it as a separate VI?  Could you send me a screen shot of you block diagram, or even the VI so I have a better idea of what you are doing?

Let me know your results after combining Tasks 2 and 3.

Regards,
Sean C.

0 Kudos
Message 2 of 13
(4,515 Views)
 
 
How do I combine Task 1 and Task 3 into one single task since Task 1 is a waveform data acquisition with 2000 pts per acquisition and task 3 is single point dbl acquisition of nine different channels.  Is there an example you recommend me to look at?  How about the use of a sequence structure inside the loop?
 
I have attached my total vi with all my three tasks inside.  Task 3 is at the top, Task 2 in the middle, and Task 1 at the bottom.
 
Mostly Task 3 and 1 work together but with the occasional error message, however Task 2 doesn't operate at the correct frequency
 
 
Thanks for your help
 
 
Nick
0 Kudos
Message 3 of 13
(4,501 Views)
Hello Nick,
 
The first thing I notice is that your continuous tasks (Tasks 1 and 2) are being created and destroyed in every iteration of your loop.  Usually when you configure a continuous task, you create the task, run it, check for errors within a while loop, then clear it.  You should only create the task once, check for errors while it is running, then clear the task after the while loop completes (see any continuous shipping example).  This is probably why you are not getting the correct frequency out of your counter; you are starting the task, then immediately clearing it in every iteration of your loop.
 
If you correctly set up Task 1 to be continuous, then you will not be able to set up Task 3 as a single point acquisition (you cannot have 2 AI tasks running on the same board simultaneously).  You will have to incorporate all AI channels into the continuous task and read them at the same rate.  If you only need one point from some channels, simply extract one point from the acquired array.
 
The same applies to AO tasks.  It looks like you are using 2 different DAQ boards for your 2 AO tasks, so this shouldn't be a problem.
 
I recommend working with the 2 continuous tasks first.  Once you get Task 1 and Task 2 running together, try incorporating the AI channels from Task 3 into Task 1.
 
I hope this helps.  Please let me know if you have any further questions.
 
Regards,
Sean C.
0 Kudos
Message 4 of 13
(4,472 Views)
Sean,

I have all the kinks worked out of the continuous pulse train generation, Task 2.  I have removed the start and clear task from the loop only calling them when i want to either start or stop the continuous pulse train generation while other tasks are running in the loop.  So this task is working to my liking.

Before I received your response I playing around with the other two tasks (1 and 3), I placed them in a sequence structure so there was no conflict with AI tasks.  This did work, but I am sure that creating and stopping this many tasks is very inefficient, so I welcome your input as a Labview Guru.


I am still a little cloudy on what you recommend for combining the two analog input functions.  Task 1 is a waveform acquisition (2000 points in 0.25 seconds, continuously) and task 3 is a single point acquisition on 9 channels.  You are saying that I should do a waveform acquisiton on all 10 channels and just sample one of the 2000 points for the 9 channels (for which I really only need single point acquisition).  This is 80,000 (2000*10*4 = 80,000) samples per second, I think that an E Series PCI-6040  multifunction board supports 500,000 or 250,000 samples per second.   So this sampling rate should be OK, is this correct??

I am pretty sure that I can do this, but a few questions . . . Task 1 also includes analog output, also through the 6040 board (although I could also do it through my other board which is a 6713) and the analog output part of  task 1 needs to be stopped and started on command, (however it is fine if the waveform analog input is continuous).  NOW for the questions

1) there is no conflict between analog output and analog input on my multifunction board (PCI 6040), these are completely independant, correct? similarly the counter on the multifunction 6040 board is also completely independant of the AI AO on the board, correct?

2) when I need to start my waveform analog output operation, (while the waveform analog input is always running continuously) the analog ouput operation needs to be triggered to run syncronously with the AI operation, currently it looks as if the analog output is triggered digitially from an "ai/StartTrigger".  This should do what I need, correct?



Thanks for your advice, it is very helpful for as I only started working with labview about a month ago.


Nick
0 Kudos
Message 5 of 13
(4,464 Views)
Hello Nick,
 
"I am still a little cloudy on what you recommend for combining the two analog input functions.  Task 1 is a waveform acquisition (2000 points in 0.25 seconds, continuously) and task 3 is a single point acquisition on 9 channels.  You are saying that I should do a waveform acquisiton on all 10 channels and just sample one of the 2000 points for the 9 channels (for which I really only need single point acquisition).  This is 80,000 (2000*10*4 = 80,000) samples per second, I think that an E Series PCI-6040  multifunction board supports 500,000 or 250,000 samples per second.   So this sampling rate should be OK, is this correct??"
This is correct.
 
"1) there is no conflict between analog output and analog input on my multifunction board (PCI 6040), these are completely independant, correct? similarly the counter on the multifunction 6040 board is also completely independant of the AI AO on the board, correct?"
Also correct.  The AI, AO, DIO, and Counter functions all operate independently from one another.
 
"2) when I need to start my waveform analog output operation, (while the waveform analog input is always running continuously) the analog ouput operation needs to be triggered to run syncronously with the AI operation, currently it looks as if the analog output is triggered digitially from an "ai/StartTrigger".  This should do what I need, correct?"
Looking at your posted VI, it looks like you have the AO/AI Task set up correctly.  The AI and AO tasks will start simultaneously on the ai/Start Trigger and run synchronously if you give them the same rate.
However, it sounds like you would like to run the AI Task continuously, and then call the AO task some time later, is this correct?  If so, then you cannot trigger the AO off of the ai/Start Trigger, because it will already have occurred.  To run an AO task synchronously with an AI task which is already in progress, you will need use the ai/SampleClock to drive the AO task.  See the attached example VI.
 
Let me know if you have any further questions.

Regards,
Sean C.
0 Kudos
Message 6 of 13
(4,451 Views)
Sean,
I have implemented all that you have recommended so that I can continue to scan all AI voltages, but I can start and stop the AO voltage generation.  I think that it is synchronized correctly, but cannot use my mass spec until tomorrow so I will know then. . . . however everything else is working well.
 
My next question has to do with averaging a certain number of MS (Mass Spec) scans and displaying it at a rate slower than 4 samples per second (while still displaying other stuff at 4 samples/sec).  Obviously I have to collect all data at 4 samples per second because they are all combined in the same task, but I would like to average the MS data over a certain number of measurements and then display (or have data available for logging in a data file) every few seconds or even slower. 
 
I think that this should be possible by extracting the Y array from the wfm and then adding this array to a "reservoir" that is passed between loop iterations using a shift register or feedback node.  Then with the use of a case structure activating after x number of iterations, I could:
 
1) divide the reservoir by the number of data sets which were collected;
2) display and log data;
3) and reset the reservoir.
 
To me this seems like a pretty logical way to do what I am attempting.  I could not find any examples exactly doing this, I could only find examples which kept track of a running avg using a shift register.   If you have an example on hand or have any advice one way or the other please let me know.
 
Thanks for all your help.   I have also attached a copy of my current VI.
 
Nick
0 Kudos
Message 7 of 13
(4,433 Views)
Hi Nick,
 
That's exactly how I would do it.  Take a look at my example VI.
 
Regards,
Sean C.
0 Kudos
Message 8 of 13
(4,415 Views)

Sean,

I have my vi all set up with all the bells and whistles that I want, overall the progam works very well, the AO task can be started, stopped and restarted via an "ai/sample clock", just as you recommended.  I only have two complaints: First problem, When I am doing other things on the computer, such as excel, word or even scrolling the screen of the vi while the vi is running the peaks on my wfm acquisiton (for my mass spectrometer) jump around, making my automatic integration scheme not work so well.  (This also occurs more frequently as I run my loop at faster rates, the erratic behavior is much more common when sampling at 4 or 5 hz as compared to 2 hz.)  I assume what is happening is that the computers is busy doing other jobs and is therefore not starting the AO on time and/or is not reading from the buffer very well.  Second problem seems to be related, also when I am running other programs with the computer, I occasionally get an error about trying to read values for my AI task from the buffer that have already been erased.

Things I can think of which might fix these problems are: taking off extraneous graphs, controls and indicators from my front panel, (or make them not visible).  Would this help even if there are control/indicators/graphs which are on the front panel but located off the portion of the front panel which I am viewing in my window, (because I have lots of these for filter specifications and mass flow controller variables etc.)?

Also would it help to manually set the size of the AI and/or AO buffer to be large so that I don't get any of these errors about "trying to read values from a buffer which have been erased"

Also, I am not sure how the "ai/sampleclock" works (is it taking some trigger from the AI/AO board or from the computer) but could I somehow make use of my unused counter on my multifunction board to trigger my AI and AO tasks very accurately?  Would it simplify things greatly if I got rid of my vi's ability to start/stop AO on command because I have decided that this function is probably expendable.

I am basically trying to get this vi running as efficiently as possible so I can scan at a rate which is as fast as possible, any help or recommendations to acheive this goal which I did not mention or are not aware of are welcome.

Again I have included the latest version of my vi for reference


Thannks,

Nick
0 Kudos
Message 9 of 13
(4,375 Views)

Hi Nick,

It sounds like your while loop is being help up by all of your data manipulation and file I/O.  The errors you are receiving make me think that your while loop is not iterating fast enough to keep up with your data acquisition.  To verify this, try putting your DAQ Tasks in a while loop by themselves.  Do you still receive the buffer overwrite error?

Removing or hiding unused controls and indicators will definitely help improve performance.

It might help in the short term to manually increase your buffer size, but all this will do is increase the amount of time it takes for an error to occur.

ai/sampleclock is an on board clock generated from your board's master 20 MHz timebase.  It is very accurate and not likely to cause the problems you are seeing. 

The ability to start and stop your AO task shouldn't add too much overhead to your application, so it should be ok.

The first thing I would do to begin trouble shooting this issue is to create a new VI which performs only your DAQ tasks.  If this works properly, start adding in the rest of your code piece by piece until you start to receive the error again.  If it turns out that the rest of that code is causing the error, I would recommend looking into a new programming architecture for this VI.  Specifically something like a Producer/Consumer or Master/Slave loop architecture.  These frameworks consist of 2 loops; one for DAQ which runs fast, the other for data manip and File I/O, which can afford to run a little slower.  Please see the LabVIEW Help file for more information about these architectures.  In LabVIEW select File... >> New...  In the window that pops up, browse to VI from Template >> Frameworks >> Design Patterns.  This allows you to view the different architectures available and even build off of a template.

Please let me know how your troubleshooting works out.

Regards,
Sean C.

0 Kudos
Message 10 of 13
(4,359 Views)