Example Code

Average Values in a FIFO Buffer Using Array Functions

Products and Environment

This section reflects the products and operating system used to create the example.

To download NI software, including the products shown below, visit ni.com/downloads.

    Software

  • LabVIEW

Code and Documents

Attachment

Overview

This VI returns the current average of all values in a fixed-size FIFO buffer using array functions.


Description

This VI returns the current average of all values in a fixed-size FIFO buffer using array functions.


Requirements

LabVIEW 2012 (or compatible)


Steps to Implement or Execute

Run this VI and watch as the 10 most recent values from a random number generator are shifted through a fixed-size FIFO, and an average of all values in the buffer is returned during each iteration.

 


Additional Information or References:

 

Average Values in a FIFO Buffer Using Array Functions FP.png

 

Average Values in a FIFO Buffer Using Array Functions sn.png


 

**This document has been updated to mee the current required format for the NI Code Exchange.**

 

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.

Comments
msensiperOO
Member
Member
on

Works great as moving average. I'm new to LV and this made more sense than what I found looking for "moving average".

carlos_camargo
Member
Member
on

This is a good start for a moving average.

There's no need to keep checking the array size as it doesn't change.

The first 9 values will calculate average using zeros for some of the elements.