Synchronize digital and analog output on NI PCIe-6251 / BNC-2110

6 views (last 30 days)
Hi,
I am using two analog ouputs on BNC-2110 (NI PCIe-6251) for controlling a galvo-scanner (x- and y-axis) and one digital output for controlling the exposure start of my CMOS-camera. When I start them consecutively in my script (see example code), there are huge timing jitters in the execution time of the start dqCamTrigger command (in the order of milliseconds, which changes the phase relation in each execution). Is there any good way to synchronize both the digital and analog output so they have a constant phase relation? Here is the relevant code I extracted from my program:
d = daqlist;
d{1, "DeviceInfo"}
dqScanner = daq("ni");
dqCamTrigger = daq("ni");
[ch1, ixd1] = addoutput(dqScanner, "Dev1", "ao0", "Voltage");
[ch2, ixd2] = addoutput(dqScanner, "Dev1", "ao1", "Voltage");
ch3 = addoutput(dqCamTrigger, "Dev1", "ctr0", "PulseGeneration");
SVoltArray = [1 0 0 0 0 0
0 0 0 0 0 0 ]' %just an example array
dqScanner.Rate = SampleRate*1000;
dqCamTrigger.Rate = SampleRate*1000;
ch3.Frequency = 1/((LineTime)/1000);
ch3.DutyCycle = 0.25;
preload(dqScanner, SVoltArray);
start(dqCamTrigger, 'Continuous');
start(dqScanner, 'RepeatOutput');
Thank you for your help :)

Accepted Answer

Patrick Byers
Patrick Byers on 5 Apr 2023
Hi all,
I solved the problem myself and post it here in case somebody else needs a solution for this. I just assigned the digital output to the data acquisition interface "dqScanner". When starting the dqScanner interface, both digital and analog output channels are started with synchronization (without any additional command).
[ch1, ixd1] = addoutput(dqScanner, "PXI1Slot2", "ao0", "Voltage");
[ch2, ixd2] = addoutput(dqScanner, "PXI1Slot2", "ao1", "Voltage");
ch3 = addoutput(dqScanner, "PXI1Slot2", "ctr0", "PulseGeneration");
SVoltArray = ...
preload(dqScanner, SVoltArray);
start(dqScanner, 'RepeatOutput');

More Answers (0)

Categories

Find more on Counter and Timer Input and Output in Help Center and File Exchange

Products


Release

R2022b

Community Treasure Hunt

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

Start Hunting!