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

5 visualizaciones (últimos 30 días)
Jason Malizia
Jason Malizia el 4 de Dic. de 2018
Editada: gujax el 9 de Mzo. de 2023
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?

Respuestas (1)

Steven Remington
Steven Remington el 11 de Dic. de 2018
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 comentario
gujax
gujax el 9 de Mzo. de 2023
Editada: gujax el 9 de Mzo. de 2023
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

Iniciar sesión para comentar.

Categorías

Más información sobre Clocks and Timers en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by