04-27-2011 10:09 PM
I am sort of stuck on basic architecture, so, hoping you can nudge me along.
What I have is a VI that measures voltages continuously, so, I have a stream of voltage data points coming in from a DAQ device. What I WANT is to act on those voltage data points, only, which are larger than previous points. For example, I want to act on the very first data point, since it will be the largest, since there is nothing else to compare to, then, I want to compare the subsequent data points to the first one, until there is a data point larger than the first one. Then, I want to compare voltages to the NEW largest value, and so on and so on, and only act on the NEW largest value.
Consider this list of data points and the corresponding desired outcome:
2 -ACT
4- ACT
3- DO NOTHING
3- DO NOTHING
4- DO NOTHING
5 -ACT
4-DO NOTHING
5-DO NOTHING
4-DO NOTHING
3- DO NOTHING
6- ACT
I have been looking at combinations of FOR and WHILE loops and shift registers and arrays, but, the array would get so huge so quickly, and the MIN/MAX value function from the ARRAY palette would get pretty slow, and I don't need to evaluate all the earlier data. I just need to be able to identify the largest value, and then compare it to subsequent values until there is a NEW largest value. It's kind of like the way warriors would fight several opponents until they lose, and then, there is a new champion, and all subsequent warriors are compared to the new champion and so on and so on.
Do you have any suggestion for how to achieve this? I am stumped.
Thanks,
Dave
Solved! Go to Solution.
04-27-2011 10:21 PM
If I understand what you're trying to do correctly, this will work:
04-27-2011 10:47 PM
I would use a functional global variable to store your data. Place the fgv in a vi by itself and drop it in to your main vi. Use and enum to either read from or write to the fgv. The fgv will be used to store your highest value. When a value is measured, read the fgv and compare it against the measurement. You can use a case structure to store the results back to the fgv if the new measurement is higher than the stored measurement. I've done similar things with my own projects. FGVs work very nicely.
The attached snippet is of a general vi architecture, very basic, but is should give you an idea of how a fgv works.
I hope this helps.
Reese, CLAD
04-28-2011 09:22 AM
Hi Thanks a lot. I will try this. Can you just confirm for me...
1.) The box labelled "DAQ" is your representation of my existing data aquisition system. Is that right? There is no "DAQ" function on the tools palette, is there?
2.) Does the zero on the left of the shift register initialize it to zero so that the first data point is being compared to zero, which would force the first value to be my "LARGE" value?
If this works, then, you have really bailed me out!
Thanks again!
04-28-2011 09:28 AM
Yes, the "DAQ" box represents the source of your data [the diagram assumes that the data is read out as a single number--use an array if it reads out multiple channels]. Your interpretation of the 0 is also correct, but you'll have to use -infinity if your DAQ will be reading negative numbers.
04-28-2011 10:21 AM
Just curious about something. You suggest running the output from the COMPARISON function into the CASE STRUCTURE and then out of the CASE STRUCTURE to the SHIFT REGISTER. Would it also work to run it outside the CASE STRUCTURE directly to the SHIFT REGISTER. Of course, I'd still have to send it inside the case structure for the PERFORM ACTION step, but, is there a need to output it from the CASE STRUCTURE to the SHIFT REGISTER or will either path to the SHIFT REGISTER work equally well?
04-28-2011 11:25 AM
Yes, either case will work, I put it in the case structure just to show that you'll need to put it in there if you want to use it.
04-28-2011 11:37 AM
Have you looked at the Producer / Consumer Loop architecture?
04-28-2011 11:48 AM
If he is just acquiring voltages, for such a simple application, he probably doesn't need to make use of queues.
Reese - Clad
04-28-2011 12:03 PM
From the original post
"What I have is a VI that measures voltages continuously, so, I have a stream of voltage data points coming in from a DAQ device. What I WANT is to act on those voltage data points, only, which are larger than previous points. "
With the Producer/Consumer Loop arrangement, he will be able to scale the same solution in the future..
Or to adapt to higher rates of acquisition.