LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

DAQmx symultaneous read (analog) and write (digital)

I am using a USB6356 to symultaneously write 3 digital signals with a task and read an analog signal using another task. It works quite well except for the first time I run the program, in this case the read signal is significantly delayed with respect to the output. I have observed the signals on a scope and they were perfectly in sync so the problem seems to be on the acquisition/processing end. 

 

The read/write process is triggered by pressing a button, and this strage behaviour only happens once after I stop and restart the execution of the program. 

 

I have also tried to "force sync" both tasks with a case structure but the result was exactly the same. Any ideas?

0 Kudos
Message 1 of 6
(3,988 Views)

I don't know about the USB devices, but in other environments, I use SIGNAL ROUTING to get this done.

 

Routing.PNG

 

Here I set up the OUTPUT task, but I route the SAMPLE clock to come from the INPUT sample clock.

 

So the input and output are clocked at exactly the same time (within a few nSec).

 

I don't have to rely on trying to get two software paths to line up (which will always be problematic).

Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
Culverson.com


LinkedIn

Blog for (mostly LabVIEW) programmers: Tips And Tricks

0 Kudos
Message 2 of 6
(3,950 Views)

Hello thehun

 

attached a little example to better show what Steve explained

 

 

Bild.png

 

On your device the routing should work, so the clock form the AI can be used for the DO and the AI start trigger to synchronice the in- and output.

 

 

 

best regards
Alexander
0 Kudos
Message 3 of 6
(3,907 Views)

Thanks,

 

unfortunately DO runs at 1MHz rate and the AI at 84KHz so I can't use a shared clock. I have tried to use the same external trigger for both tasks but it won't work since one of the tasks throws the followinf error:

 

Error -50103 occurred at DAQmx Read (Analog 1D DBL 1Chan NSamp).vi:4800001

Possible reason(s):

NI Platform Services: The specified resource is reserved. The operation could not be completed as specified.

Task Name: USB6356_Acq_Trig

 

 

 

 

0 Kudos
Message 4 of 6
(3,871 Views)

Hello thehun,

 

attached a modified example in this the ai start trigger is used to start the do task.

 

best regards
Alexander
0 Kudos
Message 5 of 6
(3,846 Views)

Hello thehun,

 

a second option is a counter which generates a deviced PWM signal from the DO sample clock.

best regards
Alexander
0 Kudos
Message 6 of 6
(3,837 Views)