Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

Task Synchronization

Solved!
Go to solution

I am using a USB-6353. I want to synchronize the start of an analog in and digital in task. They aren't running at the same speed, but they could be. What I have done is just created the two tasks and set them both to start with the same trigger. I then use another digital output, and wire it to the trigger terminal.

 

I'm not entirely sure that this is working. Both tasks are measure the distance a motor has moved in two different ways, but my analog data is always 4ms behind my digital data. I have a feeling this is because of latency in one of the sensors I am using, but I wanted to make sure that I wasn't missing anything as far as how I set up the tasks.

 

Is using a trigger the best way to synchronize the start of an analog and digital task?

0 Kudos
Message 1 of 7
(3,199 Views)

@Jo-Jo wrote:

...  Is using a trigger the best way to synchronize the start of an analog and digital task?


 

Well, that depends.  For tasks running off the same board it's generally sufficient because all the subsystems derive their sample clocks from a single master clock.  This is your situation at present.

 

In general though, when trying to sync tasks across different boards, you also need to sync the sample clocks (or the timebases used to derive them).  I personally tend to sync tasks via shared sample clocks more often than via start trigger.   Even if my tasks don't inherently need to sample at the same rate, it's often easier to configure tasks and correlate data when they do.

 

It'd help to post your code, though I think sensor latency sounds like a pretty viable suspect right now.  What kind of sensing/conditioning is happening with the analog input(s)?

 

 

-Kevin P

 

CAUTION! New LabVIEW adopters -- it's too late for me, but you *can* save yourself. The new subscription policy for LabVIEW puts NI's hand in your wallet for the rest of your working life. Are you sure you're *that* dedicated to LabVIEW? (Summary of my reasons in this post, part of a voluminous thread of mostly complaints starting here).
0 Kudos
Message 2 of 7
(3,162 Views)

Here is my task setup. After this I start both input tasks, and set the trigger high.

 

image.png

0 Kudos
Message 3 of 7
(3,155 Views)
Solution
Accepted by topic author Jo-Jo

As long as you enforce the sequencing where DAQmx Start is called for both input tasks before you generate the rising edge trigger they're looking for, you should be ok.

 

Oh, waitaminute!   I'm pretty sure you should be using digital Port 1 for your self-generated trigger.  It's Port 1 line 6 that corresponds to PFI6, not Port 0 as shown in your screenshot.

 

As it stands, it isn't clear to me why your input tasks are seeing a trigger edge on PFI6 at all, unless there's some physical wiring that hasn't been mentioned.

 

 

-Kevin P

 

CAUTION! New LabVIEW adopters -- it's too late for me, but you *can* save yourself. The new subscription policy for LabVIEW puts NI's hand in your wallet for the rest of your working life. Are you sure you're *that* dedicated to LabVIEW? (Summary of my reasons in this post, part of a voluminous thread of mostly complaints starting here).
0 Kudos
Message 4 of 7
(3,152 Views)

Yes, I have that digital out wired to PFI6.

 

I didn't think I could use an output as a trigger.

 

Can I just write directly to PFI6, and skip the external wire?

0 Kudos
Message 5 of 7
(3,148 Views)

Yes, as long as you "trick" the task into thinking the internal clock it is referencing is actually the external pulse train that you are generating. Here's how: http://digital.ni.com/public.nsf/allkb/63AE9149A2AEF85A86256F2B005D0E7D

 

Angela L. 

National Instruments

0 Kudos
Message 6 of 7
(3,144 Views)

@Jo-Jo wrote:

Can I just write directly to PFI6, and skip the external wire?


Yes.  You'll just need to write to whichever DIO pin maps to PFI6.  On many boards it will be Port 1, Line 6.  Because of the way different boards can have different power-up states or whatever, I would typically run the DIO task first to set PFI6 to low state, then start the tasks looking for a PFI6 trigger, then go back to the DIO task and write a high and low in quick succession for the trigger pulse.

 

 

-Kevin P

 

CAUTION! New LabVIEW adopters -- it's too late for me, but you *can* save yourself. The new subscription policy for LabVIEW puts NI's hand in your wallet for the rest of your working life. Are you sure you're *that* dedicated to LabVIEW? (Summary of my reasons in this post, part of a voluminous thread of mostly complaints starting here).
0 Kudos
Message 7 of 7
(3,097 Views)