Showing results for 
Search instead for 
Did you mean: 

How to use M-series counter to output digital pulse train??


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
    8) );

// The ErrorCheck() function logs error messages if DAQmx function fails.
ErrorCheck( DAQmxCfgImplicitTiming(
    1000) );

After starting the task, with no errors, the output terminal of counter zero remains blank!
Please help!!

Markus Svilans.

0 Kudos
Message 1 of 4
Hi Markus,

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.

Andrew W
National Instruments
0 Kudos
Message 2 of 4
Hello Andrew,

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?

0 Kudos
Message 3 of 4
Hello Andrew,

I found that the "Dig Pulse Train-Cont" example C program illustrates what I need to accomplish.
Thank you for your kind assistance.


0 Kudos
Message 4 of 4