I am using a M-series PCI-6280 board, and I would like to use counter zero divide an external digital frequency down to a lower frequency, which I can then access externally on the counter's output terminal. I think I have done everything correctly (after researching documentation and sample code in the NI developer knowledge base) but no signal shows up on the counter 0 output terminal (pin 2, or PFI 12). I am working with C++ and NI-DAQmx.
Here is a summary of the code I use to set up the task:
// Using C++ string class from standard library std::string clockSource = "/" + GetDeviceName() + "/PFI0"; std::string clkDivCtr = "/" + GetDeviceName() + "/ctr0";
// Divide 576kHz down to 36kHz ErrorCheck( DAQmxCreateCOPulseChanTicks( GetTaskHandle(), // returns the task handle we are configuring clkDivCtr.c_str(), "", clockSource.c_str(), DAQmx_Val_Low, 10, 8, 8) );
// The ErrorCheck() function logs error messages if DAQmx function fails.
ErrorCheck( DAQmxCfgImplicitTiming( GetTaskHandle(), DAQmx_Val_ContSamps, 1000) );
After starting the task, with no errors, the output terminal of counter zero remains blank! Please help!!
As far as setting up the task, I don't see any problems with the function calls you are making. I am curious as to how you are calling the DAQmxWrite function after you have configured the task. Do you have it contained within a while loop so that it executes a continuous generation as you have it configured in the DAQmxCfgImplicitTiming function call? Providing the code for the DAQmxWrite function call would be beneficial.
I was under the impression that the function calls I am making would set up ctr0 to act as a clock divider. I was assuming that a clock frequency present on PFI0 would be counted down using the high ticks and low ticks values provided in the call to DAQmxCreateCOPulseChanTicks. I do not use any DAQmxWrite functions to write any data to the counter output channel.
For example, with the function calls above, I was expecting to be able to feed in 576kHz clock into PFI0, and have a 50% duty cycle 36kHz pulse train appear on the OUT terminal of ctr0.
This is really my objective, which I probably should have made clear from the beginning. What should I do to be able to accomplish this, to basically set up the device to act as a clock divider?