LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How can I make a control inside a loop in a subVI change value when the calling VI's control changes?

Hi.

 

I think this is a pretty basic LV question, but I have not been able to find a good solution.

 

I am attaching VIs that show the problem I am having, but obviously, the real application is a lot complicated, which forces me to try to do it this way.

 

The issue is: I have a subVI with a Boolean control inside a loop.  When the control is true I want some action to take place.  When the subVI is run on its own, it works fine, acting properly when I set the boolean control to true via the LV FPGA interface from the host.  However, when I use it as a subVI, in which the top-level VI calls several instances of the subVI, I have the Boolean controls in the top level VI.  What is happening is that the false Boolean value with which the top-level VI starts is passed into the subVIs, and not updated, even though the control is inside the loop.

 

Can any one suggest a good solution?

 

Thanks,

 

AlejandroZ

Download All
0 Kudos
Message 1 of 8
(4,765 Views)

Hi,

replace the code of the calling vi and will works fine.

 

control subvi.png

0 Kudos
Message 2 of 8
(4,756 Views)

Hi AlejandroZ,

Fundamentally, you need to understand the dataflow model of labview.  A Subvi cannot run until all of its inputs have received data, and the subvi will not output any data until it has completed.  Because your subVI is running in a continuous loop it will never exit.  What you are really dealing with here is a parallel process. Brunos' method is one way of controlling your subVI which will work, but take a step back from just trying to read the control.  What you need is a communication method which will work between parallel loops, not only that but the loops are not on the same diagram.  Steer clear of global variables, they can be very troublesome.  You say many instances of the subVI are called.  Have a look at queues and notifiers.  They can be named and then accessed by that name from your main and sub vi's.  Just append a number to the name if you launch multiple subVI's.

Take a look at this:

 http://forums.ni.com/t5/LabVIEW/Micro-Nuggets-Post-em-if-you-got-em/td-p/1276066/page/3.  Broken Arrow has done a fine example.

Good Luck,

Michael

0 Kudos
Message 3 of 8
(4,743 Views)

Hi.

 

Thanks for your responses.  I am familiar with the dataflow programming paradigm.  It is just that sometimes it seems frustrating to see how LV FPGA goes to great lengths to enforce dataflow behavior in an FPGA, which has a different execution paradigm.  This creates problems like the one I am facing now, where it is very hard to replicate the behavior you have successfully tested on a single cRIO slot to several slots.  One solution is to simply copy the subVIs diagram several times on the main VI (I have actually tried that and get the results I want).  I posted the question to see if I would get a more elegant solution, such as using subVIs for identical code.

 

I am not sure if queues and notifiers can be used in LV FPGA.  Do you know?

 

Thanks,

 

Alejandro

0 Kudos
Message 4 of 8
(4,731 Views)
In this example, it's really silly to have a loop in the subVI let alone one you are trying to pass data to and one you can't stop.
0 Kudos
Message 5 of 8
(4,730 Views)

My associates do all of the FPGA work but an Action Engine should work if it gets updated in the top level VI and read in the sub-VIs.

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 6 of 8
(4,692 Views)

Hi.

 

I know the example I posted might seem silly, but it was just to illustrate the problem I am having.  In reality this is the application:

 

I have some LV FPGA code which uses a few FPGA IO to implement a serial link to communicate with a device.  Most of the time we are getting data from the device, so the serial link is used to send a read command, read in the data and put it into a FIFO.  However, I also wanted the VI to support sending data to the device, so I added an array control to put the data you want to send, and a boolean control to tell it you want to send it.

 

Since sending and receiving data are done using the same FPGA IO, they cannot be independent operations, because they would garble each other. Therefore, in the subVI I have a loop in which I first read data if there is any to read, then check the boolean write control to see if there is data to write.

 

As I mentioned, this works perfectly for talking to a single device.  However, we run into the issue of this topic when trying to replicate this for several devices.

 

One easy solution is to not have the loop in the subVI, and have it in the calling VI (I am favoring this simple solution right now).  The only reason why I have not done this yet, is that the subVI has more than one loop, so I am going to have to create several subVIs.  I just posted to see if there was an even simpler solution...

 

There have been some other possibly good solutions proposed here, though I am not sure if they work in LV FPGA.

 

Thanks for all your responses.

 

AlejandroZ

0 Kudos
Message 7 of 8
(4,680 Views)

HI, I am sorry you are having a hard time here, I did not read your post properly, you are right, queues, notifiers and vi server will not work on FPGA.  Now I think I understand the problem.  You are trying to send commands to the FPGA via front pannel communication.  This works fine to the top level but it is not available for controls and indicators in a sub VI.  I think you will need to use an action engine or FGV to transfer the data from your main fpga vi to the sub vi's. You will write to the controls on the fpga main vi from your RT host with read/write property nodes.

I hope this helps,

Michael.

0 Kudos
Message 8 of 8
(4,648 Views)