Acquiring data from NI Daq and serial port simultaneously

11 views (last 30 days)
Hello I am using NiDaq card and serial port for data acquisition. I want to Acquire data from NI Daq and serial port simultaneously. Please answer

Accepted Answer

Walter Roberson
Walter Roberson on 2 Oct 2011
The NiDaq card probably has some buffering on board, so if you were to start the NiDaq data collection and then were to do some data collection from the serial card, and then were to receive the buffered data from the NiDaq card, then the data will have been sampled simultaneously.
Acquiring the data from the two devices simultaneously is much more difficult, and is not possible with the hardware found on most systems. Acquiring data from the serial port normally requires one processor interrupt per byte, and you cannot have two different processor interrupts happening simultaneously. The work around here is to use a high speed serial card that has its own local interrupts and buffers the serial data and DMA's it to main memory: in theory multiple DMA's can happen simultaneously (but users do not often have any control about which DMA''s are going on.) This approach presumes, of course, that the NiDaq card also has DMA, which I have not researched.
Now, acquiring data from two sources simultaneously has nothing to do with getting synchronized samples from the two source. You would have a hope of getting synchronized samples from two data acquisition cards (or channels) by using the sample trigger signal for both, but Alas, since serial ports are asynchronous beasts, getting synchronized information through one of them is near hopeless.
When I see a question like this, unless the author has been very specific, I tend to think that what the author really wants is for the two signals to be time-stamped so that the information from the two sources can be brought in to alignment. Many NiDaq cards are able to time-stamp the data they acquire with a fairly decent precision. Unfortunately, time-stamping serial port data is very approximate at best... unless you can convince the device generating the serial data to construct time-stamps and send them as part of the data, and the clocks on the NiDaq and the remote serial device need to be aligned.
My recommendation would be to avoid this kind of problem if possible. It is almost always better to use multiple channels on the data acquisition card (NiDaq) if you need synchronization.

More Answers (0)

Categories

Find more on Data Acquisition Toolbox Supported Hardware in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!