LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

head spinning on stripchart relative time

I have worked with CVI for many years and by far the hardest thing to wrap my head around is strip chart x-axis time formatting.  Killing hours here trying to get this right.

 

I have some data that dumps into a serial port from an instrument at a rate of 5 milliseconds per frame.  I have a multithreaded function that receives the data.  That function has a while loop to read from the serial port and then add it to the strip chart.  Easy.

 

Except for the x-axis.  I want to display relative time based on the known 5ms frame rate.  Not so easy:

 

SetCtrlAttribute(panel, chart, ATTR_XFORMAT, VAL_RELATIVE_TIME_FORMAT);
SetAxisTimeFormat(panel, chart, VAL_BOTTOM_XAXIS, VAL_RELATIVE_TIME_FORMAT, "%#M:%S.%1f");

SetCtrlAttribute(xrfGraphPanel[GPH_LOG], GPH_LOG_CHART, ATTR_XAXIS_GAIN, 5.0); 
SetCtrlAttribute(xrfGraphPanel[GPH_LOG], GPH_LOG_CHART, ATTR_XAXIS_OFFSET, 0.0);		

 

I have read many threads here, each with conflicting advise about which should be gain/offset.  None of this combinations plot accurate timescale for me.  Here's a view of the data:

 

Screenshot 2022-07-07 125802.jpg

 

I have a Timer() call before and after the data dump, giving me 1.391 seconds, which I believe.  Yet, my time scale on the strip chart never formats correctly.

 

Thoughts?

0 Kudos
Message 1 of 3
(1,571 Views)

Never did this before with a strip chart but I got curious. Does this help: Specifying Dates and Times for Axis Values ?

 

Excerpt:

 

If you use the relative time format, LabWindows/CVI expects that you plot data that contains the number of seconds since some arbitrary point in time, commonly denoted as t0.

 

When the axes are in absolute time or relative time format, the value you specify for ATTR_XAXIS_OFFSET or ATTR_YAXIS_OFFSET is the t0 value. The value you specify for ATTR_XAXIS_GAIN or ATTR_YAXIS_GAIN is the Δt value.

-----------------------
/* Nothing past this point should fail if the code is working as intended */
0 Kudos
Message 2 of 3
(1,544 Views)

I remember getting pissed at the time axis of strip charts long ago also. So I wrote my own: https://gitlab.com/dargaud/TimeStripLabel

Message 3 of 3
(1,537 Views)