LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

creating a subvi with stored state

I would like to use the moving average vi example from ni as a subvi. Ideally, I would input the waveform, and the output would be the resultant waveform.When the vi stopped running, any internal storage of waveform data (if necessary) would be reset.

 

http://zone.ni.com/devzone/cda/epd/p/id/82 

 

However, in the example they use shift registers and a for loop which runs continuously. In my case, i would like one input to the vi to be equal to one point of the waveform - so no for loop, and thus no shift register. 

 

So, would the best way to put this in a subvi be to create local variables instead of using shift registers?And then make the vi reentrant?

 

Message 1 of 6
(3,508 Views)
Please view the attached VI. (Developed in LabVIEW 7.1)
0 Kudos
Message 2 of 6
(3,489 Views)

Hi Gordal,

 

Ravinder's example is a viable option. It can be wrapped up in an Action Engine so you can update in one place and read it in another.

 

Ravinder,

 

There is a "Max min" function on the comarison palette that accepts two values and returns ther largest or smallest (help simplify your logic).

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 3 of 6
(3,465 Views)
How does action engines cover the creation of multple instances of the moving average for different signals? It seems like its only useful to update one store of data, though i suppose each data instance could be hashed by an id number. Looking around, it seems theres also lvoop, maybe that would be more suitable?
Message Edited by Gordal on 05-11-2010 08:58 AM
0 Kudos
Message 4 of 6
(3,446 Views)

Gordal wrote:
How does action engines cover the creation of multple instances of the moving average for different signals? It seems like its only useful to update one store of data, though i suppose each data instance could be hashed by an id number. Looking around, it seems theres also lvoop, maybe that would be more suitable?
Message Edited by Gordal on 05-11-2010 08:58 AM

 

THe approach I suggested above can be adapted for multiple signals as well.

 

Yes you could use LVOOP but LVOOP by itself not a complete answer. You could create a Singlton for each channel and implement methods that update the average for each update.

 

Ben

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

Actually this sounds like a great excuse to use a feedback node.  Initialialization of a feedback node is simillar to initialization of a shift register except that the feedback node allows you the choice of when to initialliaze it (either every time the vi runs or globally when it is loaded into memory) 

 

An action engine (as Ben advised) using a feedback node that is set to be globally enabled can be a VERY powerful tool for this type of data manipulation where the current output is dependant on previous input(s).


"Should be" isn't "Is" -Jay
0 Kudos
Message 6 of 6
(3,416 Views)