LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

reading cFP channel

Hi,
I have a main VI that reads, with a while loop, the value of Analog Input channel on FieldPoint AI module. In the same time this VI calls a subVI by reference, see Document ID: 3J3EGJL2.
I need the value of the same Analog Input channel in the main VI and in the subVI. There are two options how to do it:
1. Using shared variable and to read the Anlog channel only in the main VI, usind FieldPoint I/O point .
2. Read the same channel both in the main VI and in the subVI.
What is the best way to do it in meaning of computer resource (Time and memory)? since the main VI and the SubVI are ranning in parallel when I am using the second option I got the same value.
Thanks
Aviram
0 Kudos
Message 1 of 4
(2,889 Views)
Hi Aviram -

If you want to read the same channel in both the Main VI and the SubVI, I would recommend using either a Global Variable or a Shared Variable.  The easiest way to read the same data on multiple VIs if you are using LabVIEW 8.x is the shared variable.

Using the LabVIEW Shared Variable - http://zone.ni.com/devzone/cda/tut/p/id/4679

What are you trying to accomplish with your application?  You might want to look at taking another approach with your design architecture.  The Producer/Consumer design pattern is one option that will allow you to enhanced data sharing between multiple loops running at different rates.

Application Design Patterns: Producer/Consumer - http://zone.ni.com/devzone/cda/tut/p/id/3023

LabVIEW Zone:  Application Design Patterns - http://zone.ni.com/devzone/cda/tut/p/id/5218


Let me know if you have any questions.

Mark W.
Application Engineer


0 Kudos
Message 2 of 4
(2,876 Views)
Thanks Mark,
My application is being used to control (using cFP modules) a fueling system. In the system I have two vessels and I read the fuel level in each vessel using an Analog Channel.
The main VI have two while loops one which reads the inputs, including the analog channels of the fuel level sensors, and one with an Event Structure.
The application can carry out several processes - draining the unit and fueling the unit with new fuel. I build the application with several subVIs (being called using reference) that perform these processes.
In the subVIs I nead to know the vessels fuel level so I used the FieldPoint I/O point to read the analog channels of the fuel level sensors. It was also possible to use shared variables to pass this information between the VIs because the first loop in the main VI is already sample these analog inputs. 
my question was what is the most "elegant" way to do it.
thanks
Aviram
0 Kudos
Message 3 of 4
(2,866 Views)
Hello Aviram,
 
Since this is all on the same system, I believe that a shared variable may be a little overkill.  The easiest and most elegant way to do this would be in two loops - similar to the producer/consumer architecture.  The top loop would get the information from the FieldPoint and then pass it to the bottom loop with a wire.  There really isn't a need to use a variable at all.  That bottom loop could then have either a case structure or event structure to call the different subVIs.
 
Be careful using variables when a wire could to the job - that is an easy way to get race conditions.
 
Good Luck!
 
Janell R. | applications engineer
0 Kudos
Message 4 of 4
(2,854 Views)