필터 지우기
필터 지우기

Syncing a DAQ card waveform-output to an external clock.

조회 수: 5 (최근 30일)
Jason Malizia
Jason Malizia 2018년 12월 4일
편집: gujax 2023년 3월 9일
I am using the data aquisition toolbox to interface with a NI DAQ card. I want to use the DAQ card to output a square wave. If I use the internal clock of the DAQ card this is very simple:
sessionX = daq.createSession('ni')
ctr0 = addCounterOutputChannel(sessionX,'Dev1','ctr0','PulseGeneration');
ctr0.Frequency = 1000;
However, I want the outputted square wave to be synced to an external clock. Is there a way to sync the counter output channels on the DAQ to an external clock? For example with the code
cc = addClockConnection(sessionX,'external','Dev1/ctr0','ScanClock')
Or is it impossible to sync the counter output channels to an external clock, and instead I would have to look at outputting the squarewave on an analog out channel synced to the external clock?

답변 (1개)

Steven Remington
Steven Remington 2018년 12월 11일
In order to synchronize DAQ device with an external clock, both a start trigger and a sample clock should be used to control the first pulse and the timings between each consecutive pulse, respectively. The code below shows how the two would work together:
s = daq.createSession('ni');
ch = s.addAnalogInputChannel('Dev4','ai1','Voltage'); % USB-6008
trigConn = s.addTriggerConnection('External','Dev4/PFI0','StartTrigger');
clockConn = s.addClockConnection('Dev4/PFI0','External','ScanClock');
  댓글 수: 1
gujax
gujax 2023년 3월 9일
편집: gujax 2023년 3월 9일
Hi Steve Can you please elaborate? Which terminal here is the external clock connected to? Assume it’s pfi0? I think the question was if you have connected an external clock is there a way to get a sync output of that clock? Counter does not do that because you have to provide frequency on demand and there is bound to be a mismatch. So not sure what your solution means? You have an analog input. What is it connected to and doing what? And then you have declared a clock going out to external connection. But which terminal is that output from? Should I then output a Counter just like how Jason suggests? However it’s output will only match the start in the beginning but later the counter will go out of sync because even external clock isn’t perfect. If that external clock is driving something else besides DAQ, those devices and DAQs will go out of sync.
The only way out is to output that external clock from analog output. This is if you want to sync start everything starting with DAQ

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Clocks and Timers에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by