01-26-2011 04:18 AM
hi everyone
Data from device will store in STS series server ( which has 16 com ports).
But I actually need to use 7 com ports from STS series server. I need to read those data from 7 com ports and save into a file.
Each com port has different function ( such as data reading or display).
My questions is,
1) Can i use different while loop for each com ports (if each com port have different channels)?.
2) If i use different while loops for each com ports, will there be any problems ( such as data overlaping or stacking)?
3) Using different while loops can consider as Parallel processing? (if No, pls explain)
the most important is
4) Should I use one main while loop for all 7 com ports?
Regards,
Solved! Go to Solution.
01-26-2011 04:42 AM - edited 01-26-2011 04:48 AM
You can run all ports in parallell, and as long as you do not create other dependancies between the loops, interference will normally not be an issue. We do this all the time (32 ports ++), there might be lots of data coming in on one port, or a slow response from a slave on another port...and you do not want the other ports to get affected by it.
Using multiple ports by having multiple loops is very inflexible though (you'll need to recode if the number of ports changes). It is better to dynamically create a "port handler" VI for each port (open a reference to a reentrant VI, a VIT, or create a copy of a VI on demand on open a reference to that - and then run it with the run method with the wait input set to false...) and use queues to get data in and out of each port handler/port.
01-26-2011 07:42 AM
@Mads wrote:
You can run all ports in parallell, and as long as you do not create other dependancies between the loops, interference will normally not be an issue. We do this all the time (32 ports ++), there might be lots of data coming in on one port, or a slow response from a slave on another port...and you do not want the other ports to get affected by it.
Using multiple ports by having multiple loops is very inflexible though (you'll need to recode if the number of ports changes). It is better to dynamically create a "port handler" VI for each port (open a reference to a reentrant VI, a VIT, or create a copy of a VI on demand on open a reference to that - and then run it with the run method with the wait input set to false...) and use queues to get data in and out of each port handler/port.
Agreed!
"Divide and conquer."
Ben
01-26-2011 09:22 AM
@Mads wrote:
You can run all ports in parallell, and as long as you do not create other dependancies between the loops, interference will normally not be an issue. We do this all the time (32 ports ++), there might be lots of data coming in on one port, or a slow response from a slave on another port...and you do not want the other ports to get affected by it.
Using multiple ports by having multiple loops is very inflexible though (you'll need to recode if the number of ports changes). It is better to dynamically create a "port handler" VI for each port (open a reference to a reentrant VI, a VIT, or create a copy of a VI on demand on open a reference to that - and then run it with the run method with the wait input set to false...) and use queues to get data in and out of each port handler/port.
This is very good advice. You did mention that you would have different processing for each port. One way to handle this using a generic method for processing the data would be to use LVOOP for your processing task within the receive (port handler) task. Create a dynamically dispatched LVOOP class to handle the data processing. The children classes would hanlde the specific processing. When you spawn the port handler pass in the specific object for the type of processing you require.
01-26-2011 07:17 PM
HI Mads,
Thanks for reply.
Sorry but i would like to confirm with you again since i am beginner in LabVIEW.
What you mean is, even though it is inflexible ( better i create "port handler" VI ) using different loops for different com ports is OK?
In your reply, (We do this all the time (32 ports ++), there might be lots of data coming in on one port, or a slow response from a slave on another port...and you do not want the other ports to get affected by it.) means, if i use different loops for each ports, other ports would not be affected by each other.
01-27-2011 02:51 AM
Yes you can use one loop per port.
I would love to post an example of a port handler here that would help you do it in a more flexible way, but right now I do not have the time to prepare an open source version, perhaps later (or perhaps someone else here will throw one together).
01-27-2011 09:34 AM
Take a look at the examples for dynamically calling VIs. Yuo can find them in the LabVIEW examples here: "Programmatically Controlling VIs->Dynamically Loading and Calling VIs". THese should give you a good idea how you can do this in a more flexible manner. Hard coded individual loops will work but it is not very flexible. If you do use individual loops make sure you use a subVI for the internals for ANY code that will be the same in all of the loops. That way when you need to make a change you only need to do it once. As suggested above make the VI reentrant.
01-27-2011 01:20 PM
2c from here...
If you are beginner in LV
Make sure you learn the Queue function intimately. It is by far the most powerful messaging function in LabVIEW
and its rock solid stable.
01-27-2011 02:34 PM
@AKA_TG wrote:
2c from here...
If you are beginner in LV
Make sure you learn the Queue function intimately. It is by far the most powerful messaging function in LabVIEW
and its rock solid stable.
Ditto that!
I would have to go back to LV 6.1 to even come up with a bug that affected the queue and even then it was not a bug in the queue but a bug in LV that killed the Q.
If I was NI... I would take the person that developed the queue (the polymorphic versions) and put that person of something really impresive like LVOOP.
They did. He goes by the user name Aristos Queue.
Ben