PDA

View Full Version : Creating software to plot real-time 2D basic graphs



Momergil
8th June 2011, 20:22
Hello!

I'm a engeneering student working in a project that, in the current moment, need to create a software that is capable of recieving real time data from a wireless module (such as Cinterion TC65i or u-Blox Leon) and plot it in a basic 2D real time graphic (exactly the same that we see in a cardiac monitor), where the X array will be time.

A professor here in the university suggested Qt to create the software, so I'm now in the part of learning how to use it.

But (and correct me if I'm wrong) I found that even using Qt I would still have to choose a graphic library (such as matplotlib, Cairo, Qwt and so on) to create the software. And I'm having difficulties in the issue of finding a graphic library or even software capable of displaying 2D graphics in real time (most of them plot just one figure at the end of the software, and that is useless for me) and, of course, it must be one that can be used with Qt. Gnuplot, for example, was capable of doing something like this, but I had problems in calling the software from my C software (not Qt), that means, when I was trying to call it to plot the graphic.

The second problem, though, is that even if I do find a graphic library capable of ploting real time graphics, I still don't know how to use it in Qt (yes, I'm a 0 level Qt user).

For example, searching in this Forum about the same problem, I found three other posts that deals with similar cases:

http://www.qtcentre.org/threads/41814-real-time-graph-plot

http://www.qtcentre.org/threads/31914-QFileSystemWatcher-with-a-Qwt-Real-time-plot

http://www.qtcentre.org/threads/18669-Best-way-in-Qt-to-plot-curve-per-real-time-reading

But nether of them show how do I call Qwt or other graphic library in the Qt environment. In fact, the most close that I found in explaining how to do something like what I need was in this post:

http://stackoverflow.com/questions/1173525/c-and-qt-problem-with-2d-graphics

So, essentialy, what I would ask is:

1. Which library should I use for my real time 2D graph software?
2. How do I implement it in Qt?
3. How do I call it to create the graph?

I would really apreciate if somebody decide to be very nice and give me a code-example already able to plot a real time graph (of course, the part of connecting to the wireless module and recieving data is the minimal that I should do).


Thanks very much.

SixDegrees
8th June 2011, 21:21
Qwt does dynamic plotting; one of their demo programs shows a nice example of it.

There is no such thing as "real time" plotting, however. There is always some lag between data generation and display. A display showing what floor an elevator is on only needs to refresh once ever few seconds to meet a "real time" requirement; a display showing the amplitude of an audio signal might have to refresh several thousand times per second if it is "displaying" to various input devices, although updates as long as 1/100 second would probably be fine for visual display purposes, given that display devices and the human visual system can't handle faster speeds. You haven't provided any sort of refresh information, so it isn't possible to say what might be an appropriate solution, although Qwt can certainly handle many dozens, probably hundreds, of points per second.

Momergil
8th June 2011, 21:46
Qwt does dynamic plotting; one of their demo programs shows a nice example of it.

Which example, exactly? And where can I find it and execute it to see?



There is no such thing as "real time" plotting, however. There is always some lag between data generation and display. A display showing what floor an elevator is on only needs to refresh once ever few seconds to meet a "real time" requirement; a display showing the amplitude of an audio signal might have to refresh several thousand times per second if it is "displaying" to various input devices, although updates as long as 1/100 second would probably be fine for visual display purposes, given that display devices and the human visual system can't handle faster speeds. You haven't provided any sort of refresh information, so it isn't possible to say what might be an appropriate solution, although Qwt can certainly handle many dozens, probably hundreds, of points per second.

Well, I imagine you got the idea when I sad "real time" plotting. Naturally there will be a time difference between recieving the information and ploting the graphic, but the idea is to plot a base of 150 points per second (or something of the like) while having a recieving speed about that or maybe higher, but ploting the graphic at the same time while recieving the data (note that the majority of aplications using 2D graphs first recieve the data, and than configure the plotting commands and than plot the graphic ready with one function. The idea is not to do that, but plot the graphic point by point in a constant speed "at the same time" as data arises).

SixDegrees
9th June 2011, 00:49
Which example, exactly? And where can I find it and execute it to see?

Beats me; it was part of the Qwt package. Download it and install it, and have a look at the demos.

ChrisW67
9th June 2011, 01:06
Examples: data_plot, cpu_plot, and to a lesser extent realtime_plot

Momergil
17th June 2011, 13:12
Thank you all for everything. I did managed to install Qwt and I'm already studing the examples.