07-07-2022 01:59 PM
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:
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?
07-08-2022 03:06 AM - edited 07-08-2022 03:07 AM
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.
07-08-2022 03:29 AM
I remember getting pissed at the time axis of strip charts long ago also. So I wrote my own: https://gitlab.com/dargaud/TimeStripLabel