LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

CVI Graph is drawing odd lines when rescaled during plotting

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
0 Kudos
Message 1 of 2
(2,883 Views)
Hey Judy,

One thing that might help with this behavior you are seeing is calling ProcessSystemEvents in between these sections where you rescale the graph.  This function plays a part in ensuring the updates of all events (including serial and graphical) within the program.  Additionally, this function calls a ProcessDrawEvents, which updates only the user interface. 

Hopefully these suggestions will work because the next step would probably be to find an instance of this behavior isolated from serial that we could reproduce to further troubleshoot.  If we do end up needing to try to reproduce it, I would recommend using a Simulated Signal drawn to the graph rather than the serial input, maintaining the current timing configuration of your software (thread priority, CPU usage, etc).  By the way, are you using multi-threading in the application?  If so, are you assigning any threads to time critical priority or even Above Normal?
Thanks,

Andy McRorie
NI R&D
0 Kudos
Message 2 of 2
(2,864 Views)