Hi,
I'm kinda new to the use of Digital lines and Couters in the NI DAQmx environment and am seeking assistance.
I'm using the M-series PCI-6221 board with two 24 bit counters.
I'm using DAQmx 8.3, and I am programming in C++ using Microsoft Visual Studio .NET 2003.
The first set of questions are related to digital output (DO). I'd like
to output a 1000 sample sequence, repeatedly. The DO will be used
to clock an external device. My intention is to open a binary
file (created in Matlab), copy its contents to an array, and play out
the array values at 1000 Samples/sec. To accomplish this I first set-up
a counter to generate a clock signal, using the 100kHz sample clock:
DAQmxErrChk (DAQmxCreateTask("",&COHandle));
DAQmxErrChk (DAQmxCreateCOPulseChanTicks(COHandle,"Dev1/ctr0","","100kHzTimebase",DAQmx_Val_Low,0,25,25));
DAQmxErrChk (DAQmxCfgImplicitTiming(COHandle,DAQmx_Val_ContSamps,1000));
Then I set the DO to use this clock:
DAQmxErrChk (DAQmxCreateTask("",&DOHandle));
DAQmxErrChk (DAQmxCreateDOChan(DOHandle,"Dev1/port0","",DAQmx_Val_ChanForAllLines));
DAQmxErrChk
(DAQmxCfgSampClkTiming(DOHandle,"/Dev1/Ctr0InternalOutput",1.0,DAQmx_Val_Rising,DAQmx_Val_ContSamps,1000));
And finally I write out the 1000 samples in the array
data:
DAQmxErrChk (DAQmxWriteDigitalU32(DOHandle,2,0,10.0,DAQmx_Val_GroupByChannel,data,NULL,NULL));
My DO questions are:
1). Is
DAQmxCfgSampClkTiming the appropriate way to set the DO clock source? It's
behavior is a bit unexpected since, the value for the rate parameter
(=1.0 in the code above), is irrelevant when I set the clock source to /Dev1/Ctr0InternalOutput.
2) Since I want to output the same DO sequence repeatedly, I assume my
performance will be improved by not regenerating the data. How do I
produce DO output without regeneration?
3) I'm not clear on the behavior of
DAQmxWriteDigitalU32. Does the
data
array have to have values in bits, or in the final voltage output
level? If the values are in bits what range of values will cover full
scale?
The next set of questions are related to Counters. I want to use one of
the counters to timestamp signals arriving on a digital input line
1) What DAQmx function should be used to set a counter's Gate and Source inputs?
2) Is the 100kHzTimeBase 'universal'? Meaning, if I use it for multiple
tasks, will all tasks see the same clock signal, and therefore remain
in sync?
Thanks for advice and comments.