08-01-2013 12:54 AM
Hi,
I've modified one of the example .NET projects to take an external clock over PFI0 and then output half the frequency on PFI1 by writing out a 0,1,0,1 ... waveform clocked by the PFI0.
My code is here:
This works great, but I have several questions:
1) The arguments to WriteMultiSamplePort are int32, does this mean that I'm changing all the PFI lines everytime I write to this? So bit 0 is PFI 0, bit 1 is PFI 1? Sorry for a basic question but I could not locate any documentation about what this function does.
2) When I feed it a small buffer (say 2 words) it fails with a buffer underrun for high external frequencies. Am I right in thinking that setting ConfigureSampleClock to ContinuousSamples+Rising Edge means that every rising edge it consumes one word from that buffer and copies it over the PFI pins? And then when the buffer is depleted it starts again from the start?
Finally, does this approach make sense? It works well enough, but I have a sneaking suspicion that theres a more elegant way to do this using counters or something like that 🙂
Thanks,
Mike
08-01-2013 04:09 PM
Mike,
Please follow this KnowledgeBase to install the appropiate MesaurementStudio Help files for proper documentation:
http://digital.ni.com/public.nsf/allkb/7082CE3F3940540E8625797C007F25B6
I don't exactly follow your first question so looking through this should help.
As far as underflow errors, you are correct. Underflow occurs with you run out of data on the buffer to write out to the DAQ device. Therefore, making sure you are putting data into the buffer fast enough/making sure there is enough data for finite writes is essential.
08-01-2013 10:34 PM
@AleAlejandro wrote:
Mike,
Please follow this KnowledgeBase to install the appropiate MesaurementStudio Help files for proper documentation:
http://digital.ni.com/public.nsf/allkb/7082CE3F3940540E8625797C007F25B6
Yes I've seen that, but the documentation was not entirely clear for me. Specifically, the WriteMultiSamplePort prototype used in the example files has the prototype WriteMultiSamplePort(bool, int[]). The documentation does not include an entry for that overload, hence I'm unclear on how the inputs are interpreted.
If you have a link to a more complete set of documentation, that would be helpful.
@AleAlejandro wrote:
As far as underflow errors, you are correct. Underflow occurs with you run out of data on the buffer to write out to the DAQ device. Therefore, making sure you are putting data into the buffer fast enough/making sure there is enough data for finite writes is essential.
Thanks, but I wasn't asking about underflow. Do you have any insight into how the ConfigureSampleClock function works? The documention is extremely cryptic.
08-02-2013 02:55 PM
Here is another forum post which talks about it:
and this paper: http://www.ni.com/white-paper/2835/en/