Jump to content

As of July 17, 2015, the LabJack forums here at forums.labjack.com are shut down. New registrations, topics, and replies are disabled. All forums are in a read-only state for archive purposes.

Please visit our current forums at labjack.com/forums to view and make new posts. To post on the current forums, use your labjack.com login account. Your old LabJack forums login credentials have been retired. There are no longer separate logins for labjack.com and LabJack forums.


retrieve data from u6 and plot on graph in real time

u6 with thermocouple

  • Please log in to reply
3 replies to this topic

#1 rouby11

  • Members
  • 3 posts

Posted 01 October 2014 - 07:50 AM


I connect a thermocouple to U6 for retrieving Data in order to display a curve of Tempeture( plot a graph in real Time in QT C++).

fist I write function to send data to a file in order to check tempeture but i enter to infinite loop and I can't do anything else.

  QTextStream flux(&fichier);
  while(true) {
  // QString  chemin, texte; 
    //GetTemp()     ;
double temp= GetTemp();//connect to U6 and return temp
       flux <<  temp<<endl;
How can I plot data in real Time without infinite loop.
Please Help Me.
Thanks a lot

#2 LabJack Support

LabJack Support
  • Admin
  • 8677 posts

Posted 01 October 2014 - 12:40 PM

Did you need help with LabJack related calls to get the thermocouple reading, or is that handled in the GetTemp function/method?


Alternative to a while loop you can use a timer that runs at a set interval and gets the reading from the U6:




If you are going to use a while loop you will want it to run in a different thread than your main one. Basically use multithreading where one thread is in the while loop, and other threads are doing something else in your application.


I wasn't sure if you were asking for help with plotting and graphs, but in Qt you can make your own widget to do so or use something like Qwt which provides a framework for plotting:




For Qt related help you will want to do a online search, read Qt documentation and use the Qt forums.

#3 rouby11

  • Members
  • 3 posts

Posted 02 October 2014 - 01:25 AM

thanks a lot,


Basically I've no problem to read from labjack But I want to see the difference of tempeture into graph that evolve in time so i need button start and another Stop.


the problem when I read temp with while loop i cant do anything else so I need thread but it didn't work in Qt netbeans (C++) I need example how thread work Please.


after that I will do graph with QWT.


I'm so grateful that you answer me.



#4 LabJack Support

LabJack Support
  • Admin
  • 8677 posts

Posted 02 October 2014 - 12:28 PM

Here's QT documentation on threads which includes links to examples demonstrating thread usage using QThread:




In their example you would put your while loop code in their "doWork" function which has the comment "/* ... here is the expensive or blocking operation ... */".


As mentioned earlier and in the documentation, you can also look into using a timer (QTimer). Note to not sleep in your timer code and let the configured intervals do the delay between reads.


Your start button can create/start the new thread or timer, and the stop button would stop it.

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users