DAQmxReadAnalogF64 is a blocking function, so it will wait
until NumberOfSamples is received before it returns its values. So the speed at
which it runs is very dependent on the sampling rate and the number of samples
expected. If you reduce the NumberOfSamples do you see an increase in speed?
Also, there are a few other threads that may help, including
some example code to help troubleshoot. Take a look <a href="http://forums.ni.com/ni/board/message?board.id=250&message.id=30739&requireLogin=False" target="_blank">here</a> and <a href="http://forums.ni.com/ni/board/message?board.id=180&message.id=24625&requireLogin=False" target="_blank">here</a>.
Let me know if there's more I can do to help.
Would you mind sharing some background on your desired
application? There may be other things to consider that would help you better
overall than just answering these questions.
Let me do my best to clarify a few things that can affect
program performance. There is overhead in every while loop, read function,
calculation, etc. The read function is going to be one of the more time-consuming
calls because it gets the number of specified samples from the buffer, interrupts
the operating system, transfers the data across the PCI bus, etc. To reduce
this overhead you can increase the number of samples read at a time.
The DAQmxReadRaw will return the binary value before its ADC
conversion and scaling, so it theoretically could run faster than
DAQmxReadAnalogF64, but could be harder to work with. If you need to do
operations in volts, you?d need to convert the data and the conversion you
would perform on the binary data would most likely be slower than DAQmxReadAnalogF64,
so it?s generally not recommended.
Another limitation is that the operating system has no
timing guarantee. The shortest wait function you can even program is 1 ms,
because it?s generally not possible to expect a higher timing resolution. It
could be faster, but it is entirely possible to go slower depending on what
other processes are running. Speed is also dependent on the capability of your
computer. The only thing I can think of to make your code faster than 1 ms per
loop iteration is to have zero wait in the loop (which you may already be
doing). Keep in mind that this doesn?t guarantee anything as the operating
system can still decide whether it gives priority to your program or other ?critical/important?
processes, but it?s the best chance you have before you need to consider
investing in a real-time system and FPGA. However, if that is something you want
to pursue, please visit <a href="http://www.ni.com/support" target="_blank">www.ni.com/support</a>
to get in touch with a salesperson who can spec out a system for you.
When I said there is overhead in every loop, read function,
calculation, etc., I was referring to the fact that those operations take more
computational power to execute than a simply displaying a hard-coded number.
The reason you are stuck around 300 Hz is due to the
specification of the NI DAQPad-6015 for analog output, which can be found on
the product page under specifications or in the <a href="http://digital.ni.com/manuals.nsf/websearch/2A7F7C4E786E3694862570D600777AD1" target="_blank">user manual</a> on page 5. The
analog output has an update rate of 300 S/s. The PCI-6110 is in a separate
league, being a simultaneous-sampling DAQ card with an update rate of 4 MS/s?quite
a bit of difference.
To compare specifications of different products, you can
visit <a href="http://www.ni.com/products" target="_blank">www.ni.com/products</a>; choose ?Data
Acquisition (DAQ)? under the ?Shop for Hardware? column in the middle of the
page. Choose at least one parameter to search and then you can narrow it down
to more specific criteria and compare the products by checking their boxes and
clicking ?Compare?.
I hope this helps.
Correct. The speed limitation is not the DAQmx driver. The
equivalent PCI-6251 is also limited to 1.25 MS/s (1-channel) or 1 MS/s
(multi-channel), so that?s the limit of this particular product family. A
3-year old computer should be able to handle this amount of data, depending on
how often overhead operations, such as reading data, are performed. If you are
calling a read function for every sample, that is going to create a lot of
unnecessary overhead that could slow down any computer.
The last point I want to make is that the sampling rate of
1.25 MS/s seems to be a USB limitation as indicated by this <a href="http://www.ni.com/dataacquisition/find_product_by_application.htm" target="_blank">page</a>, found from <a href="http://www.ni.com/dataacquisition" target="_blank">www.ni.com/dataacquisition</a> by
clicking on ?Compare Product Families? in the upper left.
I?m assuming that since you are
trying to emulate a SPI memory you have a read, write and clk line. The clk
line controls the timing for when you need to read and write. For your digital
read and write tasks what type of timing are you currently using?
I would recommend trying a continuous acquisition
with an external sample clock. In this case the sample clock could be the spi
clk line. This way your read and writes are hardware timed and you can possibly
run your application faster. This will also force your card to use its built in
buffers to store data before outputting it or writing it to buffers in the computer?s
memory.
Below I?ve included the path to a
couple of examples that show how to set up a digital task for continuous
external clk acquisition. The examples should be at these locations on your
computer. They were installed with the DAQmx drivers.
Continuous Digital Read ? External
CLKC:\Documents and Settings\All
Users\Documents\National Instruments\NI-DAQ\Examples\DAQmx ANSI C\Digital\Read
Values\Cont Read Dig Chan-Ext Clk
Continuous Digital Write ?
External CLKC:\Documents and Settings\All
Users\Documents\National Instruments\NI-DAQ\Examples\DAQmx ANSI
C\Digital\Generate Values\Cont Write Dig Port-Ext Clk
Let me know if you have any questions
and have a great week.
Thanks,
As long as you are not trying to read and
write from the same line then both tasks can be started at the same time.
Also they can both use the same sample clock.
Just specify the same sample clock source for both tasks in each tasks?
DAQmxCfgSampClkTiming function. With the same source selected and both tasks
started at the same time. When you have a rising edge on the sample clock it
will read a sample from the read line and write a sample to the write line.
Let me know if you have any questions. Take
care.
Thanks,