Hi folks,
My program is reading data from an instrument at 60 Hz via the serial port. I want to plot this data to my graph in as close to real time as I can. As I read the data, it goes into an array and, periodically, I have a function call that plots the latest chunk of data to the graph. My problem seems to be that, after a significant amount of data has been plotted (15 to 20 minutes worth), if I try to rescale the graph with calls to the following code for each axis (not all code is shown, but this is the code that resets the graph), I get an intermittant bug where the graph line skews off to the upper part of the graph. When I rescale again, the skewed part of the line is gone and my graph looks fine.
SetCtrlAttribute (MyPanel, MYPANEL_GRAPH, ATTR_XNAME, xtitle);
SetCtrlAttribute (MyPanel, MYPANEL_GRAPH, ATTR_XAXIS_GAIN, xscale);
SetCtrlAttribute (MyPanel, MYPANEL_GRAPH, ATTR_XPRECISION, xprecision);
SetCtrlAttribute (MyPanel, MYPANEL_GRAPH, ATTR_XDIVISIONS, xgrid);
SetAxisScalingMode (MyPanel, MYPANEL_GRAPH, VAL_XAXIS, VAL_MANUAL, xmin, xmax);
SetCtrlAttribute (MyPanel, MYPANEL_GRAPH, ATTR_YNAME, ytitle);
SetCtrlAttribute (MyPanel, MYPANEL_GRAPH, ATTR_YAXIS_GAIN, yscale);
SetCtrlAttribute (MyPanel, MYPANEL_GRAPH, ATTR_YPRECISION, yprecision);
SetCtrlAttribute (MyPanel, MYPANEL_GRAPH, ATTR_YDIVISIONS, ygrid);
SetAxisScalingMode (MyPanel, MYPANEL_GRAPH, VAL_LEFT_YAXIS, VAL_MANUAL, ymin, ymax);
NOTE: the data arrays are unaffected. Data looks good. It's only the graph line that acts peculiar.
My theory is that the data collection and graphing functions are taking up so much CPU time that trying to reset the graph while this is going on is causing an error in the CVI graphing paradigm.
Any suggestions?
Thanks in advance,
JMH