LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

While Loop, showing mulitple temp readings

Hi guys. I'm having some trouble displaying multiple readings within a while loop. As you can see from my VI, I have to get an average of the past 10 temp readings which i have achieved. I have to also display those 10 readings. I am trying to display these readings through an array that is set to indicator, but it is showing a broken wire. I may be wrong to be trying this array but I'm not 100%. If anyone has a suggestion on how to display through the array or if anyone has a different suggestion on how to achieve these readings being displayed, ideas are welcome.

0 Kudos
Message 1 of 11
(727 Views)

You have 10 scalars, so you could built them into an array for display. Your algorithm is however not scalable. What if you wan to average the last 1000 readings?

 

 

Much better would be to rearchitect your code by keeping a 1D array of 10 elements in a single shift register and replace the oldest with each iteration.

 

Follow the link in my post here.

 

0 Kudos
Message 2 of 11
(719 Views)

Thank you. I will try that. 🙂

0 Kudos
Message 3 of 11
(701 Views)

(You should not mark your post as solution unless it actually is the solution.)

 

See if this can give you some ideas....

 

altenbach_0-1712096999756.png

 

0 Kudos
Message 4 of 11
(678 Views)

@EDiddle wrote:

Hi guys. I'm having some trouble displaying multiple readings within a while loop. As you can see from my VI, I have to get an average of the past 10 temp readings which i have achieved. I have to also display those 10 readings. ...


An easiest way (probably) is to use the MeanPtByPt (point by point) function, something like that:

10averages.png

 

0 Kudos
Message 5 of 11
(608 Views)

@Andrey_Dmitriev wrote:
An easiest way (probably) is to use the MeanPtByPt (point by point) function, something like that:

Yes, my linked presentation (part II) mentions and compares several possibilities.

(look for slide # 12 ... 14 and code  \TS9524_NIWEEK_2016_PartII\02-TS9524BenchmarkArrays\RunningAveragesTester.vi)

 

I thought his discussion is was more about learning LabVIEW basics and how to display the entire data history. You cannot display an array of history values using "mean prbypt", but that was probably the gist of the question here. 😄

 

If the array should be sorted by age, a rotate&replace would be easy to implement.

0 Kudos
Message 6 of 11
(586 Views)

Something like this?

 

ave10Capture.PNG

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 7 of 11
(565 Views)

@RTSLVU wrote:

Something like this?


Yes, that's what I meant earlier

 


@altenbach wrote:
If the array should be sorted by age, a rotate&replace would be easy to implement.

We have to be careful not to move all elements in memory all the time, but I think the compiler will optimize it by just marking the rotation index if everything is wired correctly. (I don't see it as "subarray" in the context help, so I am not sure.) Alternatively we could just replace the oldest element and rotate for display.

 

I also think it is better to give an average of the partially filled array (as in my code) instead of outputting NaN for the first 9 iterations, but that depends on the problem.

0 Kudos
Message 8 of 11
(558 Views)

A lossy queue works well for this. 

aputman_0-1712169755573.png

 

aputman
------------------
Heads up! NI has moved LabVIEW to a mandatory SaaS subscription policy, along with a big price increase. Make your voice heard.
0 Kudos
Message 9 of 11
(541 Views)

@altenbach wrote:

@Andrey_Dmitriev wrote:
An easiest way (probably) is to use the MeanPtByPt (point by point) function, something like that:

Yes, my linked presentation (part II) mentions and compares several possibilities.

(look for slide # 12 ... 14 and code  \TS9524_NIWEEK_2016_PartII\02-TS9524BenchmarkArrays\RunningAveragesTester.vi)

 

I thought his discussion is was more about learning LabVIEW basics and how to display the entire data history. You cannot display an array of history values using "mean prbypt",


You're right, Christian, I've read this question very quickly and was under assumption that the trouble with averaged array's visualization, otherwise we need buffer, of course.

Thank you for the presentation, very nice. The only small point is — you stated that "all code variations are tested to give identical results". The results are almost identical, but not exactly identical, because floating-point additions are not associative, threfore the averages will be slightly different (and in two ways proposed above as well), usually not critical for most applications.

0 Kudos
Message 10 of 11
(532 Views)