07-12-2011 02:59 AM
Hello, I'm a student, doing my final year project with my team, and we are encountering some problems.
Right now, we are trying to find the extinction ratio.
From the screenshots below, you can see my block diagram and front panel.
We need to find out the maximum point and the minumum point, to find out the extinction ratio.
My team, we have tried using the 'Statistics' VI, found in LabVIEW itself, but however, it only gives us the value of the last reading, which is not what we want.
Perhaps, our connection is wrong. We don't quite understand where the 'Signals' connection should be connected to.
We tried to connect the 'Signal' to the 'XY Graph', but there would be error if I do so.
So, my question, is simply, how can I get the maximum AND minimum value from the XY Graph?
The following screenshots are from my team's project, and for your reference.
We really need help.
Front Panel:
Block Diagram:
07-12-2011 03:25 AM
As always on the forum, it would help if you attached your vi, not a picture.
Here is a hint to get you going... as this is a school/uni project I think it is better to give you hints rather than answers.
The reason you only get the value of the last reading is that you are only feeding the blue 'statistics' express vi a single number. I can tell this because the wire going into it is 'thin'. The max and min of a single number is of course that number e.g. what is that maximum and minimum number in "10"? The answer is "10".
You need to determine the max/min of an array (which would be a thick/bold wire)i.e. max/min of a set of numbers rather than of a single number.
Try looking into ways that you can track the max and min values within your while loop, or at ways of building an array that can be analysed after the loop exits.
If you have more questions... ask away!
Ian
07-12-2011 03:36 AM
Thank for your tips, Ian.
Tried moving the Statistics VI into the while loop, but to no avail.
Do you have more 'tips' or examples that might assist us further ?
07-12-2011 03:49 AM - edited 07-12-2011 03:51 AM
Even inside the loop, you'll still be trying to analyse a single number.
Shift registers can be your friend here. Consider either:
On each iteration of the while loop, compare the latest value to a stored max/min. At the end of the loop you have your answer... no other vis needed.
On each iteration of the loop, add the latest value to an array. At the end of the loop you can feed the array into a some form of analysis. NOTE that this method will run slower as LabVIEW has to handle the memory requirements of building the array. If you are taking lots of data this could be a really bad plan!
Get your head around the 1st option above and see how you get on. As an example see the image below (trivial to change for min value)...
(I may have just given you the answer rather than a hint - but I'm about to leave the office for a few hours so don't have the time to think how to hint!)
07-12-2011 04:24 AM
Dear Ian, I've tried the method you suggested, and it still returns the last value.
However, my loop is a little different.
As you can see from the picture above, I didn't get the max value DBL that you've got, but just an indicator.
I tried to connect the PINK XY GRAPH connector to the while loop, but it gave me an error.
So, I tried to connect back to the Y value, which is what I really need to get, and it still return me with the last value from the graph.
A little assistance please.
Thank you.
07-12-2011 04:32 AM
Hi PotatoMan,
"a little assistance"
Well, you were asked before to attach the vi instead of a picture!
And you still try to get the maximum value from a scalar wire, i.e. the maximum from a single value... And you already have a subVI that is calulating averaged data - why don't you include the min/max search in there?
07-12-2011 09:26 AM
As GerdW says, you've missed the point about single numbers vs arrays.
Take a few moments to understand the code that I posted and how it might be used. You shouldn't just copy the code I posted and stick it onto the end of yours... you need to integrate it into your existing while loop, or as GerdW suggests, integrate it into your averaging sub-vi.
If you still don't understand the scalar vs array thing, try to ask a question that will help us explain in a suitable fashion.
Ian
07-12-2011
09:32 AM
- last edited on
01-21-2025
04:43 PM
by
Content Cleaner
There is also the Array Max & Min PtByPt function which does all the work for you. (Reset if [i]=0) Try it. 😄
07-12-2011
09:22 PM
- last edited on
01-21-2025
04:44 PM
by
Content Cleaner
Hi Potatoman,
I believe you are not yet familiar with how a tunnel works. The tunnel is the solid square (in your case an orange one) that you see when you try to input/output data into or out of a structure. However, the limitation of a tunnel is that it only outputs the last value from the last iteration when you use it in a while loop, similar to what you have. This is why there is what we call auto-indexing. refer to this for more info: https://www.ni.com/docs/en-US/bundle/labview/page/processing-individual-elements-in-an-array-or-a-co....
Also, you should not add while loops needlessly, especially infinite loop ones, to your block diagram. If you can achieve the same functionality with the while loop that you currently have then that should be good enough.
Hope this helps you find a solution to your problem.
07-12-2011 11:10 PM
Thank you everyone for your 'tips' and 'advice'.
I've managed to get the maximum and minimum value, using the same method, but into my very own while loop.
I used the connection Y value and made the same connection as shown below.
THANK YOU ALL! :D:womantongue: