09-19-2012 09:44 AM
Hello and thank you for any help in advance.
I have a program that monitors a distance sensor and displays the current distance dynamically while the program runs. There are several points that I would like to be able to move the distance sensor to, click a button, and store the distance at that point. So far, the current value displays correctly, but I'm not able to make the button perform the action of grabbing the last, say 10 samples, and average them, and store the data as a value. I was trying to use the "extract portion of signal" vi, but I don't know how to tell it that the start point is the exact point at which the button is pressed. Also, I'm pretty sure there is a better way to do this, but I'm drawing a blank, so I figured asking here would be a good start.
My buttons right now just shows a running average of the data while the button is being pressed. What I want is, click button > current value is stored.
I've searched for a solution to this and just haven't found one that worked, probably because I'm not asking the question right.
Thanks again,
Justin
09-20-2012 09:12 AM
Hi Justin,
I believe what you are looking for here is an event structure. These can be configured to be triggered on the button press. I have some links that could be useful for a start on how to use event structures. Please let me know if these work for you.
http://zone.ni.com/reference/en-XX/help/371361J-01/glang/event_structure/
http://www.ni.com/white-paper/3331/en
Further to grab the last 10 samples, you'd want to store the last ten samples somewhere (say an array), and push out older samples. This link may give you a few ideas on how to implement this: