LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Absolute time in stripchart

Hi all,

in an application I sample some voltage values (USB-6009) every minute. I want them plotted in a stripchart using absolute time as x-axis. Now the following problems occure:
a) The absolute time starts allways at 00:00:00 and not as expected at the actual systemtime.
b) The stripchart takes the added values as 'values per second'. So how can I force the stripchart to scale the x-axis with a 'minute tick' and not with this 'second tick'?

regards,
Thomas
0 Kudos
Message 1 of 12
(9,368 Views)
Hi Thomas,
 
By default, graphs and charts use a 0-offset in their axis. That means, that the data for each axis is assumed to begin at 0, whether you are displaying real values, or time units. But you can change this easily. If you edit the chart in the UI editor, go into the x-axis configuration dialog, and you'll notice an "Offset" control. You can change this to whatever you like, and this will be used as a base value for the axis. In the specific case of time, you'll notice that once you change the Display Format to "absolute time", a new button appears next to this control. That button will make it easier for you to pick a time to use as a base.
 
It sounds as if in your case, you'll want to set this offset programmatically, since you probably want it to hold the current time at the time that you plot. If that's the case, you'll need to use these two functions:
 
GetCurrentDateTime (&currTime);
SetCtrlAttribute (panel, chart, ATTR_XAXIS_OFFSET, currTime);
 
Asd
 
 
0 Kudos
Message 2 of 12
(9,358 Views)
Hi Thomas,
 
By default, graphs and charts use a 0-offset in their axis. That means, that the data for each axis is assumed to begin at 0, whether you are displaying real values, or time units. But you can change this easily. If you edit the chart in the UI editor, go into the x-axis configuration dialog, and you'll notice an "Offset" control. You can change this to whatever you like, and this will be used as a base value for the axis. In the specific case of time, you'll notice that once you change the Display Format to "absolute time", a new button appears next to this control. That button will make it easier for you to pick a time to use as a base.
 
It sounds as if in your case, you'll want to set this offset programmatically, since you probably want it to hold the current time at the time that you plot. If that's the case, you'll need to use these two functions:
 
GetCurrentDateTime (&currTime);
SetCtrlAttribute (panel, chart, ATTR_XAXIS_OFFSET, currTime);
 
As
 
 
0 Kudos
Message 3 of 12
(9,359 Views)
Hi Thomas,
 
By default, graphs and charts use a 0-offset in their axis. That means, that the data for each axis is assumed to begin at 0, whether you are displaying real values, or time units. But you can change this easily. If you edit the chart in the UI editor, go into the x-axis configuration dialog, and you'll notice an "Offset" control. You can change this to whatever you like, and this will be used as a base value for the axis. In the specific case of time, you'll notice that once you change the Display Format to "absolute time", a new button appears next to this control. That button will make it easier for you to pick a time to use as a base.
 
It sounds as if in your case, you'll want to set this offset programmatically, since you probably want it to hold the current time at the time that you plot. If that's the case, you'll need to use these two functions:
 
GetCurrentDateTime (&currTime);
SetCtrlAttribute (panel, chart, ATTR_XAXIS_OFFSET, currTime);
 
As for
 
 
0 Kudos
Message 4 of 12
(9,359 Views)
(Sorry about the multiple posts...I must have had a seizure, or something)
 
Hi Thomas,
 
By default, graphs and charts use a 0-offset in their axis. That means, that the data for each axis is assumed to begin at 0, whether you are displaying real values, or time units. But you can change this easily. If you edit the chart in the UI editor, go into the x-axis configuration dialog, and you'll notice an "Offset" control. You can change this to whatever you like, and this will be used as a base value for the axis. In the specific case of time, you'll notice that once you change the Display Format to "absolute time", a new button appears next to this control. That button will make it easier for you to pick a time to use as a base.
 
It sounds as if in your case, you'll want to set this offset programmatically, since you probably want it to hold the current time at the time that you plot. If that's the case, you'll need to use these two functions:
 
GetCurrentDateTime (&currTime);
SetCtrlAttribute (panel, chart, ATTR_XAXIS_OFFSET, currTime);
 
