How do I create an n-point running average VI?

I've been programming in sequential written languages like C for many years now. I've been using LabVIEW for the last 4 months and am having problems writing an n-point running average VI. It is really bothering me, because this would be really trivial in C or anything else. But for some reason I can't conceive how I would do this in LabVIEW. I used LabVIEW 5 for the bulk of that time, and we just upgraded to LabVIEW 8 last week so I've been learning it. Wow, some pretty big differences between the two but the gist is the same.
I have a 5-point running average subVI written that uses a run-once while loop with shift-registers that keep their value between subsequent VI calls. This works for what I need, but have 2 problems I would like to overcome.
1. I can't have multiple instances of the same subVI in my top-level VI program because the way the shift-registers are keeping their value between subsequent VI calls. I have to make duplicates of the .vi file (i.e., 5_point_running_average.vi, 5_point_running_average_2.vi) in order to keep all the shift registers seperate.
2. I want it to be an n-point running average. Currently I have to jump into the VI and add another shift register to add another point. I often change my sample rate, and thus being able to have a different averaging window is really handy.
So the VI takes 2 inputs:
n - (integer) the number of points to computer the average over.
in - (real) the current data point.
output:
out[i] = (in[i] + in[i-1] + ... + in[i-n-1])/n
I've also thought about the possibility of needing a 3rd input that is "instance" which might help keep variables within the subVI separated and thus not needing separate duplicate files.
In case you are wondering, I'm using a running average to make digital HUDs easy to read. The actual data that I'm recording to file will not be going through the running average function, because as you can see by the output function, there will be a phase shift in the output. At high sample rates, the digital displays can be moving very rapidly and that makes them hard to read.
Other recommendations as to how to make digital displays easy to read to help operators while performing tests? As for instantaneous data smoothing, so to speak. I already make the displays very large if they are critical.
I'm very interested in this n-point running average solution. I've been scratching my head over it for awhile now and am quite stumped on how to approach this in LabVIEW.
Help is very much appreciates,
-nickerbocker

The atomic operations (delete/insert) MUST do the following:
When you insert into array, all higher elements need to be moved up one slot, then the element is inserted.
When you delete from array, the lement needs to be deleted and all higher elements moved down one slot
Both operations involve an array resizing operation and data shuffling in memory.
How can LabVIEW be sure that the memory can be re-used? What if your code would delete one, but insert two at each iteration? It might well be that the LabVIEW compiler properly re-uses the memory in your particular case, but there are no guarantees. A five element array is peanuts. so it would probably be difficult to notice a difference.
You might want to run a benchmark of the different algoritms using a huge buffer.
"First call?" is defined as followes in the online help:
First Call? returns TRUE the first time the VI runs after the first top-level caller starts running, such as when the Run button is clicked or the Run VI method executes. If a second top-level caller calls the VI while the first top-level caller is still running, First Call? does not return TRUE a second time.
It will only be true exactly once during the entire execution of the toplevel VI, only the first time it is called from anywhere.
LabVIEW Champion . Do more with less code and in less time .

