LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

strip chart x axis

I just can't seem to get the strip chart control to do what I want. 

I want to plot two hours worth of data (on 5 traces), with data added at a fixed interval (typically 10 seconds).  I want the X Axis to be time, scaled in minutes, showing a 120 minute window.  The data  in the traces are doubles, ranging in value from -50 to +75.

Here's the code I'm using to plot the data:

VOID plotTemperatures (TEMPS Temperatures) {
   
    DOUBLE dTemperatureArray[5];
   
    dTemperatureArray[0] =
Temperatures.dChamberT1;
    dTemperatureArray[1] =
Temperatures.dChamberT2;
    dTemperatureArray[2] =
Temperatures.dBBTemp;
    dTemperatureArray[3] =
Temperatures.dTCCA;
    dTemperatureArray[4] =
Temperatures.dTFPA;
   
    PlotStripChart (iPanel, MAIN_STRIPCHART, dTemperatureArray, 5, 0, 0, VAL_DOUBLE);  
   
  return;   
   
}  // end, plotTemps

The problem is that the data is plotted at a much larger scale than I intend.  Each update moves the traces across about 30 minutes on the X Axis.

I've read what help there is for the relative time mode on the X Axis, but it's not at all clear to me exactly what the interaction is between the number of points, the time scaling, and the trace behavior.  I don't understand what the relative time mode uses for a reference - it's "some reference" according to the help.  Does the control run its own timer to measure elapsed time since the last update and plot the data along the X Axis?

I've attached a file showing the control as well as the control edit panel.

We've used a graph before and plotted a full array, adding a data point into the array every few seconds, then replotting the entire array, but I want the stripchart capability so that the user sees just the last two hours of traces.

Message 1 of 5
(4,525 Views)
Well, I think I have it figured out ... you supply the start time in as the X axis offset.and the "delta t" as the x axis gain.  BUT this seems to dictate a constant update rate - unless you were to change the X axis gain everytime you updated to reflect the time since last update.  And it seem to me that getting the x axis labeled with correct times, even relative ones, is a pain, if it can be done at all.

Menchar
0 Kudos
Message 2 of 5
(4,517 Views)

I was testing some of these features and I second your opinion about x-axis gain: as far as I can understand the axis is always scaled in seconds and the correct gain applied must reflect your update rate (that is, to update every 10 seconds a gain of 10 must be applied, when you select "hours" in the gain list a gain of 3600 is applied). If I'm not wrong, this reflects also on points per screen paramter: to show 2 hours with an update rate of 10 seconds you must select 720 points per screen.

I am attaching a small project I developed for studying this item that may be of some help to you.

With respect to the time of update, you must consider the precision you are expecting on the strip chart: I don't know which is the exact update rate you have on your system, but with a 10 secs timebase even 0.1 secs difference in temperature acquisition may be below strip chart (and screen) resolution! If this item is crucial to you I would reconsider moving back to a xy graph scaled in time.



Message Edited by Roberto Bozzolo on 06-13-2008 10:22 AM


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 3 of 5
(4,515 Views)
Roberto, your conclusions are all correct.
 
The only (minor) tweak I'd make to your program would be to set the x-axis offset programmatically, since the time that you set it to in the .uir might have been the current time at one point, but it's no longer the current time when you run the program. If you want the chart to be synchronized with the "Current time" numeric control, you should do the following:
 
    GetCurrentDateTime (&curTime);
    SetCtrlAttribute (panelHandle, PANEL_STRIPCHART, ATTR_XAXIS_OFFSET, curTime);
 
Menchar: yes, it's true that the stripchart assumes that you're plotting with a constant time interval. You can set the units in the way that Roberto suggests (by changing ATTR_XAXIS_GAIN), but you cannot vary the rate. As for ATTR_POINTS_PER_SCREEN, you only need to set it if you want to change the "density" of the data that you can plot in a single screen on the chart. If you set it to, say, 60 points, that means that you display 60 data points horizontally, regardless of what the x-axis labels are showing you.
 
The difference between relative time and absolute time is that in the latter you're plotting using calendar time (including months and years, if you choose to display them) whereas in the former you're plotting using an arbitrary time interval. If you're using absolute time, the most common scenario involves setting the offset to the current date/time.
 
Luis
Message 4 of 5
(4,501 Views)
Hi Roberto -

Yes, I found I had to recalculate the number of points per screen dynamically, depending upon the update rate.    So if update rate is 10 seconds I do indeed set the number of points to 720.  I am not using X axis labels at all - too confusing - I could waste hours screwing around with it - I already have, in fact.    At least I know it's scaled properly.  

These issues aren't explained well at all in the NI help.   The NI stripchart example just happens to not use time labels on the X Axis:-)

Thanks for your suggestions, Roberto.

Menchar
0 Kudos
Message 5 of 5
(4,499 Views)