LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

adquisition from serial ports

Hello everybody
 
I'm writing because I don't found how to solve fully my problem.
 
I have a three-channel seismic instrument  which can send both data and time reference to a computer using serial port.
I've created a VI which can acquire data from the three channels, plot and save them. However I have to do something a little different, a new VI to connect more than one instrument in order to do similar functions.
 
In general terms my requirements are the followings:
 
1. User will connect as many devices as he need and set up their parameters such as samples per second and connection port.
 
2. User will select the channels that will be save on disk.
 
3. When the acquisition starts the VI must be able to read data from all configured instruments at the same time.
 
4. After data is received the VI must be able to save only those channels that were previously selected and optionally plot them.
 
5. There must be a window which shows the program status for example if a device is disconnected, which channels are enable to        
    save data and if an error ocurrs.
 
I hope that with this brief explanation you can provide me some suggestions or examples to solve my problem.
 
best regards, dtp
 
0 Kudos
Message 1 of 11
(3,281 Views)
I think one possible way is to open and configure the serial ports in a loop and keep the VISA resource names in an array. You can also have an array of Bool values to identify data from which serial ports need to be saved and plotted.
Then when you start the acquisition, do the communication in a loop one port after another port and keep the datas in an array as well. By this, you will have the data of port of index 0 in data array index 0 and so on. By using the Bool array, you will know which data to be saved and plotted.
 
Hope this gives an idea (although may not be the best efficient way)...


Message Edited by Deepu on 04-30-2008 10:27 AM
0 Kudos
Message 2 of 11
(3,260 Views)
Hello Deepu
 
First of all, thank you for replying so quick.  Well, I have a doubt about a point in your answer.  You said that when I start the acquisition I should do the communication in a loop one port after another, but I think it means that my acquisition won't start at the same time for all ports. So my question is,  do you know a way in which I can start the acquisition simultaneously for all ports?. Otherwise If I didn't undertand you well, could you explain me the idea?
 
best regards, dtp
 
 
 
 
0 Kudos
Message 3 of 11
(3,227 Views)
My answer was based on the assumption that you are not sure how many ports will be open each time (not even what is the max allowed).
So in this case a possible way would be as I said keep reading all ports one by one adding the datas into an array as per the ports index. Anyway serial port data will not be lost even if you do not read it immediately (as long as there is no buffer over flow).
 
On the other hand, if you know that there will be a maximum of say 5 or 6 ports in a system, then you can create a read loop for each port and start acquisition. In this case, there will be so time sharing by ports. Only thing is you can't have more ports than the max loops defined.
 
Rgds,
Deepu.
 


Message Edited by Deepu on 05-02-2008 06:33 PM
0 Kudos
Message 4 of 11
(3,205 Views)

I'll have to read from the start (which I will do next), but:

Why do you want an acquisition loop for each port?  Think of it as an Event system.  The "event" is acquire data.  Therefor, you only need 1 loop to acquire the data. 

I would create a vi (sub-vi) which handles the serial communication.  Make the vi re-entrant. 

Before giving more advice, I would need to know the rate of acquisition because it would have an impact on the appropriate architecture.  That means I will now go read the original post.

be back soon 😉

RayR

0 Kudos
Message 5 of 11
(3,194 Views)
I will answer within your question:
 
First of all, you already have code that may help you implement your solution.  Do you have access to the source code?  If so, are the terminals available on the connector pane to communicate with the existing VI?  If not and you have the source code, wire that up.
 
 

dtp wrote:
 
1. User will connect as many devices as he need and set up their parameters such as samples per second and connection port.
That works to your advantage.  You can also use this to determine how many ports to use.  Draw a state chart on what events can take place and the different outcomes.  This will help you to design your solution.
 
2. User will select the channels that will be save on disk.
Put this in the state chart as well.  The event is save to disk and a parameter is which channel to save, and maybe the naming of the file.  This becomes a function (sub-VI) that you can call
 
3. When the acquisition starts the VI must be able to read data from all configured instruments at the same time.
This is why you need one (1) single solitary loop for your acquisition event.  The idea of Daemons comes to mind, but this will depend on how big / often / how long each acquisition is, and what is meant by simultaneous.
 
4. After data is received the VI must be able to save only those channels that were previously selected and optionally plot them.
Does it do this while it is acquiring more data? 
 
5. There must be a window which shows the program status for example if a device is disconnected, which channels are enable to     
    save data and if an error ocurrs.
Does it verify before doing acquisitions or during the acquisitions or at all times (constant monitoring)?
 


0 Kudos
Message 6 of 11
(3,193 Views)

Hello JoeLabVIEW:

 

Thanks for replying. I will give you more information so that you can provide me more suggestions.

 

The acquisition will be continuous from 1 day to 1 week, so how long the acquisition is, it depends on the period of time that the user needs. How often depends on the sample rate that the user needs for each three-channel device, it could be 50, 100 or 200 samples per second. And my idea of simultaneous is that my VI must be able to read data from all ports when the acquisition starts.

 

