From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, 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: 

How to reset a subVi

Hi,

In my software I have a call of a subVi inside a case structure. What I need is that every time I call the subVi by changing to True the value of the control of the case structure the subVi starts from the beginning.

I need it because inside of that subVi I have a Simulate Signal Vi, and this simulated signal must start from the beginning every time I call the subVi.

Is there a simple way to do that?

 

Thank you

0 Kudos
Message 1 of 13
(5,028 Views)

A subVI typically starts from the beginning unless it contains some local state data, e.g. in an uninitialized shift register.

How are you calling the subVI? How long does the subVI run before returning to the calling program? Does the subVI contain a while loop? How many times is "simulate signal" called per call of the subVI? In the "simulate signal" express VI, how is the section "reset singal" configured? Do you have it set for "continuous generation"? Maybe "Reset" mode is what you want?

 

Can you show us some code that demonstrates the problem you are seeing? (Attach your VIs).

0 Kudos
Message 2 of 13
(5,018 Views)

Thanks for your answer.

 

Maybe my explanation of the software wasn't the best I could write.

My subVI is a "data processor" that generates a signal that is sent to the main VI. The subVI is called in a case structure in the main VI, so I can start and stop it whenever I want. What I need is that every time I stop and start that VI the signal (approximately a sine) starts from the beginnig. 

 

The subVi is in a case structure, the subvi starts to run when I change the control of the case structure to true. The subVI runs until I change the control to false.

There are no loops and no shift register in my VI. The "reset signal" is connected to a series of logical controls of the data processor.

 

I'll try if the reset mode is what I need.

 

Thank you

0 Kudos
Message 3 of 13
(5,011 Views)

danielepirovano wrote:

Maybe my explanation of the software wasn't the best I could write.


We are all graphical programmers and thus much more visually oriented. For us, a VI is typically much clearer to understand that reading paragraphs and paragraphs of complicated descriptions. You will typically get better help of you attach a simplified code example. 😉

Message 4 of 13
(4,993 Views)

Sorry but my VI is very big, it was difficult to post it here.

I found a workaround: when I push the startVI button I send a reset impulse to every signal generator in the VI; it seems to work.

 

Thank you for your help

0 Kudos
Message 5 of 13
(4,965 Views)

Hi all,

 

Sorry to revive/hijack this post, but the second post of this topic is very relevant to me.

 

Altenbach, I have an issue with the shift register of a while loop in a subVI. I want to clear the local data of this shift register each time after the main VI finishes its execution,  but am unable to initialize it by wiring a constant 0 (due to the way the data is stored). My current situation is that I have to close the entire main VI after each run just to clear this local data, which is very inefficient. I was hoping that resetting a subVI after it finishes its execution can somehow clear its local data, either by closing it after it runs, or after the end of the execution of the main VI.

 

The situation is as follows: The data should ideally be a 1D array of double integers, but it is extracted and stored as a string instead (Keysight's method of reading from its Vector Network Analyzer). The result is that the 1D array of double is stored as a 1 by 1 single element, with the individual values being separated by a tab. In an attempt to convert it to the desired 1D array state(which will then be build upon previous data in order to compile them), I have created a Sub-VI that contains a while loop with shift register in order to build up an array full of this data. For some reason, Initialization of this shift registers reverts back to the initial scenario, with all the values being separated by a tab into a single element of double again.

 

As the main VI would be too complicated to be evaluated ( I have to run a power supply, a guassmeter and a PNA-X Vector Network Analyzer on top of a sequential flow of commands), I will be only attaching the relevant subVIs (Keysight's drivers file can be downloaded from their website, but are not vital except for ).

 

Any advice is deeply appreciated! 

 

Best Regards,

Wai Cheung

 

 

0 Kudos
Message 6 of 13
(4,616 Views)

I don't understand what the VIs you have attach have to do with the problem you describe. Where is the VI that calls the subVI?

0 Kudos
Message 7 of 13
(4,604 Views)

Hi Altenbach,

 

The "main VI" in this case is called : Problem 1.vi

The "subVI" is called " Field Sweep Real Time XY Graph Version 6.vi"

 

" Field Sweep Real Time XY Graph Version 6.vi" has uninitialized shift registers which I want them to be emptied at the end of the execution of Problem 1, without having to add a numeric constant.

 

I am hoping that this local data can be somehow cleared by closing the subVI after it returns to the main VI.

0 Kudos
Message 8 of 13
(4,564 Views)

Why would you make the subVI frameless? Just so we cannot find it in the calling VI (it looked like a wire label!).

 

I don't understand the need for the subVI. Why don't you just add a shift regsiter to the outer FOR loop of the main VI.

 

Your main VI currently make very little sense. You are appending a cluster of two arrays to an empty array of such clusters. Over and over again. Basically the output will always be an array containing a single element, so the inner FOR loop wil only iterate once. If you would eliminate the built array and inner FOR loop, you'll probably get all you possibly need.

 

I cannot comment further, because I don't know the rest of the missing subVIs.

Why does the x-axis data even enter the FOR loop? Can't you merge that in once you have all the y data after the loop?

0 Kudos
Message 9 of 13
(4,550 Views)

@danielepirovano wrote:

 

The subVi is in a case structure, the subvi starts to run when I change the control of the case structure to true. The subVI runs until I change the control to false.

There are no loops and no shift register in my VI. The "reset signal" is connected to a series of logical controls of the data processor.

 


Reset the SubVI in the false case. Problem solved. 🙂

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 10 of 13
(4,397 Views)