I'm trying to synchronize two acquisitions channels on a NI USB-6251 DAQ: an analog input and a digital input.
I'm following this example: https://decibel.ni.com/content/docs/DOC-12185 which seems to work in almost every case (sometimes there is a single acquisition sample (0.1 ms) shift between the two channels).
To understand my mistake, I've a question about the point 3. in the block diagram of the example :
3. Call the Start VI to arm the two functions. Make sure the digital input task is armed before the analog input task. This will ensure both will start at the same time.
Why is it so important to arm the digital task before the analog one? Isn't it the order in which I call the tasks inside the loop that is important?
Thank you for your help,
The reason the digital input needs to be started before the analog one in this particular example is because the digital signal is set to be started off from the generated analog start trigger signal. If you would start the analog signal acquisition before the digital one, the digital acquisition would miss a period because it would not be start triggered in time. The order which you use inside the loop also matters, but not so much in this example, as the functions are being called in parallell rather than in series. If you would have a rather large loop or would wire the acquisition functions in series, the impact on the timing would be more significant
I hope this answers your question!
Application Engineer | National Instruments