LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

synchronize DAQ board and serial port sampling at high speeds (~2 msec)?

BASIC PROBLEM:
I need to scan all the channels of my DAQ board at least every 4 msec (but ideally as fast as 1 msec), and in the same time period check the serial port for a byte and if one is encountered, read it.

HARDWARE/SOFTWARE:
I'm using a PCI-6033e board in a Mac G4-400, with OS 9.1. I am using LabVIEW 6.0.2

ISSUES ENCOUNTERED:
Originally I put all the necessary code into one while loop, but iterations frequently went over the acceptable 4 msec time limit.

So, then I tried to achieve this using parallel loops using the "Wait" technique, with one loop handling the DAQ board and the other checking the serial port. This worked pretty well. However, every few sec
onds it would take extra time (anywhere from 1-80 msec), making this solution unacceptable. Presumably that's due to the cooperative-multitasking nature of the Mac OS. But until LabVIEW is released for OS-X, that's what I'm stuck with.

MY QUESTION:
Is there a way to "force" LabVIEW to perform certain operations at certain times? In the bad old days I achieved this using an interrupt to trigger the sampling.

Can anyone think of a way to ensure that these two devices are both sampled within this relatively short period?

Thanks,
Zach Crittendon
0 Kudos
Message 1 of 4
(3,166 Views)
Zach,

Unfortunately, there is not an easy solution to your problem. I looked at the specs for your DAQ board, and it should be able to sample at a fast enough rate for your specs, so I imagine the serial communication is slowing you down. By the nature of serial, you will be unable to query the serial port while another query is taking place, so the best way to keep your times acceptable is use a small timeout value for your serial communication. This can be set in LabVIEW with a Serial Port Config. If you are still looking for ways to synchronize your DAQ and serial reads, I would suggest looking over our Developer Zone section on LabVIEW synchronization. This can be found at zone.ni.com by following the links:

RESOURCE LIBRARY >> MEASUREMENT AND AUTOMATION SOFTW
ARE >> LABVIEW >> ADVANCED PROGRAMMING TECHNIQUES >> SYNCHRONIZATION

Ryan Tamblin
Applications Engineer
National Instruments
0 Kudos
Message 2 of 4
(3,166 Views)
Ryan,
I've started studying the use of the Notification and Semaphore VIs. From what you know, is this an area for these, especially the Semaphores, which seem to allow individual access to a single device, yet minimize waiting time?
Just curious, Doug
0 Kudos
Message 3 of 4
(3,166 Views)
Zach,
I've not used LabVIEW on a Mac, but from your description, it sounds like you are coupling two types of acquisitions. Is this application similar to real time control, except it is not controlling an external line. Is there a compelling reason to couple the DAQ and serial acquistions?

One solution would be to consider LabVIEW RT, which should handle a 1 ms or a 4 ms loop. However, I don't know if it will handle the serial I/O.

If you can decouple the two types of acquisition, you might look at the DAQ examples for buffered I/O. You can setup the DAQ driver to acquire at 1000 scans per second. The hard part would be to determine when a serial byte arrived relative to that DAQ data array.

Good luck,
Kenneth Klimkowski
0 Kudos
Message 4 of 4
(3,166 Views)