Jump to content

External sample clock - the rate does matter!


torekp

Recommended Posts

This NI document says

Problem:

Why do I have to specify a rate when using an external Sample Clock?

Solution:

NI-DAQmx uses the rate input to calculate the buffer size for the task. If you want to specify a particular buffer size, use the DAQmx Configure Input Buffer VI or the DAQmx Configure Output Buffer VI.

The rate input of the Sample Clock VI is also used to calculate the dt component of the waveform data gathered by calling DAQmx Read. By modifying the rate input you will see the data being displayed differently each time due to the dt being changed with each different rate input. As noted in the documentation for the DAQmx Timing VI, it is recommended to have the rate set for the maximum expected rate of the external clock.

But that's not the whole truth: it leaves out the most vital fact.

I have an Analog Output and Analog Input task which share an external sample clock. The external clock comes from a belt encoder and averages 125 kHz with small fluctuations around +/- 1 kHz. The external clock line also drives another process on another computer, which I can use as a check on my process. When my process is working properly, it will stay in sync with the other computer.

When I set the "rate input" to 147 kHz (which used to be accurate, but things have changed since then) my process goes out of sync by a very small amount. My process "sees" only about 99.8 percent of the clock pulses; or at least, that's how much it falls behind. When I set it to 125 kHz, the actual rate, it does not go out of sync, or perhaps it does but in a much more subtle way. (I would have to run an eight-hour test to be sure it does not go out of sync enough to matter.)

Has anyone else noticed this phenomenon? How close to the truth does my rate input have to be, to avoid this problem? Or am I just doomed? I'm using a PCI-6110 board for AI and PCI-6733 for AO.

I wonder if this NI document contains the seed of an answer to my issue.

Problem:

I am trying to generate a square wave of 10682 Hz with an update rate of 800 kS/s on the PCI-6733. Why does the frequency of the output signal oscillate? Why am I not getting a stable frequency output?

Solution:

The output frequency is not stable because the PCI-6733 can only generate discrete frequency values for a given update rate. These set of discrete values are obtained by dividing the update rate by a integer value.

For example, if you have an update rate of 800 kS/s, the PCI-6733 can generate 10810 Hz and 10667 Hz with an accuracy of 1 Hz. These two values are obtained by dividing 800 kS/s by 74 and 75, respectively. If you try to generate 10682 Hz, the 2 closest levels to this value are 10810 Hz and 10667 Hz, so the output oscillates between these two values.

Maybe NI is like the X-files: the truth is out there, but good luck finding it?

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.