Results 1 to 3 of 3

Thread: How implement real time history plot with data samples having varying timestamps?

  1. #1
    Join Date
    Mar 2009
    Posts
    14
    Thanked 2 Times in 2 Posts

    Default How implement real time history plot with data samples having varying timestamps?

    Can anyone recommend an approach to plotting data with non-fixed elapsed time intervals?
    Basically the X time values of each data sample are non-fixed, non-integral seconds, and will vary.
    However, I want the X-axis time labels to remain in units of integral seconds (or perhaps minutes).

    I am working on a real-time history plot based on the Qwt cpuplot example. While cpuplot works well it is implemented using a fixed 1.0 second time intervals. My time stamped data contains elapsed time stamp values in milliseconds rather than integral seconds and time bewteen samples can vary perhaps up to 1000 ms. How can I plot a data sample with a timestamp of 1.5 seconds and line up properly with an X-axis label displaying integral seconds?

    Example of my time stamped data series:

    1. 0 ms, 0.1 volts
    2. 1350 ms, 0.22 volts
    3. 2820 ms, 0.31 volts
    4. 4120 ms, 0.47 volts
    5. etc.


    I attached a screenshot that may hep give you an idea of what I am seeking to accomplish.

    Thanks in advance for any tips or direction,

    -Ed
    Attached Images Attached Images
    Last edited by esutton; 23rd October 2012 at 22:36.

  2. #2
    Join Date
    Mar 2009
    Posts
    14
    Thanked 2 Times in 2 Posts

    Default Re: How implement real time history plot with data samples having varying timestamps?

    Solved. ( Sorry, bad arithmetic calculating elapsed time - it should have been working all along )

    The cpuplot source was used pretty much as is, simply replacing the timer event handler with my own code that I called when I received the updated time-stamped data sample:

    Qt Code:
    1. // Update X-axis time series labels for the amount of time that has passed since last update
    2. double elapsedTimeIntervalSeconds = (structDataSample.timeStampMs - m_structDataSampleLast.timeStampMs) / 1000.0;
    3. m_structDataSampleLast = structDataSample;
    4. qDebug() << "Dbg: elapsedTimeIntervalSeconds = " << elapsedTimeIntervalSeconds << endl;
    5. for ( int j = 0; j < HISTORY_BUFFER_LENGTH; j++ )
    6. {
    7. timeDataSeries[j] = timeDataSeries[j] + elapsedTimeIntervalSeconds;
    8. }
    To copy to clipboard, switch view to plain text mode 

  3. #3
    Join Date
    Apr 2013
    Posts
    9
    Qt products
    Qt4 Qt5

    Default Re: How implement real time history plot with data samples having varying timestamps?

    I'm also doing the same kind of application. I'm new to QWT and QT. Can u please upload the full code?

Similar Threads

  1. How to plot real time x/y graph in Qtopia
    By desperado_43 in forum Qt for Embedded and Mobile
    Replies: 0
    Last Post: 18th May 2012, 09:00
  2. real time graph plot
    By robotics in forum Qt Programming
    Replies: 5
    Last Post: 24th May 2011, 06:04
  3. Replies: 1
    Last Post: 27th April 2011, 11:35
  4. QFileSystemWatcher with a Qwt Real-time plot
    By gen_mass in forum Qt Programming
    Replies: 1
    Last Post: 25th June 2010, 22:28
  5. Best way in Qt to plot curve per real-time reading?
    By Sheng in forum Qt Programming
    Replies: 1
    Last Post: 10th February 2009, 23:33

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.