LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

100% CPU capacity with the function PlotLine

Hallo Community, I must write a visualization surface for a laboratory unit.

I use the Graph Control Functions, PlotLine to show the trends of the controller sizes.

This function draws every 1/10 sec. a point into the Graph.

My problem is, that after 600 sec. or 6000 point the CPU capacity is on 100%,

without change of the memory usage.

 

Thanks for the help

Gerhard

0 Kudos
Message 1 of 5
(3,553 Views)
Hi Gerhard!

  Can you post the code? From what you said, I can't figure the problem.  I would think that you didn't use a ClearGraph function, but.... looking  at your code may help!

  Bye!

graziano
0 Kudos
Message 2 of 5
(3,531 Views)

Hello,

this code run in a timer loop with "updateTime" = 0,2sec.

Thanks for help

Gerhard

 

// Trendfunktionen Druckregler  
   
   if (Trend_Druck == 1)
   {
    // Sollwert W
    GetCtrlVal(rk3, RK3_Druck_Sollwert, &Wvalue);   // Sollwert auslesen
    PlotLine(trend_druck, Trend_P_Trend_P_Graph, (stepGraph - updateTime), Wvalue_old, stepGraph, Wvalue, VAL_BLUE);
    Wvalue_old = Wvalue;
   
    // Regelgröße X
    GetCtrlVal(rk3, RK3_Druck_Istwert, &Xvalue);    // Istwert auslesen
    PlotLine(trend_druck, Trend_P_Trend_P_Graph, (stepGraph - updateTime), Xvalue_old, stepGraph, Xvalue, VAL_RED);
    Xvalue_old = Xvalue;
   
    // Stellgröße Y
    GetCtrlVal(rk3, RK3_Druck_Stellgroesse, &Yvalue);   // Stellgröße auslesen
    state = PlotLine(trend_druck, Trend_P_Trend_P_Graph, (stepGraph - updateTime), Yvalue_old, stepGraph, Yvalue, VAL_YELLOW);
    // 
    SetPlotAttribute(trend_druck, Trend_P_Trend_P_Graph, state, ATTR_PLOT_YAXIS, VAL_RIGHT_YAXIS);

    Yvalue_old = Yvalue;
   
    // Zeit-Schritt
    stepGraph = stepGraph + updateTime;
   
    // X-Achse weiterlaufen lassen, wenn 5% vor Xmax
    GetAxisScalingMode(trend_druck, Trend_P_Trend_P_Graph,VAL_BOTTOM_XAXIS, VAL_MANUAL, &Xmin, &Xmax);
    if (stepGraph > (Xmax - ((Xmax - Xmin) * 0.05)))
    {
     SetAxisScalingMode(trend_druck, Trend_P_Trend_P_Graph,VAL_BOTTOM_XAXIS,
                        VAL_MANUAL, (Xmin + 1), (Xmax + 1));
    }
    

}

0 Kudos
Message 3 of 5
(3,524 Views)

Hello Gerhard.

I did not see any calls to DeleteGraphPlot() in your code.

Unless you set ATTR_DATA_MODE for your graph to VAL_DISCARD, the plot data will be retained in memory, and eventually this will cause you problems. The default value of this attribute is VAL_RETAIN. Unfortunately, you actually need to retain the data so that plots will not disappear when you rescale the graph.

Here is my suggestion:

  • store the data for each plot in an array; you could also use an array to store time values or data indices, and call PlotXY() in place of PlotY() below
  • when you have new data:
    • if the arrays are full, shift the values "left" using memmove(); it will be more efficient to do this after, say, every 10 points
    • append the new data points to the arrays
    • delete all plots:
      DeleteGraphPlot (trend_druck, Trend_P_Trend_P_Graph, -1, VAL_DELAYED_DRAW);
    • for each array:
      • set the active y-axis:
        SetCtrlAttribute (trend_druck, Trend_P_Trend_P_Graph, ATTR_ACTIVE_YAXIS, VAL_LEFT_YAXIS); // or VAL_RIGHT_YAXIS
      • call PlotY()
    • rescale the graph (not necessary if your axes are set to VAL_AUTOSCALE)
    • refresh the graph:
      RefreshGraph (trend_druck, Trend_P_Trend_P_Graph);

Hope this helps.

Regards,
Colin.

 

Message 4 of 5
(3,501 Views)
Yes,
  I subscribe to cdk52, that was my first impression too....  Smiley Wink

  Please, let us know if you solve this!!! Have a nice day!

graziano
0 Kudos
Message 5 of 5
(3,481 Views)