LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

clear graph programatically

Hi guys,
 
I know i can send empty array to history (or vaule in the case of graph)  property node to clear graph programmatically. But it seems does not work with my application.
 
I have got a large array of 8 bit binary data coming in from my FTDI FT245 FIFO convertor at quite high rate,  i wish to display 102 of them on a graph at a time. So after the first 102 byte data has been displayed on waveform graph, the graph clears itself, then display the next 102 byte data and so on.
 
My attempt is to use a for loop with N = 102 and connect that to waveform graph. I then use case structure to clear my graph once the N = 102. There must be something wrong with my program as what the vi dose is it only display the 1st 102 byte data on the graph, then it just stops.
 
I have attached part of vi file below. For simplicity prupose, i have changed N = 10.
 
Just one more question, is there anything in labview which waits for certain period of time for data coming in (like time out), if no data has come in during that period of time, it display the previous data on graph.  
 
I am quite new to LV and your help would be greatly appreciated.  Thanks in Advance.
 
Kim
 
 
0 Kudos
Message 1 of 9
(3,796 Views)

You need to "think dataflow"! 🙂

Your graph clears just fine, bu one nanosecond later, you read the same old data from the input tunnel and send it again to the graph.

Here's one possible way to do it.:

Unlike charts, graphs have no history data and will just graph whatever is in the array coming in. There is no need to clear, just send a new array and it will replace the old data.

 

Message Edited by altenbach on 09-23-2007 10:27 AM

Download All
Message 2 of 9
(3,777 Views)


@0401061296 wrote:
Just one more question, is there anything in labview which waits for certain period of time for data coming in (like time out), if no data has come in during that period of time, it display the previous data on graph.  

A graph retains its data until new data arrives, so there is no need to constantly update with the same old data. You should simply make sure that your loop only spinf if new data is available, there is no good reason to spin a loop if all it does is reprocess the same old data.
0 Kudos
Message 3 of 9
(3,783 Views)

Thanks for your vi file and it is really helpful.

 

I have noticed that your file only works fine when the size of incoming 1-D array is constant and an even number.  However, when the size of incoming array is variable, the remainder from the remainder-quotient function is non-zero therefore there will be some loss of data that is displayed on the graph. 

 

For example, when we set the N =95 (the size of array) and 10 elements of the array  should be sent to the graph, this will result a remainder of 5 and the waveform graph will only display the first 90 bytes data, and miss out the rest 5 bytes data..

 

For our application, the size of array changes all the time and new data keeps coming in. If we update the starting index value periodically and dont delete the previous data which has been displayed on the graph,  it will eventually overflow the buffer.

 

Is there anything we can do to destroy or remove the part of the array elements which have been displayed on the graph previously, and shift the rest of the array elements down so that the total size of the array will be kept relatively small and does not overflow the buffer?

 

Thanks in Advance.

 

Kim

0 Kudos
Message 4 of 9
(3,718 Views)

Everything is easily possible, you just need to know what you want. 🙂 My example was very simple and shows that an graph does not retain history data. If it receives variable amounts of data, the graph will show variable amounts.

You can for example use a chart display. You can set the history lenght to the number of points you want to display in the chart. Incoming arrays will be appended to the existing graph and older data (exceeding the history lenght) will drop out. In your case you can right-click and set the history lenght to 102. You can also change the update mode as needed. (top code on example).

If you want to use a graph instead of a chart, you can keep a buffer in a shift register where you would move data in as desired (using replace array subset)  and keep track of the insert point. Initialize a shift register with a fixed size array. Rotate the existing array left by the size of the new data array, then replace the tail with it. Send the result to a graph.

For simplicity, you could even use the "collector" epress VI. (bottom code on example).

0 Kudos
Message 5 of 9
(3,703 Views)


@altenbach wrote:
If you want to use a graph instead of a chart, you can keep a buffer in a shift register where you would move data in as desired (using replace array subset)  and keep track of the insert point. Initialize a shift register with a fixed size array. Rotate the existing array left by the size of the new data array, then replace the tail with it. Send the result to a graph.

And here's an example for that possibility. 🙂
0 Kudos
Message 6 of 9
(3,699 Views)
Hi altenbach, thanks for your prompt response.
 
All  of your sample vi files are very helpful. I have just realized a problem with my application. I need to constantly send 102 bytes data from our sensor to the graph. In order to test out the vi, I have constantly sent 102 bytes of similar data. I expect to get a constant graph but the graph is constantly shifting.
 
We suspect  that this is  due to handshaking problem or a loss of data during the transmission. Maybe the rate of imcoing data is not synchronized with the rate of while loop iteration.
 
We have spend whole last 2 days to find a solution , and unfortunately, still couldnt figure out how.
 
Any ideas that I could solve this problem? Any suggestions are highly appreciated.
 

 
0 Kudos
Message 7 of 9
(3,684 Views)
Hi altenbach, thanks for your prompt response.
 
All  of your sample vi files are very helpful. I have just realized a problem with my application. I need to constantly send 102 bytes data from our sensor to the graph. In order to test out the vi, I have constantly sent 102 bytes of similar data. I expect to get a constant graph but the graph is constantly shifting.
 
We suspect  that this is  due to handshaking problem or a loss of data during the transmission. Maybe the rate of imcoing data is not synchronized with the rate of while loop iteration.
 
 
Any ideas that I could solve this problem? Any suggestions are highly appreciated.
 

 
0 Kudos
Message 8 of 9
(3,684 Views)
Wow ! 2 posts at the same time.Smiley Happy
- Partha ( CLD until Oct 2027 🙂 )
0 Kudos
Message 9 of 9
(3,676 Views)