04-12-2012 04:51 AM
I am using a USB DAQ system (6341) for a number of digital output channels. My issue is with the time it takes to action the output. I think I can concisely express my problem like this. I want to output a (small) finite number of samples as a digital waveform at any one time. I subsequently want to output another waveform to the same output channels. I do this by setting up a suitable task, writing the waveform then stopping and clearing the task for each write of the waveform. However to then set up the next task to output on the same lines there is a significant setup time (many ms) before the output waveform is produced. I have also tried using the continuous samples approach but I dont want the signal to be regenerated continually. I am obviously missing something here. How can I send a new waveform (or data) to the digital output lines that are already setup, without the having to re establish a task which I then have to close. Can I reuse a task once it has delivered its specified data to the lines?
a bit more specific. I set up a task to output 32 8 bit words (as a digital waveform) to 8 digital lines on port0. This is performed at whatever the specified rate I choose. the task is set up with finite sample mode and is essentially the same as the example vi Write Dig Chan Int clk... I repeat this process inside a while loop and it takes over 40 mS for the next bit pattern to be produced. Why does this take so long? How can I shorten this?
In principle what is the best way to write new data rapidly to the outputs?
Your wisdom will be much appreciated.
04-12-2012 12:40 PM
Can you post your Labview vi?
I think buffered continuous generation is what you.
Look at the Continuous Generation - Stream from Memory example!
Hope that helps!
04-12-2012 02:20 PM
@Spurious wrote:
However to then set up the next task to output on the same lines there is a significant setup time (many ms) before the output waveform is producedere. How can I send a new waveform (or data) to the digital output lines that are already setup, without the having to re establish a task which I then have to close. Can I reuse a task once it has delivered its specified data to the lines?
Why does this take so long? How can I shorten this?
In principle what is the best way to write new data rapidly to the outputs?
Your wisdom will be much appreciated.
I've been trekking through the exact same territory in DAQmx. In short- your doing it wrong! that is why it takes so long. Here is a little snipette that shows the recommended approach.
Read the notes! and lookup the referances the DAQmx Help file ![]()
04-13-2012 03:02 AM
Jeff
many thanks for posting this. I shall go away and try it out. I made some progress on this yesterday and had a version that worked without the set up delays, but your version looks much more correct in its application method. I was getting errors when I used the wait for task to finish vi as this was leading to underflow errors. I will report back when I have tried out your suggestion .
04-13-2012 06:23 AM
Ok I tried this approach but came across some problems (no doubt one of the many other things I am doing wrong!) I used the method shown above only using the same digital waveform every cycle of the while loop, rather than queuing as shown. This would successfully run once but would then on the next loop cycle generate an underflow error alledgedly due to the driver not keeping up with the ouput rate of the device. this happened no matter how low I made the sampling rate so clearly something else is going on here. The error occurred in the wait for task vi. If I simply remove the wait for task vi the program works but shows a long gap between each iteration of the loop. Indeed the help for the DAQmx states that starting and stopping tasks is inefficient, just that doing it implicity (rather than explicity calling the start and stop tasks) is more inefficient. so in essence I cannot get this approach work for some reason that I have not yet determined, but is definitley related to waiting for the task to finish.
An approach that I have found does work is to use continuous samples rather than finite , but to set the mode to non regenerative. then you dont need to start and stop the task, just write the new data to the running task.
Apologies that I cant post diagrams but the Labview machine is not conneected to the internet. I hope this makes sense and I will try and investigate further next week.
04-13-2012 09:28 AM
An approach that I have found does work is to use continuous samples rather than finite , but to set the mode to non regenerative. then you dont need to start and stop the task, just write the new data to the running task.
That'll do it for those X series! my appologies for not reading your first post more clearly. I has assumed a software timed signal but with hardware timing - the method you describe is preferable. Just another gotcha.
I will address one other comment "Indeed the help for the DAQmx states that starting and stopping tasks is inefficient"- Read the help with quite a bit of care. It does differentiat between single sample tasks, n sample tasks and contineuous sample tasks. In places the Help is in a condition i will refer to as "Richly Obfuscated" , a term I usually reserve for reviews of my boss's code.
I'm glad you got it working! enjoy.