Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I sync up 2 tasks with USB-6353?

Hello all,

 

I am trying to configure a USB-6353 to initiate 2 tasks (an analog sample set and a digital sample set) at the same time and make sure the samples of both tasks are sync'd.  As I currently have this coded, the TDMS files generated clearly show the 2 tasks start sampling at slightly different times and actually end up with a different number of total samples.

 

I need both tasks to sample at the same rate, start at the same time (this time does not need to be based on an edge, a software trigger or using the DAQmx Start funtion is fine), and take the same number of total samples if possible (but less important than the first two items.)

 

If it is not possible for the tasks to be sampled at identical times, I am fine with the sampling of both tasks being interleaved (ie, analog channels sampled, digital channels sampled, analog channels sampled, etc.).

 

I have tried 2 or 3 different methods of doing this and I have attached one of them below.

 

Thanks!

0 Kudos
Message 1 of 11
(4,605 Views)

It doesn't look like you based your code on the example that comes with LabVIEW. There is no synchronization at all in your code. Look at the Multi-Function-Synch AI-Read Dig Chan example.

0 Kudos
Message 2 of 11
(4,599 Views)

I realize there is no synchronization in the example I attached, because I attached the wrong file.  I attached the correct one this time.  The example I initially tried to follow was  "Analog Input - Synchronization".  It does not work as I have it coded currently.

 

I found the example you suggested Ni.com but not in the example finder.  I am trying it now.  Where does the "Get Terminal Name with Device Prefix" VI come from?  I don't have it on Labview 2012. 

 

Thanks for your help.

 

 

0 Kudos
Message 3 of 11
(4,595 Views)

It's in the example folder in 2012.

0 Kudos
Message 4 of 11
(4,593 Views)

LucasH0011 wrote:Where does the "Get Terminal Name with Device Prefix" VI come from?

It's a VI used in a few examples.  You will not find it in the palettes.  I recommend saving off a copy for yourself.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 5 of 11
(4,586 Views)

Please look at my latest attempt that I've attached.  This is the method used in the example you provided.  I am getting the same results I had before, with the digital and analog tasks taking a slightly different amount of samples and starting at a slightly different time (the difference is milliseconds).  I tried this with and without the Start Trigger section.

 

I greatly appreciate your help.

 

0 Kudos
Message 6 of 11
(4,578 Views)

Where are you seeing this difference?  In the TDMS files?  The data isn't logged until you read it.  Since you are not reading at the exact same time, the timestamps will be slightly off.  But the data should be clocked in together.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 7 of 11
(4,566 Views)

Yes, the difference is in the TDMS files. 

 

I understand that the data is not logged until I read it, but surely when the data is read from the DAQ's buffer is not what determines the timestamp (wf_start_time)...

0 Kudos
Message 8 of 11
(4,549 Views)

Hello LucasH0011, 

 

When you are saying you are getting slightly different amounts of samples, how many are you getting? Your code will write 100,000 samples per channel and then read all of the samples in the buffer. 

Maggie
National Instruments
Applications Engineer
ni.com/support
0 Kudos
Message 9 of 11
(4,508 Views)

I'm sorry to respond after a week, I've been out on vacation.

 

Using the code in the latest example I attached on here, the total # of samples collected depends on how long you wait to click "stop" on the front panel.  So, after the most recent time I ran the code... I collected 12,965 samples for each analog channel and 13,001 samples for each digital channel.

 

I have come to understand, through emailing with another NI engineer, that I won't be able to sync up the tasks using a software trigger - I'll need to use a hardware trigger shared by both tasks.  Additonally, I won't be able to stop them at the same time (and I am OK with this) without using a phyical stop trigger as well.

0 Kudos
Message 10 of 11
(4,484 Views)