Similar Messages

  • How can i create a NULL-Pointer

    Hello,
    how can i create a NULL-pointer (like in C) to call a DLL-function in Labview 8?
    I have this function:
    XXXXXX FuncName(int32 handle,
    char * aCharName,
    void * aVoidName,
    int32 aInt32Name,
    char * Msg);
    and have to call it like this:
    rc=InitCasRunF(&handle, NULL, NULL, NULL, msg);
    When running the vi i get a popup with this message:
    Labview: An exception occured within the external code called by a Call Library Function Node.
    This might have corrupted Labview´s memory. Save any work to a new location and restart Labview.
    VI "......." was stopped at Call Library Function Node Call Library FuncName 0x13E0 of subVI.
    Democall.vi
    The attached democall.vi is not the original but its like that.
    Thanks for any help how i have to create thi NULL-pointer
    Message Edited by NewOne on 01-25-2006 03:42 AM
    Attachments:
    democall.vi ‏8 KB

    Thx for your help. Meanwhile it works. It was a stupid, easy thing i didnt see all the time.
    I had to change the first parameter as--> Pass: "Pointer to value" instead of "Value". Thats all.
    All NULL-values are passed as Int32-value.
    One new problem occurs now: After runnning the function Labview crashes down.
    Error-report is attached if someone can read someting in this.
    When running the dll-function in a c-program it works
    When calling the dll-function it in teststand it also works.
    Message Edited by NewOne on 01-26-2006 05:14 AM
    Attachments:
    dce5_appcompat.txt ‏47 KB

  • How do i create a digital pointer in a presentation?

    how do i create a digital pointer in a presentation?

    Try OmnidDzzle for free.
    http://www.omnigroup.com/products/omnidazzle/features/
    or Mouseposé for $4.99 on the Mac App store
    http://itunes.apple.com/us/app/mousepose/id405904955?mt=12
    I've used both and one or the other should give you what you're looking for at a pretty good price If you have any questions about using either, post back here.

  • How to manually create layer breaking point for DVD9

    Hello, I was wondering if someone could please tell me how I would go about to manually set the layer break point for a DVD9 project that I burned onto 2 DLT tapes. The total size of the DVD is 6.3GB.
    I had used the "automatic" setting for burning the DLTs and sent them to a replicator. They came back saying that the layer 0 tape did not allow enough headroom for their Ripguard protection.
    I've always used the automatic setting and this is the first time I am asked to manually set it. SO now I need to figure out how I can put a certain amount of data on one DLT tape and the rest on the other DLT.
    I am a beginner at this so any help would be greatly appreciated.
    Thank you!

    Hi Eric,
    Unfortunately the information you have regarding RipGuard and the ability to copy RipGuard protected discs is a little outdated.
    Can RipGuard be broken? Yes, anything can be broken into, including the DoD Website by 14 yr old chinese students... but that doesn't mean there isn't value in protecting the DVD.
    Also, RipGuard is regularly updated, just like Antivirus software, so while older versions of RipGuard can be broken more easily, the latest versions of RipGuard are significantly more difficult to circumvent by existing software.
    But again, the point isn't to create the unbreakable 'holy grail' DVD copy protection, but rather to protect something of value.
    When you leave your house in the morning, do you close your front door and lock it? Of course you do, but why? So no one will break in. But do you think locking up your house is really going to stop someone from going around to the side of the house and busting out a window if they really want to get in? Of course it wont. If someone wants to break into your house, they will find a way.
    Same thing with DVDs. You lock your house because it provides a method of protection, a barrier to make it more difficult and to keep honest people honest. That's what RipGuard, or any copy protection software does.
    So the question isn't why would you protect your DVD, but rather why wouldn't you? In most cases if you prevent just a few illegal copies of your DVD from being ripped, it has already more than paid for itself.

  • How do I create new mount point

    Hello,
    I'd like to create a new mount point. The Admin guide says to click the Create button on the toolbar but I don't see anything that says Create (I have New, Edit, Upload,...).
    Searching here I've seen references to some code snippets that purport to do it but I'd rather use a GUI.
    Thanks for any help

    You have to use iFS Manager, not the WebUI.

  • Creating a form with Running Averages

    Hi
    I am creating a Blood Glucose Monthly Form. It is organized by week with an average at the end of each week for the various times of day I test my sugar. Those results then contribute to averaging the weekly numbers for a monthly number. I have a similar form I am developing for Blood Pressure.
    My question is that since this a monthly form destined to be a template how do I get around the error messages that appear when there are blanks as I have not yet reached that day/ date. Can someone help with a formula that will work?
    Thank you
    Herbert

    Herbert,
    There is a function named "IFERROR" that will trap an error condition, prevent the alert and substitute a display/calculation that you choose. The syntax is: =IFERROR(original-expression, what-to-do-upon-error).
    Often it is sufficient to display a null string on error: IFERROR(original-expression, "").
    Jerry

  • Create a change pointer

    Hi everybody.
    I need to throw a change pointer when a equipment is modified (Table EQUI). I´d like to throw this change pointer when the user change the status of this object (Tabla JEST, field STAT). The problem is that in transaction BD52 I can´t find an adecuate entry and when the user only modifies this status the change pointer is not created. How could I create this change pointer when this field is modified? Exist any FM to create a change pointer or only is possible by customizing?
    Thanks a lot.
    Regards

    The check box is not checked.... That means the change pointer can´t be created when this field is modified??
    Thanks a lot
    Edited by: Christian  Abad Chico on Nov 4, 2009 9:35 AM
    Edited by: Christian  Abad Chico on Nov 4, 2009 9:35 AM

  • How do I Creating links ??

    Hi
    I have looked at help.sap.com abt this -it is unclear to me. Please help.
    I have installed EPSP9 NW04 SR1 with KMC. I would like to create an iview that just has links one after the other. Some of these links will point to documents and some will point to sites on client's intranet. So i want the iview to be like this for example:
              About Company
              Products Sold
              Emergency Procedures    
    How do I create these links? I will upload documents in the portal via KM. But how do I create the links pointing to documents and teh intranet?
    Manny Thanks
    Namira

    hi
    If you only want some static links you can go for the KM Document iview.
    1.Create an html document with the links you needed.
    2. Use javascript functions for the links.
    3.Save it as text and upload it to a KM folder.
    4.Create a KM Document iview and set the path to the document you created in the properties of iview.
    5.Place the iview in the portal where you wanted.
    Regards
    geogi

  • How do I create a point to a list of devices?

    I have a .dll code with a function to control the Analyzer from AX/4000, as follow bellow:
    void anaRun(UINT8 run, UINT8 *devList, UINT8 numDev)
    How do I create in Labview the list of devices and how do I specify the number of devices?
    Thank you.

    If you simply need to know how to pass a pointer into a call library function node then you should check out this document:
    Passing and Receiving Pointers with C/C++ DLLs from LabVIEW
    https://decibel.ni.com/content/docs/DOC-9080
    --Ryan

  • How to create a schedule to run once?

    I am having some problems getting a schedule to run only once. If I leave the repeat_interval empty, the schedule does not run at all. The documentation explains all the options for setting the repeat frequency, but it does not explain how to run it only once at a set time/date. I have created a user interface to allow the users to create their own schedules and I'd rather not do something like a "yearly" interval with an end date of next week. I need the generic solution.
    Any ideas?

    Hi Ravi,
    Thanks for your reply!
    I have just discovered something very interesting! best explained by example:
    (I might log an SR through metalink too. I'll be sure to update this thread with the outcome...)
    I create 3 schedules and 3 simple jobs:
    schedule 1 - start_date in 2 minutes time (eg. 11:30:00), repeat_interval => null
    schedule 2 - start_date in 2 minutes, 20 seconds time (eg. 11:30:20), repeat_interval => 'FREQ=DAILY'
    schedule 3 - start_date in 2 minutes, 40 seconds time (eg. 11:30:40), repeat_interval => null
    jobs 1, 2 and 3 just insert a row into a table through a PL/SQL block.
    My test results are as follows:
    1. The first time these schedules are created only schedule 2 runs. Schedules 1 and 3 never run.
    2. I drop and re-create all schedules and jobs, (adjusting the time to a few minutes in the future) and re-submit the schedules and jobs and they all run. I can continue this as many times as I like now and the repeat_interval of null will now work fine.
    3. re-start the 10gR2 database.
    4. re-create the schedules and jobs and only schedule 2 runs again. Schedules 1 and 3 never run. (I'm back at step 1!! I can reproduce this problem anytime by following these steps)
    My script is below:
    declare
    start_datetime__w timestamp(3) with time zone;
    repeat_interval__w varchar2(200);
    begin
    * REPEAT INTERVAL NULL TEST
    * TIM_SCHED_2_1 - no repeat interval
    * TIM_SCHED_2_2 - a repeat interval
    * TIM_SCHED_2_3 - no repeat interval (identical to TIM_SCHED_2_1)
    * Results on my 10gR2 database (Redhat Enterprise Linux 4.4) are:
    * job 2 will always run
    * jobs 1 and 3 will only run after the successful run of job2 AND jobs 1 and 3 have been re-created
    * Why?
    * It seems the scheduler needs a wakeup call!!!
    * test table: create table tim (col1 varchar2(30), col2 date);
    -- Cleanup previous jobs:
    --dbms_scheduler.drop_job      (job_name      => 'TIM_JOB_2_1');
    --dbms_scheduler.drop_schedule (schedule_name => 'TIM_SCHED_2_1');
    --dbms_scheduler.drop_job      (job_name      => 'TIM_JOB_2_2');
    --dbms_scheduler.drop_schedule (schedule_name => 'TIM_SCHED_2_2');
    --dbms_scheduler.drop_job      (job_name      => 'TIM_JOB_2_3');
    --dbms_scheduler.drop_schedule (schedule_name => 'TIM_SCHED_2_3');
    repeat_interval__w := 'FREQ=DAILY';
    -- create schedule TIM_SCHED_2_1, repeat_interval__w = null
    start_datetime__w := '27-FEB-2007 11:34:00.000 AM +10:00';
    dbms_scheduler.create_schedule (schedule_name => 'TIM_SCHED_2_1',
    start_date => start_datetime__w,
    repeat_interval => null,
    end_date => null,
    comments => 'schedule created at '||to_char(sysdate,'DD-MON-YYYY HH24:MI:SS'));
    -- create schedule TIM_SCHED_2_2, with a repeat_interval set
    start_datetime__w := '27-FEB-2007 11:34:20.000 AM +10:00';
    dbms_scheduler.create_schedule (schedule_name => 'TIM_SCHED_2_2',
    start_date => start_datetime__w,
    repeat_interval => repeat_interval__w,
    end_date => null,
    comments => 'schedule created at '||to_char(sysdate,'DD-MON-YYYY HH24:MI:SS'));
    -- create schedule TIM_SCHED_2_3, repeat_interval__w = null (SCHEDULE IDENTICAL TO TIM_SCHED_2_1)
    start_datetime__w := '27-FEB-2007 11:34:40.000 AM +10:00';
    dbms_scheduler.create_schedule (schedule_name => 'TIM_SCHED_2_3',
    start_date => start_datetime__w,
    repeat_interval => null,
    end_date => null,
    comments => 'schedule created at '||to_char(sysdate,'DD-MON-YYYY HH24:MI:SS'));
    -- create jobs
    dbms_scheduler.create_job (job_name => 'TIM_JOB_2_1',
    schedule_name => 'TIM_SCHED_2_1',
    job_type => 'PLSQL_BLOCK',
    job_action => 'begin '||
    'insert into tim values (''TIM_JOB_2_1'', sysdate); '||
    'commit; '||
    'end;',
    number_of_arguments => 0,
    enabled => TRUE,
    comments => 'job created at '||to_char(sysdate,'DD-MON-YY HH24:MI:SS'));
    dbms_scheduler.create_job (job_name => 'TIM_JOB_2_2',
    schedule_name => 'TIM_SCHED_2_2',
    job_type => 'PLSQL_BLOCK',
    job_action => 'begin '||
    'insert into tim values (''TIM_JOB_2_2'', sysdate); '||
    'commit; '||
    'end;',
    number_of_arguments => 0,
    enabled => TRUE,
    comments => 'job created at '||to_char(sysdate,'DD-MON-YY HH24:MI:SS'));
    dbms_scheduler.create_job (job_name => 'TIM_JOB_2_3',
    schedule_name => 'TIM_SCHED_2_3',
    job_type => 'PLSQL_BLOCK',
    job_action => 'begin '||
    'insert into tim values (''TIM_JOB_2_3'', sysdate); '||
    'commit; '||
    'end;',
    number_of_arguments => 0,
    enabled => TRUE,
    comments => 'job created at '||to_char(sysdate,'DD-MON-YY HH24:MI:SS'));
    end;
    Cheers,
    Tim.

  • How do I create a 1d array that takes a single calculation and insert the result into the first row and then the next calculation the next time the loop passes that point and puts the results in thsecond row and so on until the loop is exited.

    The attached file is work inprogress, with some dummy data sp that I can test it out without having to connect to equipment.
    The second tab is the one that I am having the problem with. the output array from the replace element appears to be starting at the index position of 1 rather than 0 but that is ok it is still show that the new data is placed in incrementing element locations. However the main array that I am trying to build that is suppose to take each new calculation and place it in the next index(row) does not ap
    pear to be working or at least I am not getting any indication on the inidcator.
    Basically what I am attempting to do is is gather some pulses from adevice for a minute, place the results for a calculation, so that it displays then do the same again the next minute, but put these result in the next row and so on until the specifiied time has expired and the loop exits. I need to have all results displayed and keep building the array(display until, the end of the test)Eventually I will have to include a min max section that displays the min and max values calculated, but that should be easy with the min max function.Actually I thought this should have been easy but, I gues I can not see the forest through the trees. Can any one help to slear this up for me.
    Attachments:
    regulation_tester_7_loops.vi ‏244 KB

    I didn't really have time to dig in and understand your program in depth,
    but I have a few tips for you that might things a bit easier:
    - You use local variables excessively which really complicates things. Try
    not to use them and it will make your life easier.
    - If you flowchart the design (very similar to a dataflow diagram, keep in
    mind!) you want to gather data, calculate a value from that data, store the
    calculation in an array, and loop while the time is in a certain range. So
    theres really not much need for a sequence as long as you get rid of the
    local variables (sequences also complicate things)
    - You loop again if timepassed+1 is still less than some constant. Rather
    than messing with locals it seems so much easier to use a shiftregister (if
    absolutely necessary) or in this case base it upon the number of iterations
    of the loop. In this case it looks like "time passed" is the same thing as
    the number of loop iterations, but I didn't check closely. There's an i
    terminal in your whileloop to read for the number of iterations.
    - After having simplified your design by eliminating unnecessary sequence
    and local variables, you should be able to draw out the labview diagram.
    Don't try to use the "insert into array" vis since theres no need. Each
    iteration of your loop calculates a number which goes into the next position
    of the array right? Pass your result outside the loop, and enable indexing
    on the terminal so Labview automatically generates the array for you. If
    your calculation is a function of previous data, then use a shift register
    to keep previous values around.
    I wish you luck. Post again if you have any questions. Without a more
    detailed understanding of your task at hand it's kind of hard to post actual
    code suggestions for you.
    -joey
    "nelsons" wrote in message
    news:[email protected]...
    > how do I create a 1d array that takes a single calculation and insert
    > the result into the first row and then the next calculation the next
    > time the loop passes that point and puts the results in thsecond row
    > and so on until the loop is exited.
    >
    > The attached file is work inprogress, with some dummy data sp that I
    > can test it out without having to connect to equipment.
    > The second tab is the one that I am having the problem with. the
    > output array from the replace element appears to be starting at the
    > index position of 1 rather than 0 but that is ok it is still show that
    > the new data is placed in incrementing element locations. However the
    > main array that I am trying to build that is suppose to take each new
    > calculation and place it in the next index(row) does not appear to be
    > working or at least I am not getting any indication on the inidcator.
    >
    > Basically what I am attempting to do is is gather some pulses from
    > adevice for a minute, place the results for a calculation, so that it
    > displays then do the same again the next minute, but put these result
    > in the next row and so on until the specifiied time has expired and
    > the loop exits. I need to have all results displayed and keep building
    > the array(display until, the end of the test)Eventually I will have to
    > include a min max section that displays the min and max values
    > calculated, but that should be easy with the min max function.Actually
    > I thought this should have been easy but, I gues I can not see the
    > forest through the trees. Can any one help to slear this up for me.

  • How can I create a disk image of snow leopard installer disk from my Imac which runs it?

    how can I create a disk image of snow leopard installer disk from my Imac which runs it? It came without DVD installer, and I want to make a copy of it's OS installer but can't find out how.

    You need to have the disc in order to create disk image of snow leopard installer disc. What did your machine ship with? If something later than SL, then why? If earlier, then you can buy the SL installer disc and make the disk image.

  • How can I create a start up disk for a old intel core duo running 10.5.8.. Computer works fine, but can't find install disk.

    How can I create a start up disk for a old intel core duo running 10.5.8.. Computer works fine, but can't find install disk. Want to use internal disk drive or USD flash drive.

    Try calling 1-800-676-2775.  Give the serial number and thy *may* still burn you new install disks designed just for the hrdware in your system (for a fee, something like $160 per disk).  *May* is only because they may not burn disks for Leopard anymore.
    If they do not burn them for you, you can buy Leopard disks off Amazon or eBay for about $200.
    Have you considered Snow Leopard?.  Those disks only cost $19 (single user) or $29 (5-user license) through Apple by calling 1-800-MY-APPLE.

  • How do I create a report of what is run and when on Crystal Server

    In crystal server, how do I create a report that will tell me the name of all of my reports and the time it is scheduled to run?
    I get the feeling it is in the Query Builder,  but I have no idea what the names of all of these tables are.
    Anyone ever done this or know of another way to do this?

    Please download https://www.sdn.sap.com/irj/boc/index?rid=/library/uuid/404170c1-59ae-2b10-b19f-c86764e759a5#rating and read the section titled "Auditing Reports".

  • How to create transparent image at run-time?

    How to create transparent image at run-time? I mean I want to create a (new) transparent image1, then show other (loaded) transparent image2 to image1, then show image1 to a DC. The problem is - image1 has non-transparent background...

    i'm not sure, but you can set the alpha value to 0 in all pixels which are 'in' the background..
    greetz
    chris

Maybe you are looking for

  • Blank page shown when Jive Forum is started

    Hi, we got a blank page when the Forum is started. Configuration of iViews is fine. Problem only occurs when forum is called when using browsers that have more security restrictions. Strange enough the SDN forum works fine in those case, but not our

  • Trying to boot in to safe mode, phone will just reboot.

    Hi. I'm trying to boot my Incredible into Safe Mode, because I'm having trouble with my sound. I can't hear speakerphone, ringtones, button presses etc. So I'm trying to boot into Safe mode. I press the buttons (down volume, Menu, circular button) wh

  • Date format for ARDGLP

    Hi, I am trying to find out why the date I pass to the ARDGLP concurrent program isn't getting swallowed. The ARDGLP is the Dunning Letter Generate Program, which has a parameter 'Dun as of date'. I am executing this program in a PL/SQL-procedure wit

  • Viewer Crosstab Excel Export - Limit to Static Worksheet

    I'd like to know if it's possible to limit the export of a crosstab worksheet to excel to just a static worksheet (eg. Crosstab_Static excel worksheet ). In advance, thanks for your assistance.

  • Desktop creative cloud stopped working.

    As of today,  my desktop creative cloud stopped working.  could not find icon on desktop.  any ideas conaway design