Digital I/O

cancel
Showing results for 
Search instead for 
Did you mean: 

How to set a fixed latency / dealy to NI 6535b card for digital output

Solved!
Go to solution

Hello!

 

I am using NI 6535b card to output digital waveform at tens of kHz sample rate. However, I suffer from a unknown delay between my sample clock and the first output of the waveform. For example, my card will output a series of waveform to do beam scanning and at the same time a camera will be triggered by the sample clock to capture the beam position simultaneously. Ideally, the first beam position (or the first sample of the waveform) corresponds to the first frame of the camera. However, I notice sometimes the first beam appears in the 3nd frame and sometimes in the 5th frame. According to my test, under 1kHz the latency is not an issue. Otherwise, the latency of the card is not fixed and is related to the sample rate. 

 

My question is how I can set a fixed delay to the card so that the first beam position (corresponding to the first output of the waveform) is always synchronized to the first frame of the camera. Any help will be appreciated!!!

 

 

For your information, I am using the "continuous pipelined digital generation" sample code as attached below to output the waveform. The waveform is already generated before I run the code.

 

unfixed latency problem.png  

0 Kudos
Message 1 of 6
(2,039 Views)

Just to make it clear, we have tested the camera. It works perfectly and it is fast enough to be triggered by the sample clock.

The problem is the waveform output is several pulses slower than the sample clock output.

How to sync the sample clock and waveform output?

0 Kudos
Message 2 of 6
(2,034 Views)

This is probably a direct result of choosing the Pipelined sample clock rather than the plain old regular sample clock.  As far as I know I've never used a device that supported a pipelined sample clock, but the help mentions the possibility of a few sample clocks worth of latency.

 

It's main purpose seems to be for high bandwidth applications.  You shouldn't need it for 1 kHz generation.  A regular sample clock ought to work fine.

 

 

-Kevin P

CAUTION! New LabVIEW adopters -- it's too late for me, but you *can* save yourself. The new subscription policy for LabVIEW puts NI's hand in your wallet for the rest of your working life. Are you sure you're *that* dedicated to LabVIEW? (Summary of my reasons in this post, part of a voluminous thread of mostly complaints starting here).
0 Kudos
Message 3 of 6
(1,988 Views)

Dear Kevin,

 

Sorry for the late response. I tried your suggestion and it worked for the card running in the master mode. No latency appeared with normal "sample clock"! Amazing!

However, if I trigger the card for digital output (i.e., the card works in slave mode), even with "sample clock" I still suffer from 1 camera frame latency. Can you kindly advise how to solve this problem? 

 

Thank you in advance!

 

David

 

unfixed latency problem in slave mode.png

0 Kudos
Message 4 of 6
(1,928 Views)
Solution
Accepted by topic author zy_chen

I'm not familiar with what you call "master mode" or "slave mode" for that board, but maybe that's just because I haven't used that family of boards before.

 

What I see is a hardware race condition between the trigger signal and the external sample clock.  You're using the same edge of the same signal for both.  Since the task has to get start triggered before it'll be ready to accept any sample clock pulses, *that* is very likely the reason for your 1-sample offset.

 

To work around this problem I often advise people to trigger on the *leading* edge while using the *trailing* edge as the sample clock.  If the incoming signal's a square wave, that'll still give you 1/2 cycle of latency.  If that's too much, I'd need to know more about the app and the specific needs for sync.

 

 

-Kevin P

CAUTION! New LabVIEW adopters -- it's too late for me, but you *can* save yourself. The new subscription policy for LabVIEW puts NI's hand in your wallet for the rest of your working life. Are you sure you're *that* dedicated to LabVIEW? (Summary of my reasons in this post, part of a voluminous thread of mostly complaints starting here).
0 Kudos
Message 5 of 6
(1,923 Views)

Hi Kelvin,

 

Thanks for your prompt attention!

You are right that I am using two synchronized trigger signals to trigger the NI 6535b card and my camera simultaneously. 'll try to generate one extra pulse to trigger the card to get it synchronized with the camera.

 

David

 

0 Kudos
Message 6 of 6
(1,919 Views)