LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I log data from multiple serial instruments at the same time?

I have 12 serial instruments connected to 12 seperate serial channels on a PXI chassis. I need to poll each instrument (at approx 18hz) which then returns 36 bytes of data that has to be logged to a file with a time stamp. I can get one or two instruments but anything more than that and I start running into problems.
 
I've started from scratch several times now. My current VI has 12 initialize serial port subVI's then 12 acquisition subVI's in a while loop. Is there a better or more efficicient way to acquire this data?

Message Edited by Skoorb on 08-17-2006 12:16 PM

0 Kudos
Message 1 of 13
(2,877 Views)
What problems exactly? The space of problems in general is a little too big.
0 Kudos
Message 2 of 13
(2,872 Views)
Actually, at this point I've just started over again. I was having problems with the machine slowing down over time. The VI would run just fine initially but the longer it ran the more data got lost.
0 Kudos
Message 3 of 13
(2,861 Views)
That is usually a symptom of a memory leak or a growing data structure (array or string). Do you have an array or string which increases in size with every iteration of your loop? Are you creating references to some objects and never disposing of them? There are some documents that come with LV or are on the NI web site which discuss memory management issues.

Lynn
0 Kudos
Message 4 of 13
(2,853 Views)
I've been doing some reading and I think I was writing to the file but not getting rid of the old data. Also, I was writing to the file after every acquisition of data, meaning LOTS of file I/O going on.
 
I'm trying to figure out how to write larger quantities of data to file less frequently. So far, no success.
 
0 Kudos
Message 5 of 13
(2,851 Views)
Often it is useful to separate the acquisition of the data from the processing and saving of the data. Parallel loops with the data transferred via queues or functional globals are a good way to do this. Look at the Producer/Consumer examples which ship with LV.

Lynn
0 Kudos
Message 6 of 13
(2,845 Views)
Here is a simple producer-consumer example.
- tbob

Inventor of the WORM Global
0 Kudos
Message 7 of 13
(2,842 Views)
Interesting, thanks for teh example Bob. I've never played with Ques before.
 
So if I understand correctly, the que is like a FIFO? The upper loop collects data and plugs it into the que, the lower loop (in my case) takes the data and periodically writes it to a data file and simultaneoulsy clears the que for the new data?
 
 
0 Kudos
Message 8 of 13
(2,818 Views)
That is basically right, like a FIFO.  But I wouldn't say the lower loop clears the queue.  It just takes one element off the queue.  You could have a situation where the top loop stuffs the queue faster than the bottom loop can process the data.  Then the queue will build up until you run out of memory.  Also with queues, you can stuff data into the queue at either end.  There is a function that allows you to push the data at the other end of the queue so that the next de-queue will get the latest data instead of what was there before.
- tbob

Inventor of the WORM Global
0 Kudos
Message 9 of 13
(2,803 Views)

Thanks for the explanation.

I have a problem right now in accessing more than one instrument. IfI attempt to acquir data from more than one serial port the data rate drops DRAMMATICALLY.

 

As soon as I can transfer a screen shot from the development system I'll post a pic of the VI's I'm using.

0 Kudos
Message 10 of 13
(2,799 Views)