10-04-2024 04:53 PM
Hi all,
I am trying to build a VI where I am displaying voltages and current on a waveform graph.
I want to reset the waveform graph by clearing the data every 5 min.
I need a way to clear the the data on the waveform graph after every 5 min. So the data doesn't get crowded on the graph as the VI will be running for a long period of time.
Other issue I am having is that the new values that get sent on CAN are getting plotted on the left side of the graph.
As a standard graph would update values on the right side, this is not the case.
I am attaching the part of the VI below. Can someone please help me out with this?
10-04-2024 10:23 PM
When you are trying to figure out your display, decouple the display question from the rest of your application - same when you post to the forums.
Do you want your graph to clear every 5 minutes, or do you want the display to show that last 5 minutes of data?
If you want to clear the data, you can append new data to existing data and display on graphs. Every 5 minutes, don't append, just replace the existing data with new data.
If you want to display the last 5 minutes of data, replace your graphs with charts. Configure the Chart History Length to 5 minutes worth of samples. AutoScale X to make the chart automatically scroll once the chart history has reached 5 min.
10-05-2024 10:19 AM - edited 10-06-2024 09:40 AM
Your code is highly flawed with unnecessary sequence structures, complicated constructs (e.g. how you parse the data) and way too many local variables (causing race conditions). The diagram that is way too big to efficiently debug. It is incorrect and unnecessary to reset all to default at the end. If things need to be initialized, it should be done at the start of the program. Your orange shift register is not initialized, so the contents will grow forever in consecutive runs.
It is rare that voltage and current values are integers, so why is most of your code blue??? No, there should not be any dynamic data anywhere!
It is extremely hard on the memory manager if you prepend new data to existing arrays. Appending is much more efficient. It would be sufficient to have a single shift register with a 2D array to hold all data. Keep it simple!
A graph is just a passive indicator for whatever data is held in the shift register.. You built your arrays there, so all you need to do is manipulate the contents.
If you just want to chart the last N values, all you really need to do is use a chart instead! Charts have a scalar input (among many other possibilities) and have a fixed history where the oldest values are dropped once the history buffer is full. No shift registers or arrays needed.
10-06-2024 09:09 PM - edited 10-06-2024 09:19 PM
Hi Doug,
From now onwards I will keep in mind to not integrate two questions in a single post. My apologies for the same.
To be specific, I want to clear the data after every 5 mins as I want a limited number of sample points on the graph at a given instant. Just so I can visually display the plot more distinctively focusing on each sample.
This VI will be running continuously for hours. So, I don't want a user input to stop and start the VI each time to clear the graphs for the same reason mentioned above.
Since this will be real time data, I won't be able to use a chart.
In a waveform graph, could you please elaborate on how replace new data with existing data every 5 mins?
I tried using the History data property but it seems like it is only available for waveform chart and not graph
Thanks for the reply
-Satvik
10-06-2024 11:23 PM
Since this will be real time data, I won't be able to use a chart.
I don't know why real-time data precludes a chart.
Here is a VI that implements the behavior where data is displayed on a graph (cleared every 300 samples) and on charts with different update modes. Each chart is configured with Chart History Length = 300.
10-07-2024 05:54 AM
You do realize, I hope, that Displaying Data is entirely separate from saving data. If your data are coming at 1 Hz, you should have time in that loop to both write the sample to a file and plot it on a Chart. If you make the Chart a
write the datum to a file, (b) plot it on a Chart, perhaps using "Scope" or "Sweep" mode to keep the Chart from scrolling ("Scope" is like an oscilloscope -- after 300 points, it erases and starts over, while "Sweep" starts over, but "auto-erases" the point it is about to overlay). [Note this assumes that the Chart length is 300 points].
Bob Schor
10-07-2024 11:08 AM - edited 10-07-2024 11:10 AM
@Satvikpai wrote:
Since this will be real time data, I won't be able to use a chart.
I don't even know what you mean by that. the word "real time" has often a very special meaning (e.g. LabVIEW RT) and has more to do with time precision than with any specific rate.
Unlike a chart, a graph just blindly displays whatever is in the wire leading to it. History data has no meaning for graphs.
You know the data rate and the desired history time, which lets' you calculate exactly what size of chart history buffer you need to keep exactly the last 5 minutes worth of data.
How fast does the data change and how much noise do you have? You might even be able to do averaging and down-sampling so trends are more easily visible. It is often pointless to have a graph with 10k points on a display that has a much smaller width in pixels.
What is actually interesting for the user to see when looking at the front panel?
You could even do an xy graph that plots current vs. voltage and maintain a limited history in a 1D complex array.