10-02-2023 02:16 PM
Hello,
I am working on this program to display the Max value from a waveform graph and display the previous 4 values. Some issues I am having is displaying the previous values on the front panel and getting the values to hold/stay until the program is ran again. I have played around with arrays and strings but could not get the value to hold or display the previous value. Some examples I have seen use the array Max and Min or the Waveform Max and Min, not sure which one wires everything correctly to do what I want it to do. I have tried multiple different ways to go about this but I feel I must be missing something ever so important. I have displayed below what my block diagram looks like and what each case structure is wired to. This is all in a While Loop just fyi.
Also, if there is any suggestions in simplifying this program please let me know! I am open to trying different things as I am beginning to learn LabVIEW more in depth.
Thank you.
10-02-2023 03:25 PM
Please attach your VI instead of pictures. To retain data between runs, you need e.g. an uninitialized shift register.
What do you mean by "previous 4 values"? The last four max values? The last four values in general? A chart with a 4 point history? How does the front panel look like?
I don't think you need any case structures!
10-02-2023 03:45 PM - edited 10-02-2023 03:46 PM
Here's a quick draft to show data, min and max on a chart. Maybe it can give you some ideas.
If you want to retain data between calls (only meaningful during debugging!) You can use an uninitialized shift regsiter and some extra code.
10-06-2023 02:01 PM - edited 10-06-2023 02:09 PM
I have attached the VI below. Let me know your thought! I am looking over your other min and max suggestion. Yes, the previous 4 max values is what I would like to display. Preferably in a value form instead of a graph.
10-06-2023 03:26 PM - edited 10-07-2023 09:16 AM
Wow, your code is convoluted!!!
Why use local variables if you could connect to the terminal right there??? Completely pointless. Why are there terminals without labels?
Where is the array with the max values? Why not label is as such?
Don't wire a +inf for the sample length of the ptbypt minmax. Look at the help and wire a zero if you want what you apparently want. There is no "inf" for integers so it will get coerced to 2^32 and you'll eventually run out of memory!
Correctly done, you code should fit on a postcard!
I am not going to even try to debug your code, but here's a "code miniature" that keeps an array of the last four max values seen.
The shift register should be anchored on the toplevel loop. There is no need for inner loops!
(Note that the code could be slightly simpler if you want the maxes in a different order. We can't really tell how you want it)
10-09-2023 09:28 AM - edited 10-09-2023 09:29 AM
Thank you for helping. I did say I was a beginner and just starting out in this program. I will do some more work to see what I can do to condense it as well as make it more efficient.
10-10-2023 01:27 PM
So I took your suggestion and rewired by code to fit the previous max values. However, the two issues I keep running is 1.) When the While loop is outside of the main while loop, the averaging graphs and max values do not generate, 2.) When I make the while loop to a for loop, the max values keep resetting to zero and do not store the previous values. Please let me know your thoughts. I've attached my new VI below.
10-11-2023 01:05 PM
@A1777 wrote:
So I took your suggestion and rewired by code to fit the previous max values. However, the two issues I keep running is 1.) When the While loop is outside of the main while loop, the averaging graphs and max values do not generate, 2.) When I make the while loop to a for loop, the max values keep resetting to zero and do not store the previous values. Please let me know your thoughts. I've attached my new VI below.
No, this is still all wrong! For example why would you take a waveform, make it into an array of waveforms, get the fire waveform (getting you back to square one!) You still have these silly local variables. Wiring [i] to N is completely pointless.
You array of maxes needs to be anchored on the outer while loop, of course.
10-11-2023 01:23 PM
10-20-2023 02:36 PM
Okay, I have simplified my program and made it more efficient. It's doing what I would like it to however, is there a way to get the last 4 max values to hold until the next value without putting a while loop? For example, when I bring the while loop outside of the while loop I am working in, the values do not generate but when the while loop is inside the other while loop it does not run at all. So what I have done is gotten rid of the while loop and just left the for loop and its working properly. I just want to know how to not reset the last 4 max values.