LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Plotting Problems

Hi Folks!

I am in trouble. I will describe the situation below and I would like do know some opinions of you in how to solve the problem.

I need to create a strip chart or a graph which the X axis will have time value.

I don´t have all points of my graph when I start to plot it. The plot must consumes the data during all time long.

The software receives the value of boty coordinates, X and Y. I don't know the frequency of the data transmission, so I can't set the frequency of the data that is plotted in the graph.

The plot should has the same behaviour of a strip chart. In other words, I would like to update the graph on a PC monitor... plots points, that will be connected, from  left to right until the screen is full, then scrolls left...  automatic adjustment of y-range would be a plus. This should be fairly common in industrial-type applications.

Thank you in advance!
Gustavo


Message Edited by Oliveira on 09-06-2007 07:11 AM

0 Kudos
Message 1 of 14
(4,820 Views)
Gustavo,

Because you don't know the frequency ahead of time, and because you need the y-axis to autoscale, you probably should use a graph instead of a strip chart, and use the PlotXY function to plot your data. You have to keep the x-axis in manual scaling mode, and set the limits yourself, each time you plot, so that it shows the horizontal scrolling effect that you're looking for.

What you should set the new minimum and maximum values to is pretty much up to you. It depends on how much of a data history you want to show. Since the x values are not uniformly distributed, you'll have to decided whether you want to always show a constant number of points in the screen at any one time, or you want a constant [min,max] range instead.

Whatever you do, each time you plot, you simply have to delete the previous plot (use VAL_DELAYED_DRAW in order to avoid the extra flashing) and then plot the new data, using PlotXY. As for the data itself, you can keep appending the new points to the end of your array, or you can shift everything over, and therefore delete the points at the beginning of the array -- in other words, you can treat your array like a circular queue.

Luis
0 Kudos
Message 2 of 14
(4,801 Views)
Isn´t there any real time solution? Such as a real time graph...

The software must have a good performance managing 20 graphs divided in 4 tabs. It is not so good to store all last samples to plot and plot them again in every update. It will spend a lot of memory to do it.

Have you ever do it using the amount of graphs that I have to plot? Has the solution that you suggested a good performance in the conditions that I described?

Any other solution?

Thank you
0 Kudos
Message 3 of 14
(4,760 Views)
In theory the memory requirements shouldn't be that much worse by having you implement the circular buffer, rather than have the control do it for you. More complicated, sure. But overall, the amount of memory required at any one time should be about the same. The only difference is that in one case, the memory is hidden inside the CVI library, and in anoter case it's being explictly allocated for you.

Having said, I can see how the solution I suggested would be slower, since you're replotting all the data on each iteration, rather than only the new data points. Depending on how much data you want to be visible in the graph at any one time, this might be a significant issue. If that's the case, you might want to consider plotting only the new points each time. To do that, instead of removing the previous plot with each iteration, you can leave it in the graph, and instead plot only the new data in a new plot, and link it to the last point of the previous plot. If the new data is a single point per trace, then you can use PlotLine, and you won't even need a circular buffer for your data. You just have to remember the last data point. It would look something like this:

Iteration 1: PlotPoint (x1, y1)
Iteration 2: PlotLine (x1, y1, x2, y2)
Iteration 3: PlotLine (x2, y2, x3, y3)
Iteration 4: PlotLine (x3, y3, x4 y4)
etc...

If you do it this way, you'll have to decide on a good metric for when to delete old plots that are no longer in view. The plots will naturally disappear, since you will also be updating the [min,max] range on each iteration. Eventually old plots will scroll out of view, and it's okay to delete them anytime after that point. You can delete them on each iteration, or you can delete them in large batches, once in a while.

Unfortunately, CVI doesn't have a strip chart control that supports non-uniform time, so I can't think of a better solution for you to try.

Luis

