04-14-2011 08:59 PM - edited 04-14-2011 09:01 PM
Calculating the Average with this logic!
a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 values
A9^=Summation (a0 to a9)/10
t0 t1 t2 t3 t4 t5 t6 t7 t8 t9
a0* a0 -> a1-> a2 a3 a4 a5 a6 a7 a8
A9^=Summation(a0* to a9)/10
Please let me know how can I create it.
04-14-2011 09:13 PM
Your description is a bit unclear and has lots of duplicate or missing information, but maybe you can use mean ptbypt or make your own. This should give you some ideas.
04-15-2011 02:00 AM - edited 04-15-2011 02:01 AM
Hi,
What you need is a Moving Average Filter. It's pretty simple and easy to be done.
Take a look in the attachment.
Paul
04-15-2011 02:36 AM
Thank you for sharing the info.
I tried to develop the VI based on the logic but unable to attain all conditions.
In my VI attached:
1.How can I introduce time factor like 1, 2, 3, 4....ms as an array?? I need counting generator to be attached to the sample time, t0,t1, t2...t9
2. Array received from AI is giving only value per channel?
3. The case structure is not considering other cases just averaging simply, how can I give the condition.
Finally I will save all data as a file.
Please give your comments, sugestions & modifications.
04-15-2011 03:07 AM
Hi,
I'm not sure that I understand exactly what you want to achieve.
1.How can I introduce time factor like 1, 2, 3, 4....ms as an array?? I need counting generator to be attached to the sample time, t0,t1, t2...t9
You want different sampling times for each read? For example first read after 1ms, second after 2ms, third after 3ms and so on?
2. Array received from AI is giving only value per channel?
I've noticed that you read 2 channels in parallel (AI2 and AI3) but only one sample (from each channel) at a time. Do you want to read more than one/channel? This is what you meant? You can use N Channels / N Sample 2DBL. You have to specify the number of samples and at output you will have a 2D Array (Channels x Samples/Read).
3. The case structure is not considering other cases just averaging simply, how can I give the condition.
I see no reason for having the second (inner) While loop. If you want to change from Average to Average New get rid of the second loop (as I said in this configuration has absolutely no function) and Change the Enumeration Constant (Average,..) in Control Element.
Please make it more clear what you really want to do with the values read from the Analog Input? First I thought that you want to filter (using average) the voltage from one channel, but you make you filter the voltage from two different channels.
I've attached a modify version of your VI of what I think I understood that must be done. (PS: It's draft, there are many things that must be improved - like sampling rate. It's not recommendable to be done as delay in the while loop).
Paul
04-15-2011 04:19 AM
Thank you so much Paul. Yes I need to use AI values and N channel, single sample.
I have modified my VI with more concepts and adding your concept.
In my VI:
1. I have 2 stops. How can I control my VI?
2. How can I add the sample time from 0, 1, 2,...10ms?
Please see the attached.
04-15-2011 04:40 AM
Hi,
In the vi you can see that after each read the Loop Delay increases with one step. There is also a block that limits maximum delay time. You can modify it.
If you want to use one stop for both loops you simply have to delete one and to connect the outer while loop stop to the inner one.
Rgds,
Paul
04-15-2011 08:46 AM
Thank you Paul!
Saturation concept is new for me, it seems good for adding a delay.
But I wish to connect some simple counter or a short VI function which automatically generates the simple counting 1, 2, 3, 4....as a control to the timer,
04-17-2011 05:59 AM
I have introduced the simple counting for the sample time in my VI but the loop doesnt move again, it iterates only time but I want iterate till the count of 10.Please see the attached.
04-18-2011 05:03 PM