Averaging data of n-samples continuously

Given a specific sample size and continuous data, how do you find the average of each "block of n-samples" as the data streams in. In Short how do you make a VI that emulates a Hardward Mean sum AD converter.

If it were averaging a window of n samples continously this would be a "running average" and you could use the VIs from this thread:
http://exchange.ni.com/servlet/ProcessRequest?RHIVEID=101&RPAGEID=135&HOID=5065000000080000003A0B0000&UCATEGORY_0=_49_%24_6_&UCATEGORY_S=0&USEARCHCONTEXT_QUESTION_0=running+average&USEARCHCONTEXT_QUESTION_S=0
If you only want to produce one average per n samples (reducing the number of samples) you can use the same VIs, just "sample" the given average every n incoming sample.
If you have the signal sampled up-front there would be more effective way to generate the averaged signal than uisng the VIs referred to though...
MTO

Similar Messages

  • Clear array and take average of values in array continuously

    I have a continuous signal that I am acquiring with hardware (sampling at 1000Hz).  I want to be able to insert the data into a 1D array for 5 seconds, and then take the average of these 5000 samples.  So basically, every 5 seconds I need to take the average of a 1D array and create a new array for the next 5000 samples.

    There is no reason to accumulate the data into an array if all you need is the average.
    Simply add the values into a shift register. Every 5000 points devide the sum by 5000, output the average, and zero the shift register for the next series of data..
    LabVIEW Champion . Do more with less code and in less time .

  • Record data at one sample rate and calculate velocity

    I need to record position data at a sample rate of 10 hz but I would like to calculate velocity every half a second.  What is the best way to do this so the velocity display does not jump?  I want to capture quick responses but I would also like to calculate the velocity over a longer period of time like 1 minute. 

    I am trying to calculate vertical speed based on pressure altitude data.  I am using serial communication to measure pressure at 10 Hz.  I am using Labview 8.2 for all of the calculations and measurements. 
    I am looking for some way to average the data over some time interval that I have yet to determine.  I want to be able to see any major pressure changes whithin about .5 seconds but I also need to see trends over a longer time period say 2 to 10 seconds. 
    I have thought about using an array and then averaging the array or implimenting a rolling digital filter. 

  • Does Signal express save averaged data to LVM / Ascii / UFF file or all the individual runs?

    Hello,
            I am acquiring impact
    datausing NI sound and vibration and NI cRIO 9233. I am averaging the
    data over 10 hits and saving it to Ascii, LVM files. When I open the
    file in excel I see 12500 readings. The frequency resolution is 1.25Hz
    and range is 0 - 1562.5Hz that gives me 1250 divisions, which means its
    storing each of them separately. Why is it doing so and not storing the
    averaged data?
           Also could I possibly set a condition where
    the data is accepted by the software only if the hit is good and I want
    to accept it. May be like a condition where I could accept that data by
    clicking a push button?
    Attached is my acquisition template and also
    the data in ascii format. I collected data for 10 averages but the set
    is showing data for 11 averages or sets of 1250 each. Could someone
    please help me out.
     I need to get this going as soon as possible as I want to transfer data from Sound and Vibration assistant to another software.
    Thank you.
    Message Edited by StuMtu on 10-30-2008 11:39 AM
    Attachments:
    FRFdata_1.xls ‏1445 KB
    filtereddata_1.xls ‏3062 KB
    ImTe-10-29_run1_1 (DAQmx).seproj ‏787 KB

    Hey Stu,
    You had asked this question a while back. Did you have any problems implementing the solution I provided?  If so, please post in the original forum and we can take it from there.  Thanks!
    -John Sullivan
    Analog Engineer

  • Acquire, display, and write data at 50 samples per second

    I have a vi running on a PXI which samples data using two 4220's (all 4 channels) and one 6031 (only 6channels).  I am acquiring data at 100 samples per second, but only need to write the data out at 50 samples per second.  The data needs to be displayed at a minimum of 10samples per second.  The problem is that the VI can not get 50samples per second writen to the file, it writes about 20 to 30samples per second.
    I dont know if the issue is displaying the data which is holding up the writing at 50samples per second or if it is something else in the VI.  I have moved the writing of the data to the outside of the while loop, but this did not help enough to reach 50samples/sec.
    Is it better to change the waveform data types to dynamic waveforms?  Would this increase speed of operations?
    Galen
    Attachments:
    ATM_FrictionTests_v1.2.vi ‏375 KB

    Galen,
    Looking at your vi, I would recommend writing to your file in a different way.  The function you are using is actually opening, writing, and then closing the file every time you call it.  This greatly increases the amount of resources being used.  Take a look at the Cont Acq to Spreadsheet File.vi example and note that the file is only being opened and closed once.  The data is being written to the file during execution of the program, and then closed when the app is done running.  The example is done in traditional DAQ but you should be able to do something similar with DAQmx.  Try this and let me know if it helps. 
    Regards,
    LA

  • I have to average data of 1min and then log into text file

    For my application i have to average data of 1min and then log into text file. please guide me on this . To transfer the data i am using notifier.
    Prashant Soni
    LabVIEW Engineer

    hi prashant,
      Check this attachment..I just implemented my idea    in this one.
    Thanks and regards,
    srikrishnaNF
    Attachments:
    Example_VI_BD.png ‏12 KB

  • Average date

    Hello,
    my application finds average date from given dates. It does it in following way:
    1. converts all Date objects to long (+((Date)value).getTime()+)
    2. compute average value
    3. create Date object from the value computed in 2.
    4. format above Date object as String
    The problem is, that the result depends on the time zone on the computer the application is running. Eg. on one computer I get +27/02/1992 17:52:56+ and on the another +27/02/1992 17:18:49+ for the same data set. The difference is caused by the fact, that one computer has different winter and summer time, an the another computer doesn't change time during the year.
    My question is:
    Is this behavior correct? Is there a way to normalize dates to get the same results always?
    I'm looking for your opinions.
    Agata

    agad wrote:
    Sure: just use a fixed, defined timezone for all your calculations (GMT would be the obvious candidate, but maybe your local one is a possible choice as well).It would be possible if I got String (not Date) as an input. But I don't have an original input (I can't change the code, that is parsing String to Date, I have to work with Date objects), so I don't know if the format string contained the time zone definition or not.If you had the same set of Date objects on both machines, then you would have the same set of long values, the same average, and the same answer on both machines.
    But you don't.
    Therefore you don't have the same set of Date objects on both machines. This suggests that the process of creating the Date objects is dependent on the default time zone on the machine. That's the part you should fix, if you want the answers to be consistent.
    If you can't fix it, then it isn't your problem. It's the problem of whoever controls the code you aren't allowed to fix.

  • How I average data with 78,74,73 and 55 points respectively and end up with an array of 78 points for the average?

    Hi
    As the questions states, how do I average data with 78,74,73 and 55 points respectively and obtain an array of 78 points? 
    When I use the plus vi, Labview somehow produces an array of 55 points when I do the average (see attached vi).
    I have been unlucky in trying to get good results.
    Can anyone help?
    Thank you.
    Attachments:
    average4.vi ‏40 KB

    The add function is polymorphic. It accepts arrays as well as numerics, but you need to understand one thing about array operations in LV. Operations performed on arrays of different sizes will always (I think) work based on the smallest array. For example, if you auto index 2 arrays of different sizes into a for loop, the number of times the loop will run will be the size of the small array. The same is true here - when you wire 2 arrays of different sizes to the add function, only the first N elements of the larger array get processed. The rest are dumped. That's why you get 55 elements.
    Attached is a modification of your VI which shows 2 things:
    The bottom part is your algorithm, only cleaned up. Note how much easier it would be to read now. You should always write clean code. Also, note that I have changed the representation on some of the data from DBL to I32. This is because this is the representation the array function work with and your code had the DBLs coerced for no reason.
    The top part is a different algorithm which should do what you want. Note that like Mike said, the arrays with smaller sizes will have 0s appended at the end, so if you want to avoid that, you will have to modify the last part, where the averaging is done and only divide those columns which are long enough.
    To learn more about LabVIEW, I suggest you try searching this site and google for LabVIEW tutorials. Here and here are a couple you can start with. You can also contact your local NI office and join one of their courses.
    In addition, I suggest you read the LabVIEW style guide and the LabVIEW user manual (Help>>Search the LabVIEW Bookshelf).
    Try to take over the world!
    Attachments:
    average4MOD.vi ‏63 KB

  • Why are your Data Plans SO SCREWED UP? You are Unfairly making the average data user Subsidize the Big Data Users. This kind of thing is why I left AT

    Why are your Data Plans SO SCREWED UP? You are Unfairly making the average data user Subsidize the Big Data Users. This kind of thing is why I left AT&T and came to Verizon a Decade ago. Their plans sound better now, maybe I should go back.

    I currently have 5 phones/lines. 2 Droid MAXX phones, a Samsung Galaxy S5 phone and 2 basic phones (4+ year old Motorola & Samsung). The cost for each line rose considerably and usage fees more than doubled on the 2 basic phones when I upgraded the 3 smartphones at the beginning of this year and Had to Convert from my old Unlimited Family Plan to the Newer Share Everything Plan. My Data Usage varies a lot due to occasional travel which I have little control over. At least you recently began including a $10 deduction on each of the 2 older phones (which I have not updated in order to save money though they need updating). My Sweet Spot on Data would be around 6GB Monthly Data. But that level is not offered. Only 2, 3, 4, 10, or 15 GB plans are offered.
    Verizon's Data Plans Offered Are:  2GB-$50/MO = $25/GB  *   3GB-$60/MO = $20/GB   *   4GB-$70/MO = $17.50/GB   *  10GB-$80/MO = $8/GB   *  15GB-$100/MO =  $6.66/GB   *   And Overages are Charged at $15 per 1k-1GB.
    Offers JUMP From 4GB TO 10GB (There's a 6GB GAP/JUMP - ***) - Why is there NO 6 or 8 GB offering?  Because Verizon is Overcharging the Lower Data Users!  Seems like All of the Other Cellular companies are Offering Better Deals.
    If you can offer something better please let me know, otherwise I may have to consider going back to AT&T or moving to one of the other cellular companies.

  • My music goes to iCloud and I don't want to use my data to download it continuously. How do I keep it on my device and out of iCloud?

    My music goes to iCloud and I don't want to use my data to download it continuously. How do I keep it on my device and out of iCloud?

    Donnakelley62 wrote:
    I don't know. And no I don't use iTunes match.
    WE are travelling and it seems every time I want to listen to music it's on iCloud and not my device. I find a wifi connection and download the songs them bam next time they are back on iCloud!
    iTunes purchases are always on iCloud. They don't get uploaded there. They are simply there because you purchased them.
    When you first purchqse, iTunes (computer or phone) should download them. If they are not downloaded, you will see the cloud icon.

  • Average value of N samples

    Hi,
    I have a problem. I'm reading data continuously from analog input. I want calculate average value when I press button START. Average value should be calculated from samples which are defined by 'Number of samples' and 'millisecond multiple'. When all samples are read, average vale should show.
    The problem is that when number of samples is higher then 10, it doesn't work.
    Can someone tell me what I did wrong?
    Thanks
    P.S.. I saw that there was something like this but I can't open it because I use Labview 8.5
    Attachments:
    Average.vi ‏35 KB

    For that you need to store the previous value for averaging... i have attached a VI regarding that ( sorry no time to cleanup ).. You can use the logic to calculate the average of the samples (Still am not clear about you requirement).
    The best solution is the one you find it by yourself
    Attachments:
    Average_anand.vi ‏26 KB

  • Plotting "Averaged" Data Every 10 Seconds

    Hello! I'm trying to collect a voltage data and average them every 10 seconds then plot the average. I've attached a closed example of the vi I'm working on which is slowing my process. Thanks in advanced!!!!
    KowdTek
    LabVIEW 2009
    One Step At A Time, Maybe Two...
    Attachments:
    UPDATE.vi ‏43 KB

    I noticed you said you collected voltages. Then I assume you have some DAQ equipment also. A very common mistake by beginners is that they do the data collection in a software timed loop, reading 1 sample in each iteration. That is not the best approach. The best thing is to let the DAQ unit do the timing and buffering. Then you can relax and just pull data from the buffer then you want it. Go to help in the toolbar and then select "find examples" search for the term "continuous acq"  I think a good example for you to start with is the "Cont Acq&Chart Samples-Int Clk.vi"
    Besides which, my opinion is that Express VIs Carthage must be destroyed deleted
    (Sorry no Labview "brag list" so far)

  • How to average data collected in a loop

    Hey everyone,
    I am using an interface card to read voltage across a resistor to measure the current through a photodiode.  The VI I made slowly increases the voltage applied across the sample. It takes a starting voltage, increases it by a specified increment, and then takes a series of measurements at that voltage (usually around 200 or 300). I had the program just save all of this data to an external measurement file, where I would then average it in excel.  I had to change the program to measure three variables, and I want to the VI to average the data and then save the average current at each voltage in a measurement file. 
    Ex. 
    It used to export the data as...
    -1     .90
    -1     .80
    -1     .85
    Im trying to get the program to average all of these values and then save it as one data point.
    -1     .85
    I would like the program to take the 200 or so data points, average them, and then save just the average in a file. 
    I usually have about 300 different applied voltages to measure, and with 200 current readings at each it becomes a huge amount of data.
    Right now I have the part of the VI that takes the measurements in a while loop, and once the number of loop iterations reaches the specified number of measurements it stops running.  The program would then increase the voltage, and run the measurement loop again.  I got everything else working, I just can't figure out a way to average all the data.
    Any help would be greatly appreciated

    Alright, I just started using labview last week and i knew that i would have to use shift registers, but when i tried to create one the add shift register option was grayed out.  All i had to do was click on the right or left side of the loop instead of the bottom which is what i had been trying before. 
    Thanks for the fast response

  • Conflict between the saved data and the sampling rate and samples to read using PXI 6070e

    Hello, I am using PXI 6070e to read an analog voltage. I was sampling at 6.6 MHz and the samples to read were 10. So, that means it should sample 10 points every 1.5 um. The x-axis of the graph on the control panel was showing ns and us scale, which I think because of the fast sampling and acquiring data. I use "write to measurement file" block to save the data. However, the data was saved every 0.4 second and as 35 points data at the beginning of each cycle (e.g. 35 points at 0.4 sec and 35 at 0.8 sec, and so on) and there was no data in between. Can anyone help me how there are 35 reading points every cycle? I could not find the relation between the sampling rate and samples to read, to 35 points every 0.4 second!
    Another thing, do I need to add a filter after acquiring the data (after the DAQ assistant block)? Is there anti-aliasing filter is built in PXI 6070e?
    Thanks for the help in advance,
    Alaeddin

    I'm not seeing anything that points to this issue.  Your DAQ is set to continuous acquire.  I'm not sure if this is really what you want because your DAQ buffer will keep overwriting.  You probably just want to set to Read N Samples.
    I'm not a fan of using the express VIs.  And since you are writing to a TDMS file, I would use the Stream to TDMS option in DAQmx.  If you use the LabVIEW Example Finder, search for "TDMS Log" for a list of some good examples.
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions
    Unofficial Forum Rules and Guidelines

  • Averaging Data stream from air flow meter...

    Hello,
    I'm fairly new to Labview, so this may seem elementary to some.  I am pulling real-time data from an airflow sensor and I want to manipulate the data in the following way:
    1) after starting the program, I want to release one of 3 valves to trigger the sequence
    2) delay for 10 seconds
    3) grab one data point at a given interval (every second?) over period of 10 seconds (20 seconds total time elapsed)
    4) average the data and spit out a value 
    I've been trying for a while to get this working for a while.  Any tips would be much appreciated.  Once again, I'm new at this, so please bare with me.
    Thank you.
    Mark 
    Attachments:
    Air Flow venturi.vi ‏223 KB

    Basically the test setup is this...I am testing air pressure through a mechanical venturi.  There are 3 venturis in the machine at the same time.  The DAQ assistant communicates with the NI USB-6009 only (no data collection).  THis is used to activate the solenoids that clamp and pressurize the test pieces.  When one of the nozzles (nozzle1, 2, 3) is released, air flow through and the Omega FMA-1611A flow sensor picks up pressure and flow rate.  This is what is connected to the serial port.
    What I'm trying to do is streamline the process.  Right now, I am reading a number off a visible indicator, which is causing user error.  I'm trying to make it so that as soon as I release one of the nozzles (boolean nozzle1, 2, 3), a sub-routine will execute that waits 10 seconds (for the air flow to normalize) then takes a reading once every second for 10 seconds.  Then I want to display and record the average of these data points.  I want to be able to do this without ending the program (the flowmeter should still be reading continuously).  I've gotten to the point where the program works perfectly with the just the visible displays.  All I need to do is add the secondary sub-routine I explained. 
    I did try highlight execution per reccomendation and I now see what you are saying about data flow.  I tried just taking data points without averaging or time delays and I still seem to be bogging down the program somehow.  Do I need to build another case structure outside of the main loop?  I think I can get through the delays and the mathematics...my biggest issue is taking a reading at a set interval (i.e. 1 second) and saving the readings so that I can calculate the average and display it.  Do I use an array?  The "for loop" uses bracketing, but as you stated, only takes one reading. 
    I'm an ME guy, so while I can build the test setups without issue...obviously programming is another story
    I will continue to play around with the programming.  I have gotten far enough to make the program work in its basic form, so I think I can do this, but any tips you can provide would be extremely helpful.
    Thanks again,
    Mark

Maybe you are looking for