LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

IMPLEMENTING CIRCULAR BUFFER FOR XY WAVEFORM GRAPH

Solved!
Go to solution

Hello

I want to show timestamp in X axis and multiple CH's numeric values on Y axis

 

My application is that I am getting data from 15 CH's of CAN bus and would like to plot this data on Chart with Absolute timestamp

 

I tried with Waveform Chart since it was fairly simple, but as the duration of the test is long almost 7-8 days, the timestamp was not consistent with the PC actual time. I figured that the while loop iterations are not always constant, so created the problem

 

Therefore I have shifted from Chart to XY graph where I can insert the timestamp dynamically during each iteration.

Please find attached vi for the same. I am able to shift the data to left after the circular array size is achieved i.e. say 100 iterations.

 

My problem statement:

1. For the first 100 samples the data is cramped in the graph and after the 100 iterations, the circular buffer logic starts working so, the data then starts shifting to the left. I want to see the data transition to the left after say 50 samples, so it looks neat something like the built in feature of the Waveform Chart . I played with the properties like "minimum, offset, maximum and multiplier", but could not get it working

2. Is it possible to show the transition from left to right, rather than right to left similar to waveform chart. 

 

Snippet:

 

xy gragh.png

 

Thanks

0 Kudos
Message 1 of 13
(419 Views)

This isn't an "embedded systems" topic at all. Circular buffers are used everywhere, where you, you know, need a circular buffer. They're good for continuous reading from sensors via DMA, they're good for keeping a log of error messages and other operational messages similar to e.g. how Linux does, one might use circular buffers for some sort of terminal emulator interface and so on.

 
0 Kudos
Message 2 of 13
(397 Views)

Hi Patil,

 


@VihangPatil wrote:

My problem statement:

1. For the first 100 samples the data is cramped in the graph and after the 100 iterations, the circular buffer logic starts working so, the data then starts shifting to the left. I want to see the data transition to the left after say 50 samples, so it looks neat something like the built in feature of the Waveform Chart . I played with the properties like "minimum, offset, maximum and multiplier", but could not get it working

2. Is it possible to show the transition from left to right, rather than right to left similar to waveform chart. 


  1. Set the X axis to show 50 samples (and AutoScale switched off) when you want to see some scrolling… (Might get tricky when your X data comes with irregular intervals as is the use case for XYGraphs…)
  2. Exchange the min/max values of the X axis to change their direction…
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 3 of 13
(393 Views)

Hello GerdW

Can you kindly modify the code and attach. Because I am not getting it to work somehow

Thanks

0 Kudos
Message 4 of 13
(374 Views)

Anyone who could kindly guide? Or modify the missing part 

0 Kudos
Message 5 of 13
(340 Views)

to show from right to left, just double click on the time stamp, type "0", the graph will update from Right to left. 

 

Use circular buffer size 50 will do what you need. 

LVNinja_0-1725996467295.png

 

Message 6 of 13
(319 Views)

Thanks for the tip

Changing the 0 to right, made scrolling from right to left

 

Using 50 as circular buffer actually is not giving me what I intended.

I have an X scrollbar and it should show be scrollable , I want to show 50 samples at any given moment on the screen, after the 50 samples the screen should scroll and I need to store history of 1000 samples

 

The circular buffer I want to implement is such that the memory(history) is restricted to 1000 samples only and PC memory should not overrun 

 

This is my requirement.

Currently the history length and samples length is the same, therefore the scrollbar is not scrollable.

 

Thanks

0 Kudos
Message 7 of 13
(293 Views)

You need to initialize the buffer with 1000 points in memory ,  and replace every new data on the buffer, to the pointer at every iteration. You can then get a subset of 100 points and update the plot...there is some extra work to be explored, but consider you have a set of 1000 points in memory , you need to massage your data to show what you want on the plot to be "scrollable"...

 

LVNinja_0-1726070947089.png

 

0 Kudos
Message 8 of 13
(283 Views)

I have modified the code further where now, I got the Scrollbar functionality working, i.e. I have now the history data.

But one thing which is still not as per my liking is the feel that the Waveform Chart would give, like continuous data scrolling

In my modified code the data is shown till the period of 10 secs and then it gets blank and again the data starts to show from the left. This is undesirable. I want the last 10 secs data always visible

 

I would like to have a history of 1 minute. So I have kept the circular buffer of 6000, and would like to show live data of 10 secs

 

Little help modifying the code would be great. I want the scrolling feature similar to the Waveform Chart

 

xy gragh1.png

0 Kudos
Message 9 of 13
(274 Views)

Hello Fibo

I am trying to achieve the same using XY graph. But struggling to get the XY Graph to work like Waveform Chart

I want to also add timestamp to the Xaxis. Can you please share your code

 

This is my code where i am struggling

 

 

Thanks

xy gragh1.png

0 Kudos
Message 10 of 13
(270 Views)