05-10-2010
08:54 PM
- last edited on
10-12-2025
03:57 PM
by
Content Cleaner
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?
05-11-2010 02:09 AM
05-11-2010
07:42 AM
- last edited on
10-12-2025
03:57 PM
by
Content Cleaner
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
05-11-2010 08:56 AM - edited 05-11-2010 08:58 AM
05-11-2010 09:05 AM
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
05-11-2010 11:29 AM
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).