Clear Filters
Clear Filters

DAQ multiple rates with digital output

3 views (last 30 days)
Hilton
Hilton on 9 Jun 2022
I need to generate pulses to synchronize the DAQ board analog output with other two devices through TTLs. I am using the following code
s = daq.createSession('ni');
s.Rate = 1000;
%Add analog output channels
s.addAnalogOutputChannel('Dev1',0:1,'Voltage');
s.IsContinuous = false;
%Add digital outputs to trigger external devices
DO1 = s.addCounterOutputChannel('Dev1',0,'PulseGeneration');
DO1.Frequency = s.Rate;
DO1.DutyCycle = 0.1;
DO2 = s.addCounterOutputChannel('Dev1',1,'PulseGeneration');
DO2.Frequency = s.Rate/100;
DO2.Frequency = s.Rate;
DO2.DutyCycle = 0.01;
s.queueOutputData([linspace(-1,1,100) linspace(-1,1,100)]);
s.startForeground;
s.stop;
release(s);
clear s
The code runs and it performs the desired outputs, but the pulses DO1 and DO2 are not synced (as checked in a fast oscilloscope), although the analog output and DO1 are synced. I asked a colleague to write a simple "program" in labview (to output two TTLs at 1KHz and 10Hz) and we clearly observe that the two ouputs are synced, so it looks like some sort of bug in Matlab. Anyone has seen a similar issue?

Answers (1)

Sivapriya Srinivasan
Sivapriya Srinivasan on 7 Sep 2023
Hello ,
I understand that you are experincing synchronzation issues with the digital output channels while generating pulses using DAQ toolbox
1.Ensure the devices are synchronized with the same clock
2.Refer to the specifications of your DAQ board to ensure it supports simultaneous updates of multiple output channels
3.Adjust the buffer and latency settings in your code so that there are no delays affecting the synchronization
For further assistance please provide more information about your hardware setup and any error messages you encounter

Categories

Find more on Data Acquisition Toolbox Supported Hardware in Help Center and File Exchange

Products


Release

R2019b

Community Treasure Hunt

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

Start Hunting!