09-30-2016 11:36 AM
Hello NI community.
I built a VI that basically outputs voltage from some maximum voltage to some minimum voltage back to that maximum in n steps (all user specified) and measures an input voltage at each step. This is all contained within a for loop to have multiple scans.
I would like to average the input voltages over all of the scans for each step and display it on an XY graph as the VI runs*. My idea is to have an array built for each step and each time a scan passes through that step it adds to that array. Then I can run it through a mean.vi and display it. I was hoping for advice on how to impliment this. Thank you for any that you guys can give and let me know if there is anything I need to clarify.
*Each scan passes through the output voltages twice but the input voltages will be different for scanning down vs up due to the physics of the experiment so I do not want to average the parts of the scans.
Solved! Go to Solution.
09-30-2016 11:39 AM
Without seeing any code I'd suggest the Mean point by point, or just Mean which takes an array of values that you can keep track of in a shift register.
Unofficial Forum Rules and Guidelines
Get going with G! - LabVIEW Wiki.
17 Part Blog on Automotive CAN bus. - Hooovahh - LabVIEW Overlord
09-30-2016 11:42 AM
I will post the .VI when I get back to the lab later. My issue is that wouldn't I need a separate shift register for each step, because I'd need a separate array for each step?
09-30-2016 11:59 AM
Not necessarily. One option might be to use an action engine, where you can give the new current value to a VI, which holds the running averages for each iteration. Then when you want to get the current average it would be returned from that VI for the specified iteration. Again when I see some code I'd be glad to whip something up.
Unofficial Forum Rules and Guidelines
Get going with G! - LabVIEW Wiki.
17 Part Blog on Automotive CAN bus. - Hooovahh - LabVIEW Overlord
09-30-2016 12:42 PM - edited 09-30-2016 12:43 PM
I assume that the steps are equally spaced and the same for each scan. In that case, a plain graph is sufficient, no need for an xy graph.
Because of hysteresis, you need to create two arrays, one for the up and one for the down. Initialize it with zero and add the new values for each step as it arrives (fill from the back for the downs scan). Divide by the number of scans at the end to get the average for each.
Of course you can also create a single array for each up/down pair and use an xy graph.
09-30-2016 01:17 PM
@altenbach wrote:
Of course you can also create a single array for each up/down pair and use an xy graph.
Here's what I had in mind. Modify as needed (To update each point with the average in real time would require significantly more code).
09-30-2016 03:59 PM
This worked perfectly. Thanks a ton.