06-18-2011 09:34 PM
Hi,
I'm studying the GenDigPulseTrain_Continuous example from the NI DOTNET3.5 examples. I'm trying to use the COChannel Count property to get the total number of pulses generated.
A code snippet from the example with minor modifications for my hardware is shown below:
try
{
myTask = new Task();
_startCount = 0;
myTask.COChannels.CreatePulseChannelFrequency(counterComboBox.Text,
"ContinuousPulseTrain", COPulseFrequencyUnits.Hertz, idleState, 0.0,
Convert.ToDouble(frequencyTextBox.Text),
Convert.ToDouble(dutyCycleTextBox.Text));
COChannel d = myTask.COChannels[0];
d.PulseTerminal = "/DAQ/PFI4"; //added this for my hardware wiring
myTask.Timing.ConfigureImplicit(SampleQuantityMode.ContinuousSamples, 1000);
myTask.Start();
_startCount = myTask.COChannels[0].Count;
startButton.Enabled = false;
stopButton.Enabled = true;
statusCheckTimer.Enabled = true;
}
I'm setting myTask.COChannels[0].Count to _startCount, but the value does not seem to correspond to the actual number of pulses. It produces a huge number. The NI DAQmx help files regarding the class just says the Count "Indicates the current value of the count register".
How can I use the Count property to return the total number of pulses generated once the user hits the Stop button?
-Chuck
06-20-2011 08:13 AM
Unfortunately, the short answer is, "you can't." As you've seen, the count register is busy managing the pulse timing
characteristics and isn't available to count the # of pulses generated. The best alternative is to program a 2nd counter
to count the pulses generated by the 1st.
-Kevin P
06-20-2011 10:06 PM
Interesting. I wonder why DAQmx exposes the Count property of the counter if one cannot use it to check the count? I was expecting there to be some type of tick conversion to make the value returned useful.
-Chuck