As for the time units, you change those using the "Gain" setting of the graph. You'll notice a drop-down list next to the "Gain" control in the UI editor. You can pick the unit you chose here. Selecting "Minutes" is equivalent to entering a gain of 60.
 
Hope this helps,
 
Luis
 
 
 


Message Edited by LuisG on 12-03-2007 11:03 AM
0 Kudos
Message 5 of 12
(9,359 Views)
Hi Luis,

thanks for your help. It fixed my first problem perfectly.
Now I have only the one with the 'minute' resolution.

Hopefully one can show me the way out?

best regards,
Thomas
0 Kudos
Message 6 of 12
(9,341 Views)
Thomas,
 
To change the resolution, you have to change the axis gain. You can do this programmatically, or interactively in the UI editor.
 
Programmatically:
 
SetCtrlAttribute (panel, chart, ATTR_XAXIS_GAIN, 60);
 
Interactively:
 
In the strip chart edit dialog, click on the "X-Axis" button. Make sure that the display format is set to "Absolute Time". Then, go to the "Gain" control, click on the button with the upside-down triangle, and select "Minute".
 
Luis
0 Kudos
Message 7 of 12
(9,318 Views)

Hi, 

 

I am having a problem with speed of the strip chart. The GAIN is 1.0, absolute time, strip  chart is refreshed in TIMER function, but I cannot get real time situation. The time is runing much more faster then it should. Can anyone help me?    

 

int CVICALLBACK set (int panel, int control, int event,void *callbackData, int eventData1, int eventData2){

double curtime;

 

switch (event){

 

case EVENT_COMMIT:

GetCurrentDateTime (&curtime);

SetCtrlAttribute (panelHandle, PANEL_STRIPCHART, ATTR_XAXIS_OFFSET,curtime);

SetCtrlAttribute (panelHandle, PANEL_STRIPCHART, ATTR_XAXIS_GAIN, 1.0);

SetCtrlAttribute (panelHandle, PANEL_STRIPCHART, ATTR_XPRECISION, 2);

SetAxisTimeFormat (panelHandle, PANEL_STRIPCHART, VAL_BOTTOM_XAXIS,   VAL_ABSOLUTE_TIME_FORMAT, "%H:%M:%S:%2f");

go=1;
break;

}

return 0;

}

 

int CVICALLBACK timerica (int panel, int control, int event,void *callbackData, int eventData1, int eventData2)

{

switch (event){

 

case EVENT_TIMER_TICK:

 

if(go){

 

PlotStripChartPoint (panelHandle, PANEL_STRIPCHART, 1.00);

}

 

break;

}

return 0;

}

 

 

0 Kudos
Message 8 of 12
(8,347 Views)

Hi mitros,

 

I think you might be misunderstanding the purpose of the time axis in the chart. It's not intended to control your plotting speed. It is merely an indicator of a timestamp associated with each data point.

 

When you use a gain of 1.0, you are telling the chart that each data point that you plot to the strip chart was acquired 1 second after the previous data point. This doesn't mean that the strip chart will wait 1 second before plotting the next point. A strip chart is not a real-time control! It merely gives you a way to visualize data that might or might not have been acquired in real-time.

 

In your case, the plotting speed is determined primarily by the interval at which your timer control fires the EVENT_TIMER_TICK event. You have it set to 0.05 seconds, which means you're plotting a point every 0.05 seconds. Therefore, you should either change the gain of the chart's x-axis from 1.0 to 0.05, or you should change the timer interval from 0.05 to 1.0. If you do that, the axis and the data will be in sync.

 

Luis

0 Kudos
Message 9 of 12
(8,339 Views)

Luis,

Thanks for reply.

 

The situation is like this: I have to acquire digital signals with NI USB 6501, store that values in file and plotting  them in realtime. What is the best way to do that (plotting)? When I use PlotStripChart, with timer tick 0.02s, I set the gain for example 0.02/24, and 1000 points per screen and even then there is a slight difference in actual time respect to strip chart time, end that difference progresses with time.

 

Thank you in advance,

Igor

0 Kudos
Message 10 of 12
(8,330 Views)