LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

How create a continuous XY Oscilloscope?

Solved!
Go to solution

Hi,

 

I am creating a continuous XY Oscilloscope on LabWindows/CVI 2013.

I didn't find a solution with the Stripchart library because i want to implement X an Y axis, so I tryed with a graph.

The solution works but I have to face now with large time treatment when my buffer of points is full and i am doing memory operations on it !

For indication I display 10 000 values per curve and I have more than 50 curves.

 

Someone know a solution to implement an continuous XY oscilloscope?

And is there a way to optimize my problem of time treatment?

 

Thank you for your help.

Charles

 

 

0 Kudos
Message 1 of 15
(4,861 Views)

The graph control is definitely the way to go if you want to plot XY curves. I don't understand your observation on the buffer being full: 50 XY-curves of doubles are less than 8MB in memory, I don't think you are facing some limit neither on system memory not in the graph control. Can you add some detail more on what you are doing? A code abstract could help to understand what's going on. Are you continuously adding new plots to the graph? Or replacint some plot with another? Or what?

How do you realize the buffer is full? Do you receive any error?



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 2 of 15
(4,864 Views)

Hi Charles,

 

how large is your screen? Smiley Happy I do not think that plotting 50 curves with 10000 points is meaningful, all it will do is slow down plotting and any other graph operation. So my recommendation is to use the parameter pointFrequency to significantly reduce the number of displayed data points. If your user needs details, provide a zoom option.

0 Kudos
Message 3 of 15
(4,863 Views)

I have to plot on 4 graphs totally 26 curves of 10 000 points (I display 10 000 points on my screen). For that each 500ms i get 500 values (1kHz acquisition) for each curves, and i put these values in a buffer of 10 000 points x 4 x 26.

when my buffer is full i shift my 10 000 values and insert the news at the end. I do that sequentially for all of my curves.

Each time that i update my buffer i delete my plots and and display my new buffer.

 

Before that my buffer is full my operations last 70ms, when I begin to shift my buffer my operations last 170 ms !

So is there a way to optimize it?

 

Thanks,

Charles

 

0 Kudos
Message 4 of 15
(4,860 Views)

The observation of Wolfgang could help you to reduce the total time spent in the operation. Another hint could be to use VAL_DELAYED_DRAW when deleting curves from the graphs: the graph will be automatically updated on the next PlotXY.

Additionally, since you are plotting only 1/10 of each curve on each run, you could simply call PlotXY for the new data only instead of deleting and replotting the same data every time.

 

How are you performing the shift? Could it be optimized someway?



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 5 of 15
(4,856 Views)

Sorry i did explain this point but in first i update my buffer for all my curves and after i plot all with a loop like that :

 

"

status = DeleteGraphPlot (panelMemo, TabPanelOscilloscopesF2t[indexI].Control, -1, VAL_DELAYED_DRAW);
status = SetCtrlAttribute (panelMemo, TabPanelOscilloscopesF2t[indexI].Control, ATTR_REFRESH_GRAPH, 0);

 

// I plot all my curves with a Loop For
        PlotXY (panel, control, xArray, yArray, numberOfPoints,  VAL_DOUBLE, VAL_DOUBLE, VAL_THIN_LINE, VAL_EMPTY_SQUARE, VAL_SOLID, 1, color);

 

status = SetCtrlAttribute (panelMemo, TabPanelOscilloscopesF2t[indexI].Control, ATTR_REFRESH_GRAPH, 1);

"

 

The long processing time occurs when i shift my datas.

I tried with For() ; Shift() ; Copy1D() and memcpy()  libraries but it's slow.

 

 

0 Kudos
Message 6 of 15
(4,853 Views)

Why are you storing and copying the data AT ALL?

Plot the data, and just keep track of the plot handles, deleting the oldest one every time.

Obviously you may need to add an extra dimension to the arrays if you are plotting 4 separate graphs.

 

While I am embarrassed to post code in front of Robert & Wolfgang, I used something similar recently:

 

#define NUMBER_OF_PLOT_HANDLES 100

static int current_plot_number =0;

static int list_of_plot_handles[NUMBER_OF_PLOT_HANDLES]={0};

 

//

// Code to acquire & process data goes here

//

 

SetBOLE(0);

if(list_of_plot_handles[current_plot_number]>0)

   {

   SetBOLE(0);   

   status = DeleteGraphPlot (panelMemo, TabPanelOscilloscopesF2t[indexI].Control,list_of_plot_handles[current_plot_number], VAL_IMMEDIATE_DRAW); 

   SetBOLE(1)

   }
list_of_plot_handles[current_plot_number]=  PlotXY (panel, control, xArray, yArray, numberOfPoints,  VAL_DOUBLE, VAL_DOUBLE, VAL_THIN_LINE, VAL_EMPTY_SQUARE, VAL_SOLID, 1, color);

current_plot_number++;

if(current_plot_number>=NUMBER_OF_PLOT_HANDLES)current_plot_number=0;

 

0 Kudos
Message 7 of 15
(4,827 Views)

I am storing my news datas in arrays because after i plot these arrays.

I don't know how i can plot just my news points at the end of my graph. So i store an array with the size of my screen.

An after i **bleep** my datas in this array when it is full (long processing operation for me)

 

Also i would like to save all my datas to apply filter on it or keep a track of my previous datas.

 

0 Kudos
Message 8 of 15
(4,802 Views)

Sorry i forgot a letter to SHIFT :

An after i SHIFT my datas in this array when it is full (long processing operation for me)

0 Kudos
Message 9 of 15
(4,801 Views)

As far as In can understand, you have a 10-seconds screen where you plot in blocks of 0.5 sec each timewith PlotXY.

If your "oscilloscope" is in block mode (e.g. the screen is cleared after 10 sec and plots restart from 0) then you can simply iterate with several PlotXY with increasing offset:

 

PlotXY (... , ... , Xdata, Ydata, 500, VAL_DOUBLE, VAL_DOUBLE, ...);

PlotXY (... , ... , Xdata + 500, Ydata + 500, 500, VAL_DOUBLE, VAL_DOUBLE, ...);

PlotXY (... , ... , Xdata + 1000, Ydata + 1000, 500, VAL_DOUBLE, VAL_DOUBLE, ...);

...and so on

 

When you have plotted all 10k points you clear the graph and restart.

 

If you are in continous mode, the best solution is the Woflgang way, but not only at plotting level: since correctly is useless plotting 10000 points on a screen that is 1500 dots at best, you can decimate the original array and plot / shift the decimated one, keeping original data for other uses including the zooming Wolfgang suggested if you need it.

 

But this is *very* similar to a stripchart: are you sure that control cannot suit your needs?



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 10 of 15
(4,796 Views)