0 Kudos
Message 4 of 14
(4,744 Views)
I read that it is possible to use some Measurement Studio graphs throught ActiveX to plot a chart in that way. I am looking for an example of what it was explained and about the use of DCWGraphChartXY function. How it works and everything else....

If you have some experience using these objects, share it with us 🙂

Thank you again
0 Kudos
Message 5 of 14
(4,720 Views)
I forgot to say that the function is related to CWGraph controls. I am using labwindows/cvi 8.1.1

0 Kudos
Message 6 of 14
(4,699 Views)
Here, it is the code which I am trying to execute using the activex control, that has some problem.

    // ActiveX variables controls
    CAObjHandle ObjHandle;
    VARIANT dataToPlot;
    double arrayData[2];

             while ( newDataToPlot ) {
                arrayData[0] = timestamp;                
                 ........
                arrayData[1] = pValue[0];
                GetObjHandleFromActiveXCtrl (panelID, controlID, &ObjHandle);
                CA_VariantSet1DArray (&dataToPlot, CAVT_DOUBLE, 2, arrayData);
                CWUIControlsLib__DCWGraphChartXY (ObjHandle, NULL, dataToPlot, CA_DEFAULT_VAL);
             }

The timestamp and pValue[0] are updated by another thread.

Using it, I would like to plot a chart (point by point). Is it  possible? What is it wrong?

Thank you very much.
   

Message Edited by Oliveira on 09-12-2007 06:52 AM

0 Kudos
Message 7 of 14
(4,696 Views)
I haven't used the CWGraph myself, so I might only be of limited help here. Also, you don't mention exactly what problem you're having with this code. Are you getting errors back from one of those functions? If not, is it that the graph is not plotting what you'd expect?

If you're looking for examples on how to use these graphs, and you have the CVI Full Development System version, you should have a CD with the Measurement Studio installer. Go ahead and install it. Once you do, you'll have some C++ examples that show you how to use the ChartXY function. You can find them here:

C:\Documents and Settings\All Users\Documents\National Instruments\MStudioVS2005\VCNET\Examples\Application\FrequencyResponse
C:\Documents and Settings\All Users\Documents\National Instruments\MStudioVS2005\VCNET\Examples\UI\Graph\Graph Benchmark

Luis


0 Kudos
Message 8 of 14
(4,674 Views)
The problem is that nothing occurs when that code is executed.

When I try something like that, the code works:
                arrayData[0] = pValue[0];
                GetObjHandleFromActiveXCtrl (pCAux->panelID, pCAux->controlID, &ObjHandle);
                CA_VariantSet1DArray (&dataToPlot, CAVT_DOUBLE, 1, arrayData);
                CWUIControlsLib__DCWGraphChartY (ObjHandle, NULL, dataToPlot, CA_DEFAULT_VAL, CA_DEFAULT_VAL);

But it is not exactly what I need. I need to do an input of the X value also, because, the data that I wnat to plot have a variable frequency.
The function CWUIControlsLib__DCWGraphChartXY seems to solve the problem, but I don't know to work with it.




0 Kudos
Message 9 of 14
(4,665 Views)
The problem is that nothing occurs when that code is executed.

When I try something like that, the code works:
                arrayData[0] = pValue[0];
                GetObjHandleFromActiveXCtrl (pCAux->panelID, pCAux->controlID, &ObjHandle);
                CA_VariantSet1DArray (&dataToPlot, CAVT_DOUBLE, 1, arrayData);
                CWUIControlsLib__DCWGraphChartY (ObjHandle, NULL, dataToPlot, CA_DEFAULT_VAL, CA_DEFAULT_VAL);

But it is not exactly what I need. I need to do an input of the X value also, because, the data that I wnat to plot have a variable frequency.
The function CWUIControlsLib__DCWGraphChartXY seems to solve the problem, but I don't know to work with it. So, my question is about of an code example that uses that function (CWUIControlsLib__DCWGraphChartXY).

Thank you




0 Kudos
Message 10 of 14
(4,662 Views)