08-26-2010 05:18 PM
Hi all,
I am trying to digitally output a sequence of 99999 0s and a 1 to Port2, Line 0 on my NI PCIe-6537. I have successfully generate the sample on the specified pin at 20 MHz. And then I did some timing test to see how long it takes to run 200 iteration of sample generation (see Timing Test 2 attachment). It seems like 200 iterations takes 2.3 seconds, which is very long. I would prefer to have it under 1 seconds.
My thinking is that DAQmx Channel Creation, DAQmx isDone, and DAQmx Clear Task is slowing it down at every iteration since we are repeating the task that could just configure once. So, I tried to put the Channel Creation, DAQmx isDone, and DAQmx Clear Task outside of the while loop to increase the speed of the VI. When I run this VI, Timing Test 3, I get an error (Error -200288 occurred at DAQmx Write (Digital 1D U8 1Chan NSamp).vi:2). Please see the attached screenshot for error.
I am also attaching both VIs.
Hope someone can help me with this problem, I would REALLY appreciate it. Thanks!
Cheers,
-YK
08-26-2010 05:49 PM
You should give a look at some of the shipping examples. You do not want the Create Channel, Timing, Start Task, Stop Task, Clear Task inside the loop. You have a Is Task Done that is doing nothing. Your test 3 example has the functions outside the while loop but still inside a for loop and that is nearly as bad. I also don't understand why you have the Start Task after the DAQmx Write. As I said, place it outside the loop which would mean before the write.
08-27-2010 10:58 AM
I tried to put the Start Task before the DAQmx write as you said but I get an error (Error -200462 occurred at DAQmx Start Task.vi:4). Please see the attachment for a screenshot of the error.
I also removed the Is Task Done. I ran the program and it gave me a time of about half, 1.3 seconds to do 200 iterations. But, I do not see the 1 on my oscilloscope as I did with the previous VI. I'm thinking that it is not actually writing the data to the port.
Cheers,
-YK
08-30-2010 11:23 AM
YK:
There's a community example that might help out a bit. Some timing tasks may be moot (depending on the capabilities of your hardware), but the top task demonstrates building the array of desired values and writing them to a digital line.
I would also strongly second Dennis's recommendation about the examples. The shipping examples will provide much more insight into how different types of digital output tasks are structured.