LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Using Mean PtBy - Giving odd results when used in shift register

Solved!
Go to solution

Just wondering if anyone could possibly point me in the right direction, I know I am misunderstanding how the MeanPtBy.vi interacts in a shift register.

 

I am inputting an indexed array into a shift register to place through a "rolling average" and expecting an average. As the numbers in the array at present are static then the output should = the input array?

 

Would any one have any suggestions?

 

Alex902_0-1747234261644.png

 

0 Kudos
Message 1 of 8
(257 Views)
  • I don't see any shift register in your picture or VI
  • Why is the "length" terminal inside the FOR loop? Do you expect it to change between iterations?
  • Place a reasonable wait inside the loop. No need to burn the CPU spinning the while loop millions of times per second.
  • Ptbypt VIs should be initialized on first run, else they remember old data. In your case you could init if [i]=0 for the FOR loop.
  • In your VI, the input array is empty and the length is zero. It would help to set reasonable defaults before attaching. We don't know if the length is less or more than the array size.
0 Kudos
Message 2 of 8
(250 Views)

Hi Altenbach,

 

Thank you for the reply.

 

I have made all of the suggested changes, reason for the not having the shift register was I have copied the code from my main program which had data, the blank array was me forgetting I hadn't set a default.

 

Please see the below and/or code.

 

I would be expecting the output to be 5,10,15,20 Not 5,7.5,10,12.5.

 

Alex902_0-1747238043301.png

 

0 Kudos
Message 3 of 8
(232 Views)

Cannot look at your VI (next time, do a save for previous, 2020).

 

You need to start with some basic tutorial, for example Rube Goldberg code such as the following is just plain silly:

altenbach_0-1747238904265.png

 

 

Your array control is outside the loop, so the value in the shift register can never change, no shift register needed.

I cannot tell the size of your input array (container size != array size)

0 Kudos
Message 4 of 8
(224 Views)

@Alex.902 wrote:

I am inputting an indexed array into a shift register to place through a "rolling average" and expecting an average. As the numbers in the array at present are static then the output should = the input array?


No. It should be the same result every time, that's true, but not the same as the input array.

Yamaeda_0-1747239467707.png

 

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 5 of 8
(218 Views)

Your array only has four points, so doing a five point rolling average seems pointless.

 

See if this can give you some ideas...

 

altenbach_0-1747239797209.png

altenbach_1-1747239808663.png

 

Message 6 of 8
(214 Views)

Thank you,

 

I see what you are saying although I have explained myself badly.

 

I am trying to make an array of constantly (in the main program) updating data and rolling average each column in the array with the next piece of data.

 

so in this instance it would be repeating 5,10,15,20. So averaging 5 five times 10 five times etc.

 

I don’t want to average the array instance itself but each individual number in the array with the next iteration from the loop that replaces the existing number.

 

Your example I think creates 200 random values feeds into an array then plots a rolling average of those values. In my example you would be feeding in a 2d array with 4 columns each of 200 values however I am looking for the average to be rolling dynamically as the data is acquired.

 

In my example I am just using the same digits looped rather than changing them each iteration to ensure the code worked.


as a practice example when doing a temperature calibration if doing 4 probes at once (due to being able to place 4 temps in a dry well against a reference) I would like the values being displayed to the user to be a rolling average of the data being acquired.

 

really appreciating the help.

0 Kudos
Message 7 of 8
(161 Views)
Solution
Accepted by topic author Alex.902

You would need one PtByPt VI for each channel.

 

 

snip.png

 

 

 

Alternatively, roll your own averaging using e.g. exponential smoothing


exponential smoothing multi channelexponential smoothing multi channel

Message 8 of 8
(111 Views)