From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Running multiple subVIs in the same loop

Hi,

 

I have a VI which I am running on a cRIO 9074. This VI contains a number of subVIs.

 

To be exact, I have 6 classes of subVIs and am using approx two instances of each class.

 

Each class has atleast one other subVI that works as a RS flipflop. Each class has been configured as a reentrant VI(do I need to do this as I am not using the faceplates of any of the classed).

 

None of the subVIs pass any data to each other.

 

I am using all these subVIs in the same 'While' loop(I hope this is correct!)

 

My problem is this:

 

Earlier, when I was running this VI, the subVIs operated ok, including the RS flipflop part.

Now, when I run the VI, the RS flipflop section of the subVI doesnt work, in other words, the output of the RS flipflop is not latching.

 

Between 'Earlier' and 'Now', nothing has changed!

For me, if the flipflops do not work, the project wont work!

I need to know what I've missed.

Regards..

 

 

0 Kudos
Message 1 of 6
(2,877 Views)

Hi EventTrig...,

can you show how you create the RS flipflop and how it is implemented in your main loop?

 

Mike

0 Kudos
Message 2 of 6
(2,873 Views)

I got this VI from this forum or somewhere from the NI website! I started using it coz it saved me the time of creating a working flipflop.

 

I am using this VI as a subVI in my subVIs.

 

These subVIs are present in my main loop.

 

 

PS: Company policy doesnt allow me to upload any project VIs or images (company IP)!

Message Edited by EventTrigger on 06-16-2009 07:36 AM
0 Kudos
Message 3 of 6
(2,863 Views)

I did some more tests on my VI.

 

Instead of the downloaded flipflop subVI, I used the SR flipflop available in the LV RT module.

 

Again...I got the same result.

 

I tried running only one instance of a subVI in a separate loop in a separate VI, but the I am getting the same results.

 

I forgot to mention in my last post, I am using the LabVIEW 8.6.1

 

Regards....

0 Kudos
Message 4 of 6
(2,834 Views)

Hello EventTrig,

 

I have a good guess as to what is happening in your code. The RS flip flop VI that you uploaded uses a technique called a functional global variable to store data. Specifically, a shift register is present in the RS flip flop subVI that is uninitialized.

 

This means that when the RS flip flop VI is executed, it will retain memory of the last "Q" value (from the last call of the subVI). The memory is a desirable trait for this VI, as its purpose is to retain values. 

 

To make use of this memory, you need to make sure that you are calling the same subVI instance in memory each time you use a given RS flip flop in your code. When you mark the subVI as reentrant, then subsequent calls to the subVI will use a new memory space and therefore not be able to access the state from previoius calls. If you mark the subVI as non-reentrant it should work, but if you are using it in multiple places then you will need to remember that you are dealing with the same flip flop.

 

A good solution (as long as you are not using too many flip flops) would be to copy the subVI on disk as "flipflop1.vi, flipflop2.vi, etc". This way, you can use multiple flip flops in your code as long as they are not marked as reentrant.

 

Regards,

 

Casey Weltzin | LabVIEW Real-Time Product Manager | National Instruments

 

 

Message 5 of 6
(2,815 Views)

Hi,

 

I replaced all the flipflops in my subVIs with the RT module flipflops.

 

This seems to have solved the problem as of now!

 

Thanks and Regards...

0 Kudos
Message 6 of 6
(2,796 Views)