05-08-2009 01:20 PM
I have a PXI-4461 and I'm using DAQmx inside of Microsoft Visual Studio 2005 to control it. I did some timing of my function calls and noticed that the function DAQmxWriteAnalogF64 was taking about 50 millisecounds to run. Is it possible to make this call faster? Is there anouther call I could use that would be faster?
Bill
05-11-2009 01:23 PM
Hi Bill,
While there's no faster function, I'm curious as to how you have your program setup. What kind of sampling rate are you outputing? How many samples are you writing at a time? Do you have this in a loop? How is the loop timed, and how are you measuring the 50 milliseconds? Thanks in advance!
05-11-2009 01:47 PM
Thanks for your response. What I was timing was the DAQmxWriteAnalogF64 function call it-self not the pattern running. I used QueryPerformanceCounter to make my timings measurements. What I was trying to do was to speed up the time it took to change of pattern the pin would run.
Bill
05-12-2009 08:21 AM
05-12-2009 02:40 PM
Hi Bill,
Unfortunately, there's no way to make the actual function run faster, unless you're willing to upgrade your processor. One thing you might explore is multithreading so that you are starting the tasks at the same time, but on different threads. As well, I'm curious what you're program flow is like: are you declaring both of your tasks, and then starting them both, or are you declaring and starting your task for your first device, and then declaring and starting your task for the second? Thanks!
05-13-2009 04:49 AM
Bill,
Can you provide more details about what you are attempting to do?
Are you doing single point, programmed I/O writes, or are you doing buffered writes and using hardware timing?
There are several things that could be slowing you down, and there are ways to use hardware triggers to synchronize start across multiple devices. However, without a few more details, it'll be hard to make any specific recommendations.
Dan
05-18-2009 09:54 AM
05-18-2009 09:46 PM
Hi Bill,
I'm afraid that I still don't have a very clear idea about what you are attempting to accomplish. You mention that you are attempting to do a write to a PXI-4462, but this is a device which does not support analog output.
In general, if you want output from multiple devices to be synchronized then your best bet would be not to attempt to use software timing to do this (ie... spawning multiple threads and attempting to call start at the same time on both), but rather to use the hardware itself to handle synchronization. To do this, typically you share a sample clock between the two devices, and use the start trigger from one device to start the other.
If you must use software timing, then you'll want to ensure that you're using the DAQmx API as efficiently as possible. At the heart of DAQmx is a state machine which handles task configuration and resource management. For a task to be started, it must transition through several states. First the task is verified, meaning all of the channels you create and settings you make are examined and verified to be supported on your hardware. After this, DAQmx must reserve all of the resource necessary for your task. This ensures that each resource can be used by only one task. Once the resources necessary for the task have been reserved, the configuration for your task is committed to hardware. In this step, the configuration for your task is translated to register level commands, and these are written to your device. Only after all of this has happened can your task be started. If you only create a task, make some settings then call start, the call to start performs all of these steps. However, you can use DAQmxTaskControl to advance the DAQmx state machine before calling start. If you were to call DAQmxTaskControl, and pass DAQmx_Val_Task_Commit in as the action before calling DAQmxStartTask, then the DAQmx state machine would have already taken care of the work of verifying your task, reserving resources, and programming the task's configuration to hardware. If you are not doing this, DAQmxStartTask will take longer than it otherwise could.
So my suggestion would be to use hardware triggers and timing to synchronize your devices if possible. If not possible, see if you can optimize the way your code interacts with DAQmx's state machine to minimize the amount of work that needs to be done when you call start. If you could explain in a bit more detail what you're attempting do, or post a code snippet I may be able to give more specific advise.
Hope that helps,
Dan