06-15-2017 10:37 PM
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?
Solved! Go to Solution.
06-16-2017 08:29 AM
@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
06-16-2017 12:43 PM
Here is my task setup. After this I start both input tasks, and set the trigger high.
06-16-2017 02:30 PM
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
06-16-2017 03:01 PM
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?
06-16-2017 03:44 PM
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
06-19-2017 08:57 AM
@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