the moving average of 3 random numbers

This is my first time using LabVIEW and I need help.

  • I have to design VI which generates the random number from 10 to 100
  • VI shows the last generated number and the moving average of the last 3 generated number on a waveform graph
  • If the average of the last 3 numbers obtained is greater than 55, to turn on the LED.

I did the whole VI but I have the problem with the first two loops. In the first loop, the moving average should show the random number itself (((random number) 1 + 0 + 0) / 1). In the second loop (((random number 1) + (random number) 2 + 0) / 2) and after that my VI works correctly. The moving average shows the other values in the first two loops (random number e.g. 17.54, average 29.28). Probably I have to change something in the shift registers, but I'm not sure how to do it. I need help to fix my VI for the first two loops. Thank you in advance.

easy

No explin he for grade

Of course there are other ways

Tags: NI Software

Similar Questions

  • The moving average.

    What is meant by moving average? and hoe do we calculate in essbase.

    Read the technical link referance and get back if you had doubts below.

    http://download.Oracle.com/docs/CD/E10530_01/doc/EPM.931/html_esb_techref/funcs/movavg.htm

  • The moving average of the data file

    Hello

    I'm doing a Subvi, which has jumps in the data points.

    The algorithm:

    -build an array of samples (of size round(FPS/2))

    -Take the average

    -subtract the data of the table of average points: = absolute difference (medium-sized data point).

    -compare the difference threshold: If difference > = point, then add 1 to the counter.

    The Subvi (jump detect) is intended to be used in a larger vi, and I need to make sure that it works. But it doesn't now.

    When the vi works and everything is calculated, it does not count the jumps that are visible on the ground.

    Any ideas what I am doing worng?

    Thank you

    The exsist problem in your loop in your Subvi. At this stage you are iterating FPS/2 size of the array, and you only show the last value of all of your calculations. Unless the last value is reported as a jump, it will not be saved. You can easily fix this by putting registers at offset on your loop for, the only question is do something with your Boolean indicator. You can index the Boolean values, and then make a chart or works, but this part is up to you.

  • FPGA - windowed moving average, variance, standard deviation, kurtosis and asymmetry

    Hello!

    I'm processing in FPGA and I want to calculate the MOVING WINDOW average, variance, standard deviation, kurtosis, asymmetry online for the last N (N is the size of windows) elements. The frequency is about 100 kHz and N about 10000 (100 ms of signal).

    I found something like EMA (moving average exponential)...

    Have someone solved something like that? Any ideas how to fix?

    That looks like a problem. What type of window you need? The moving average exponential isn't an option? There are online algorithms described in Wikipedia, but they can suffer from problems of numerical accuracy when it is implemented in a fixed point (depending on the nature of the data). They would be interesting watch in, however.

    Other than that, here are some options that I can think of:

    • More large FPGA
    • Be part of the treatment on the RT controller - have - you looked into that?
    • Return to your needs and push some of the numbers. Do you really need 100 ms in all cases, etc.?
    • Depending on the nature of the data, simple compression techniques may be an option
    • An precision analysis to determine the data type minimum, that you really need. For example, getting to 25 bits, would have a huge impact on your cost of multiplier.
    • Consider the mathematics of floating (using Xilinx IP cores) point to online methods. Your flow is relatively low, so you could share it resources between all channels. Manage States of different channels is complicated but is doable.

    The BRAM will be used for FIFO buffers, but is also available for general use to implement the fifo and memories. Some IP use BRAM under the hood, keep an eye on the compilation summaries to monitor how much still you have.

  • exponential response moving average stage fpga

    Hey guys,.

    I have a problem with my filter, the exponential weighted moving average filter (IIR 1 st order.). Excerpt from the book: understand the digital signal processing (Richard Lyons) I have the following formula, calculate the frequency of 3dB (CF) of alpha. Alpha is the parameter to control the filter.

    Differential equation of the filter: y [n] = x [n] * alpha + (1 - alpha) * y [n-1]

    Relationship between CF and alpha: alpha = cos(2fc/fs) - 1 + sqrt [cos²(2fc/fs) - 4 * cos(2fc/fs) + 3]

    If I now choose a frequency of 3 dB from 0, 0794Hz (time constant (TC) = 2 s) alpha = 0,00169621. (fs = 94)

    For a filter command 1st IIR, the rise time (your) of the stepresponse (from 10% to 90%) is: ta = 2, 2 * TC which translates your = 4, 4S.

    But if I simulate the step response, my rise time is about 3 times this value at 14.

    I can't explain why the response of my filter is so much different. For my Moving Average filter, the calculated and simulated rise time are equal.

    I have the vi that is performed on the attached FPGA. Maybe someone can find a mistake...

    Greetz

    Slev1n

    Hey ZX81.

    Thank you very much for your detailed answer.

    Regarding the issue with the rise time, I think I've found the error. You might be right, that the formula is not correct, or which is most probably misunderstood by me and put in the wrong context.

    When I was cycling home from work I remembered a practical function of labview: 'coefficients.vi filter smoothing' here you only need to define tau/TC and fs and it calculates the numerator and the denominator for the moving average exponential and the moving average. Offering it is alpha I could compare the result of the formula I've used and there was a big difference. LabVIEW uses the following formula: alpha = 1 - exp (-1 /(fs*TC)). With this formula, TC = 2 s is equal to alpha = 0, 0053.

    And with this alpha my simulation works! Risetime 4.4 s

    Quote you: "in general, at this stage, I have maturities adjust alpha until my results matching what I wanted and move." I would like to do the same thing, but as it's my thesis I have to solve such things

    Now, back to the rounded questions. I understand that the small values are a more serious problem. This filter is used in a Lock In, the values are going to be REALLY small. But I've already tested on our measuring device and it works, to that effect, I'll test your version as well, but if I get no problems, I guess I keep to the 40bits. Simulating the following configuration, caused an error of 2.3%. 57 bits using reduced the error less than 1%. I think that 40bits should be sufficient.

    Alpha = 0, 000335693 entry = 1, 19209E-7

    And regarding resources, I have no worries. Although using a myrio ultimately I still have a lot of DSP Slices for the multiplication and 10% in flip flops.

    So I guess that this matter is resolved. Thanks for your great help and interesting reflections.

    Kind regards

    Slev1n

  • [8i] how to calculate a moving average?

    I am trying to calculate a moving average over a specific period of time, but I can't quite figure out how to do this. For this particular problem, I am also stuck on a 8i database.

    Some examples of data for the problem:
    CREATE TABLE     my_data
    (     order_no     CHAR(10)
    ,     seq_nbr          CHAR(4)
    ,     area_id          CHAR(4)
    ,     start_date     DATE
    ,     unit_time     NUMBER(7,2)
    );
    
    INSERT INTO my_data VALUES ('0000567890','0010','A001',TO_DATE('05/01/2000','mm/dd/yyyy'),0.34);
    INSERT INTO my_data VALUES ('0000567890','0020','A001',TO_DATE('05/02/2000','mm/dd/yyyy'),0.78);
    INSERT INTO my_data VALUES ('0000567890','0030','A002',TO_DATE('05/03/2000','mm/dd/yyyy'),0.91);
    INSERT INTO my_data VALUES ('0000567890','0040','A003',TO_DATE('05/03/2000','mm/dd/yyyy'),0.27);
    INSERT INTO my_data VALUES ('0000123456','0010','A001',TO_DATE('04/01/2001','mm/dd/yyyy'),0.39);
    INSERT INTO my_data VALUES ('0000123456','0020','A001',TO_DATE('04/02/2001','mm/dd/yyyy'),0.98);
    INSERT INTO my_data VALUES ('0000123456','0030','A002',TO_DATE('04/03/2001','mm/dd/yyyy'),0.77);
    INSERT INTO my_data VALUES ('0000123456','0040','A003',TO_DATE('04/03/2001','mm/dd/yyyy'),0.28);
    INSERT INTO my_data VALUES ('0000123123','0010','A001',TO_DATE('12/01/2001','mm/dd/yyyy'),0.31);
    INSERT INTO my_data VALUES ('0000123123','0020','A001',TO_DATE('12/02/2001','mm/dd/yyyy'),0.86);
    INSERT INTO my_data VALUES ('0000123123','0030','A002',TO_DATE('12/03/2001','mm/dd/yyyy'),0.82);
    INSERT INTO my_data VALUES ('0000123123','0040','A003',TO_DATE('12/03/2001','mm/dd/yyyy'),0.23);
    INSERT INTO my_data VALUES ('0000111111','0010','A001',TO_DATE('06/01/2002','mm/dd/yyyy'),0.29);
    INSERT INTO my_data VALUES ('0000111111','0020','A001',TO_DATE('06/02/2002','mm/dd/yyyy'),0.84);
    INSERT INTO my_data VALUES ('0000111111','0030','A002',TO_DATE('06/03/2002','mm/dd/yyyy'),0.78);
    INSERT INTO my_data VALUES ('0000111111','0040','A003',TO_DATE('06/03/2002','mm/dd/yyyy'),0.26);
    INSERT INTO my_data VALUES ('0000654321','0010','A001',TO_DATE('05/01/2003','mm/dd/yyyy'),0.28);
    INSERT INTO my_data VALUES ('0000654321','0020','A001',TO_DATE('05/02/2003','mm/dd/yyyy'),0.88);
    INSERT INTO my_data VALUES ('0000654321','0030','A002',TO_DATE('05/03/2003','mm/dd/yyyy'),0.75);
    INSERT INTO my_data VALUES ('0000654321','0040','A003',TO_DATE('05/03/2003','mm/dd/yyyy'),0.25);
    It is a sample of the actual data, which includes the lines around 50K, and is the result of a query, not a table. In addition, the actual data also have a reference number attached to each order, and the end result will be be partitioned by party id number and the region. This sample represents basically something, you might see a unique part number. In addition, these records at the time spacing is not predictable. You might have a single year that has 20 ordered, and another year (or years) that does not.

    Here is where I am now in the problem. For example, suppose I want to calculate a moving average over 2 years (average for the 2 years preceding the date of the current row). For my actual data, I probably want to be able to change the period of time (at different times in several queries) on which the moving average is calculated.

    I thought that using the analytical function AVERAGE with a window clause might be the way to go, but I don't know exactly how to use the window clause. I can even be completely wrong interpret what is its use, but if all goes well, it should still show what I'm after.
    SELECT     area_id
    ,     AVG(tot_area_unit_hrs)     
         OVER     (
              PARTITION BY     area_id
              ORDER BY     min_start
              ROWS          BETWEEN     --2 years prior to min_start of current row
                        AND     CURRENT ROW
              )
    ,     --something to indicate the time period the average is over     AS time_period
    FROM     (
         SELECT     order_no
         ,     area_id
         ,     MIN(start_date)     AS min_start
         ,     SUM(unit_time)     AS tot_area_unit_hrs
         FROM     my_data
         GROUP BY     order_no
         ,          area_id
         )
    ORDER BY     area_id
    ,          time_period
    As you can see from the above query, I want to calculate the sum of the unit_time for each order/area_id combo, then roll the way to this total time. (I'm the average total time that a product passes through each area_id per order).

    I want to see results like something along those lines... I really don't like how the time period is identified, as long as I can pay by him in chronological order, and he tells me what period of time it covers. The way I show with period_start and period_end in the results of the sample below is just a way that I thought to do this.
    area_id   period_start period_end   avg_unit_time   
    ----------------------------------------------------
    A001      4/30/1998    5/1/2000     1.120           
    A001      3/31/1999    4/1/2001     1.245           
    A001      11/30/1999   12/1/2001    1.220           
    A001      5/31/2000    6/1/2002     1.223           
    A001      4/30/2001    5/1/2003     1.153           
    A002      5/2/1998     5/3/2000     0.910            
    A002      4/2/1999     4/3/2001     0.840            
    A002      12/2/1999    12/3/2001    0.833            
    A002      6/2/2000     6/3/2002     0.790            
    A002      5/2/2001     5/3/2003     0.783            
    A003      5/2/1998     5/3/2000     0.270            
    A003      4/2/1999     4/3/2001     0.275            
    A003      12/2/1999    12/3/2001    0.260            
    A003      6/2/2000     6/3/2002     0.257            
    A003      5/2/2001     5/3/2003     0.247            
    Any suggestions?

    Hello

    You're close enough. You want a window based on the BEACH, no LINES.
    LINES BETWEEN... means that you know exactly how many lines will be in the window, and you don't care what range of values that represents.
    RANGE BETWEEN... means that you know the exact scope of the ORDER BY value to include in the window, which could mean any number of lines.

    When you say "RANGE BETWEEN x BEFORE...". "where the words ORDER BY id of a DATE, x is considered as the number of days. (Which is consistent with the arithmetic DATE Oracle).

    Try this:

    SELECT     area_id
    ,     min_start - 730          AS period_start
    ,     min_start             AS period_end
    ,     AVG(tot_area_unit_hrs)
         OVER     (
              PARTITION BY     area_id
              ORDER BY     min_start
              RANGE BETWEEN     365 * 2     PRECEDING
                    AND     CURRENT ROW
              )               AS avg_unit_time
    FROM     (
         SELECT     order_no
         ,     area_id
         ,     MIN(start_date)     AS min_start
         ,     SUM(unit_time)     AS tot_area_unit_hrs
         FROM     my_data
         GROUP BY     order_no
         ,          area_id
         )
    ORDER BY     area_id
    ,          period_end
    ;
    

    Output of your sample data:

    AREA PERIOD_STA PERIOD_END AVG_UNIT_TIME
    ---- ---------- ---------- -------------
    A001 5/2/1998   5/1/2000           1.120
    A001 4/2/1999   4/1/2001           1.245
    A001 12/2/1999  12/1/2001          1.220
    A001 6/1/2000   6/1/2002           1.223
    A001 5/1/2001   5/1/2003           1.153
    A002 5/4/1998   5/3/2000            .910
    A002 4/4/1999   4/3/2001            .840
    A002 12/4/1999  12/3/2001           .833
    A002 6/3/2000   6/3/2002            .790
    A002 5/3/2001   5/3/2003            .783
    A003 5/4/1998   5/3/2000            .270
    A003 4/4/1999   4/3/2001            .275
    A003 12/4/1999  12/3/2001           .260
    A003 6/3/2000   6/3/2002            .257
    A003 5/3/2001   5/3/2003            .247
    

    The period_starts are not quite what you posted, but, if I understand you correctly, you don't mind that.
    There should be no problem of partitioning an additional column.

  • The value of the seed of the generator of random numbers in Matlab node

    Hi all

    I need to use random variables inside a Matlab Labview Commsuite node. I generate with the randn() function. Is it possible to put the seed of the random number generator such as the random numbers are reproducible?

    Hi Steve,.

    You can use randn ('seed', seeds) to initialize the random number generator. The seed must be a positive integer value. For example, randn ('seed', 3). In addition, this seed is global within the entire application. This means that if the randn() function is called MathScript multi-node that could run in parallel, random results are not guaranteed to be the same after you change any part of your code. But you should always get the same results for repeated passages of the same code.

  • How the random numbers will be generated

    The "dice" in LabVIEW function is ised to generate random numbers between 0 and 1. If I create a [100000] array with random numbers between 0 and 100, the appearance of 1 to 100 is the same (about 1000 times each), but the appearance of the 0 is only 500.

    So my question is, on the basis of which will be generated random numbers?

    Mitu salvation,

    It is not a problem of the RNG, it's a problem of your function rounded!

    "To U8" allows you to convert the entire random DBL. ToU8 rounds up to the next integer. So all the number of 0-0.5 will get rounded to 0, but all the numbers from 0.5 to 1.5 will get rounded to 1. If you have twice the range of a number rounded to 1 at the beach of rounding to zero - the same goes for your "end of range" with rounding to 100. 100 should be also less likelihood (in your VI) to appear...

    To get the same probability, you should (explicitly) roundpupils before converting in U8!

    BTW. You can also search the forum to get the same answer by searching for "random"...

  • I'm trying to generate a table of random numbers 30. After each 5 readings a new vi must open and indicate to the user than 5 readings were made. and continue with the generation of the table again.

    because I don't have a sensor now, I am currently generating a table of random numbers 30. After each 5 readings a warning should be given to the user 5 readngs are completed. This cycle must be repeated. the size of the table is 30.

    Please help me, waiting for response as soon as possible.

    Once I have the transducer, I'll take 30 analog samples and then after each 5 smaples this wraning will be displayed din a new VI

    Use a while loop with a delay time representing your sampling interval.

    Use is equal to the count Terminal to see if 4, then 4th iteration = 5th sample.

    Use a box structure. The real deal will only run on the 4th iteration.

    In the case of true place a Subvi with your message of your choice in the front panel. Go to the properties of the VI window and set ' open the front panel when it is called.

    The condition to closing of attention is not given to your description.

    Consider that rather than usign a Subvi to do this, you can use the "dialog box one/two/three button" or "display message" live in the palette "user interface and dialogue."

    Please try it out and send your own VI. Do not provide us with a working solution.

    Kind regards

  • Division of random numbers, see if the result is an integer.

    Simple and yet impossible to find an easy way around it.

    I have 2 RANDOM numbers, I'm dividing them, and I want to see if the result is an integer or not. Basically, I need to know if the divison of random numbers 2 is an integer.

    Who wants KUDOS?

    /SPAW

    Use Quotient and remains, check if the remainder is 0.

  • I want just a bunch of random numbers (about 120 of them) from the list, select 'all' and get the computer to rearrange in CNC

    I try both notepad and wordpad. I'm in Winows XP 2003.  I want just a bunch of random numbers (about 120 of them) from the list, select "all" and reorganize in order digital computer. I can't understand how I've done it before. Google says select the balls feature, but all that is put a point in front of a certain number. There is no arrow down to select. No A - Z. No 1,2,3. what Miss me? is the Notepad or wordpad not the place to do that?

    Use Excel.

  • Gmail button (in internet explorer) keeps having moved to the right in my taskbar when I wasn't staying on the left (that's why I first open). How can I get the taskbar buttons to stop randomly to reorganize and stay in order?

    Gmail button (in internet explorer) keeps having moved to the right in my taskbar when I want to keep it on the left (that's why I first open).  How can I get the taskbar buttons to stop randomly to reorganize and stay in order?  I'm talking about the buttons on list of my open applications and documents in Windows Vista.  The bar tasks are "locked", but the button of the window open with gmail in internet explore reappears suddenly in the good moments apparently random.

    It is in the middle part of the taskbar (what I found online so far is on the start menu, the quick launch area or area/system tray of notification, the location of the taskbar in full, either about grouping taskbar - I disabled because I would like to separate).  Can anyone help?  I don't understand why this is happening (or why microsoft would never do).

    Lock the taskbar that it prevents to be moved elsewhere on the office and maintains the different sections where they are - it does not block the tabs showing what is open where they were when they were opened.  There is no control for this function.  Maybe if you uncheck similar taskbar buttons group it will help, but I honestly don't know (and fear he won't make any difference - it may even make things worse).  This also happens to me and I was unable to find an answer.  I think that there are more than just random, but I can't telll you why he moves the legs periodically (sometimes it works fine all day and other days it happens almost immediately).  But still, there is no control for this function, so there is no way to tell him to keep a specific order or to lock an established order, once it has been created.  I suspect that it happens because the notification area icons appear and hide and new programs open and close and which changes the amount of space available and so he rearranges things so that they match and apparently does not always consider the original sequence in which the elements have been added.  Maybe if you remove the Quick Launch toolbar and then add again, the order will reset (but that I know not - probably not in the original sequence, which I doubt is logged nowhere - it did not work when I tried it).

    Unfortunately, I don't have a solution to this problem (and I spend a little time looking for even before myselff posed the question) and do not believe that there is a.  It is also unfortunate that you can't move them so they can be put back in the right order if they change.  I don't think that there is nothing wrong with your system or that it is something that can be repaired or fixed - it's just the way it is and we just have to live with it.  I don't know any 3rd party software that controls the order of tabs open in the taskbar program (but you can check out Bing, Gooogle,www.tucows.comand www.download.com to see if I'm wrong on this - here n "t all when I looked trying to solve this problem for my own system).

    I'm sorry it wasn't what you wanted to hear, but it's like that.  I don't know if it's different in Windows 7.

    Good luck!

    Lorien - MCSA/MCSE/network + / has + - if this post solves your problem, please click the 'Mark as answer' or 'Useful' button at the top of this message. Marking a post as answer, or relatively useful, you help others find the answer more quickly.

  • moving averages

    I have a file (excel) which has 11,12,13,14,15,16,17,18,19, 20, 21, 22, 23, 24, 25, or no matter what random numbers in no particular order.

    I have a bearing everytime calculation that reads the file. for example.

    Add the first 5 digits in the file and divide by 5, then place the first number and move one to the right and get the number following 5 and then divide it by 5, etc.

    (11 + 12 + 13 + 14 + 15) / 5 = 13, the first time, he reads then file the first number and move one to the right (12 + 13 + 14 + 15 + 16) / 5 = 14 then (13 + 14 + 15 + 16 + 17) / 5 = 15.

    Can anyone help please?

    There are many examples of functioning / moving averages on this forum. But I don't remember them ever called rolling average. So you might want to search for running or moving average.

    A recent thread started by comes me to mind.

    The simplest example I saw while loop with shift registers, especially if you do not need to change the size of the sample running.

  • Medium-sized random numbers

    So what I need to do, is to generate a series of random numbers. I've got that.

    However, the tricky part is that I need to average the random number and the previous 3 numbers random and exit on a waveform graph.

    Any help or pointers would be great. Thank you

    Simple as pie. He called a VI means Pt by PT. set your buffer to 4 and it will be an average intensity absorbed with the last 3.

  • How to speed up the attached average.vi 'weighted '.

    Hello

    I would be grateful if someone could give me some suggestions which would accelerate the Attaché "weighted average.vi. It takes 30 seconds to run to the 'data.tdms' attached to a Core 2 Extreme CPU [email protected], LabVIEW 2012, computer Windows 7 and 20 seconds on an i7 CPU [email protected], LabVIEW 2013 computer, Windows 7.

    The weighted average.vi calculates a weighted average for each group, for example "2325E", "2350E,". "R" means repeat. Number_of_Stacks is 32 for all groups with different numbers of repetition in the joint "data.tdms" and will be a different number in the future data.tdms.

    Thank you very much

    Steve

    Well I'm still not fully what he does, but I managed to improve by 10% or more.  My attempt is attached.

    Model functions are external modules and are much slower for simple tasks like a search.  The search string Split is roughly the fastest method based on most of the cues.  It can be improved by right-clicking and choosing Match one character if possible and one of them is.  I moved the initialization of the outside loop 2D table.  No need to make a new one each time.  I also changed the data type of a waveform in a 2D double table.  It seems that it is wha tyou want anyway.  I tried also to defragment the file first, but the file is not very fragmented and it took actually longer after the addition of that time.

    To be honest, there are a lot of data.  It will take just so long to blow through it.  Is it possible that you can do this while the other treatments occur, to trick the user into thinking it takes less time?

    There are a few other improvements you might be abel to go out with, if you increase the complexity much.  You can have a fast computer, but using only 1 core with this code.  If you can find a way to turn the loop parallelism you should see a lot of improvement.

    Edit: I have also disabled the automatic error handling and enable debugging.

Maybe you are looking for

  • Equium A100-147 - Native resolution on the external LCD display does not work

    Hello My Equium A100-147 has 1 VGA and 1 S-Video output, so I use the VGA output on an external LCD monitor with a native resolution of 1680x1050@60hz, but integrated graphics Intel 945 card doesn t give me the correct resolution to choose for this m

  • Analog DAQmx read with offest

    In the test, I'm trying to Setup, I need to record readings of load with the subscribed initial charge.  I take the initial read and who then subtract all of the following readings. I have a pre-load of 50 lbs, I want all surveys carried out during t

  • Video/HD Audio drivers of Lenovo T410s

    Hello I am currently installing windows XP Pro on a new computer laptop Lenovo T410s 2924 - A55 and I got 3 unknown devices that I can not find drivers to work. 2 of them are video controller (VGA Compatible), I tried to install all the drivers throu

  • Windows vista update 80246008 error code

    Windows vista update 80246008 error code

  • How to make a transparent gray screen

    Simliar to that of Director of office of BB, I need to make a transparent gray screen - all things in the background are visible, but when they are hit, nothing happens. Actually, lock screen for a while. Suggestions/pointers are appreciated.