I want to generate pulses (basically a square wave) at a frequency of 5MHz using on board counters in NI USB 6251 multifunction DAQ. I have attached the file here (it is rather a very simple code). Uptil about 10kHz, I get very nice pulses; however, as I begin to increase the frequency from there, the pulses start to deteriorate. By the time I set the frequency close to 600kHz, the pulses are no longer distinguishable. Does anyone have any idea on what I might be doing wrong or if there is some piece of information I'm missing out on?
What do you mean "deteriorate"? Are you looking at the output with a scope? Can you post those traces please?
You're code should be fine - the issue is likely HW related (wiring, shielding, reflections, etc.). How are you wiring the counter output to whatever you're using to measure the signal?
Pardon me for the diagram (I hand drew it). The pulses look like this at 13kHz. I'm using a voltage probe with one clip at the pin to which wire from PFI13 (default pin for counter output) is tied (or connected) via a connector and the other clip at potential ground.
No worries on the hand drawing, but a scope trace would be nice. The counter output uses TTL logic, so the voltage should not look stair-stepped like this. The kind of deterioration I would expect to see is large overshoot, long settling times, etc.
I also get the error as in the file attached herein. I really do not know what to do with this.
Apart from that, I'm using Yokogawa DL850 oscilloscope. Could it be that the scope is slow enough to not be able to generate the right CLK signal?
Looks like that scope has a 100 MS/s sampling rate, which should be plenty fast to capture even the 5MHz signal. Just to make sure it isn't a scope issue, try generating a 50kHz square wave and reading the output with one of the analog input channels of the 6251. You'll want to sample the AI at the max rate (1.25MS/s). If that looks good, measure the same signal with the scope. Note that the max square wave frequency you'll be able to reasonably test like this is ~100kHz.
Please post a screenshot of the waveform acquired by the AI when you finish this test.
I was using a slower card on the oscilloscope (1 M samples/sec, 16 bit); so when I changed the card to 100M samples/sec, 12 bit), the clock pulse looked fine. Though like you mentioned there could be possible overshoots, you were right about them. I'm not so much concerned about them just yet. Your suggestion about reading the square pulse output through one of the analog inputs was helpful. Thanks!