About saving and plotting data, it will be while my VI is acquiring more data. In my previous VI the data were read from my device and saved on files of 10, 20, 30 or 60 minutes of duration.

 

About the window that shows the program status, it will be necessary only during the acquisition.

 

Regards, dtp

0 Kudos
Message 7 of 11
(3,154 Views)
I will reply within your text..

dtp wrote:

 

The acquisition will be continuous from 1 day to 1 week, so how long the acquisition is, it depends on the period of time that the user needs.

 

Let's keep the architecture very simple... This will be your main loop.  A while loop would be more appropriate.  You can set the granularity to what you want, but 1 minute is probably sufficient.  So you would have a control that the operator enters the duration, ie 1 day to 7 days. You take a timestamp when the test starts and you add the duration to it.  That will be the end of test condition.  Not necessarily stop the loop.  You should have a seperate STOP button for that. 

How often depends on the sample rate that the user needs for each three-channel device, it could be 50, 100 or 200 samples per second.

You will need a control [cluster containing 3 numeric values?] that sets the sampling rate for each channel.  I suspect you may want to configure them individually.  If not, then a single control could do.  Since you want to perform other tasks while the system acquires data, then you could have a sub-vi that is re-entrant handle the acquisition.  Another approach is the use of Daemons (my preference) - similar concept, using timed loops.  I would use an Active Engine to buffer the data (I need to think about this because you may want to actually call something else to then write to file... and there are 3 buffers... which is why I did not say "Functional Global".  --- sorry.... I'm thinking out loud --- 

Actually, a producer / consumer architecture is probably more suited for this and you could use a queue to pass data to the consumer loop for handling.  It would have a state machine to appropriately handle the data (plot, store, etc).

 

Question:  would it be acquiring data continuously at 200 samples per second non-stop for 7 days?  If so, what type of PC will be running this?  Multicore? single core? And what Labview version is used for development?

Message Body: Message cannot exceed 10000 characters.

 

0 Kudos
Message 8 of 11
(3,129 Views)

(part 2)

 


 And my idea of simultaneous is that my VI must be able to read data from all ports when the acquisition starts.

 

That would be handled by calling the vi (sub-vi / daemon above).  Simply make sure they start at the same time.  Make sure the sub-vi has an error in on the connector pane.  It will make life easier.

 

About saving and plotting data, it will be while my VI is acquiring more data. In my previous VI the data were read from my device and saved on files of 10, 20, 30 or 60 minutes of duration.

Plotting the data is relatively easy.  If you need help, simply describe how you want to plot it and provide sample data.

Saving the file at different intervals.  Again, a control is needed to allow setting the interval time.  Do you really want to wait 60 minutes before saving data?  Maybe save every minute and change filename after the duration.  Explain your thoughts on how file saving occurs.  Will it be one single huge file or several timed-interval files?  

 

About the window that shows the program status, it will be necessary only during the acquisition.

 

If you use a properly architectured producer / consumer architecture, you could also monitor events such as changes to the test environment and display the status.  That would mean that the producer loop would contain an Event Structure that handles operator interface events (pushing a button, entering value, etc.  And also monitor the status of the software as it runs.  It would also start appropriate Daemons (or sub-vi) and stop them for the duration of the acquisition.  It would also monitor the timing to trigger the consumer loop to handle the various events that would be passed to it at regular intervals (plot data, store file, update satus display). 

 

There is a template of what I describe if you select New VI from Template and you look for an event structure (with data?).  Unfortunately, I do not have LV installed on this PC.  Also do a search within this forum for Event Structures.  and Action Engines... and Daemons.

 


Hope the above helps you.
 
RayR
0 Kudos
Message 9 of 11
(3,128 Views)

Hi JoeLabView,

 

Excuse me for not replying quickly. But now I will clarify some points:

 

Well, the data will usually be acquired  continuously at 100 sps from 1 to 7 days non-stop for each three-channel device but there must be an option to stop the acquisition whenever. My PC is a pentium III with 512MB RAM and I'm programming in Labview 8.0. However the final user has a laptop with better features.

 

About how to save the data, in the previous version of my program, first the three-physical channels of a device are configurated in a dialog box specifying the duration of the files in minutes(1-60) and this configuration is saved on a configuration file. Next, the program is run  and the data are saved on successive files with the configurated duration in a folder for each physical channel.

 

However in the new version, before running the program the user must configurate as many logic channels as he need one by one using a dialog box. Moreover each time that he configurate a logic channel, this configuration will be  saved on a different configuration file. After when he run the program, the received data of all logical channels must be saved on successive files wich will be in a folder for each logic channel.

 

Thank you for helping me!

 

Best regards, dtp

0 Kudos
Message 10 of 11
(3,070 Views)