EnglishSvenska

Detta inlägg är automatiskt översatt till svenska med Google Translate.

Realtime data plotter

Debugging sensors on a microprocessor can be a hassle and the most used approach is to output the sensor values to a serial monitor. Realtime plotting is a better and more visual way of doing the same thing.

RealtimePlotterProcessing

  • Uppdaterar plot i realtid medan det fortfarande behandlas av mikroprocessorn
  • Plots live data from serial port. Microprocessor choice does not matter as long as it can send serial data to your computer.
  • 6 channels of data (and this can be increased if necessary)
  • Stapeldiagram i realtid
  • Linjediagram i realtid
  • You just send the data you want to debug with a space as delimiter like this "value1 value2 value3 value4 value5 value6". Floats or integers does not matter.
  • Open source
  • Robust. It will not crash because of corrupt data stream or similar.
  • Multi platform Java. Tested on OSX and Windows 8 (and should work on Linux as well).

I created this software to debug an Arduino Due on my self-balancing robot. To tune the controls of the robot I needed fast feedback to know if I was making progress or not. The video below demonstrates typical use of the realtime plotter:




Download

Download
You can also följa projektet på Github. If you make improvements to the source code, please share it by making a pull request at Github.

Installera och använda

Since I have an Arduino I will use it as example but any micro processor can be used.

  1. Ladda ner ProcessingIDE to run the code. It is a neat and useful IDE for doing graphical stuff.
  2. Download controlP5 gui library och packa upp den till mappen för Processing libraries
  3. Connect the Arduino to the usb or serial port of your computer.
  4. Upload the example code (RealtimePlotterArduinoCode) to the Arduino
  5. Check serial monitor (at 115200) and check that it outputs data in the format "value1 value2 value3 value4 value5 value6".
  6. Close the serial monitor (since only one resource can use the serial port at the same time).
  7. Open the Processing sketch and edit the serial port name to correspond to the actual port ("COM3", "COM5", "/dev/tty.usbmodem1411" or whatever you have)
  8. Kör koden

Advanced use

The realtime plotter can be expanded to also send commands to the microprocessor. The usual approach when programming microprocessors is to set some parameters in the beginning of the code, upload them to the processor, see the result, change the parameters again, upload, and so on until satisfactory performance is achieved. This iterative process takes a lot of time and a better approach is to send updated parameters to the microprocessor from your computer via serial data. For example I needed to tune some parameters on my robot and created a command panel that runs in parallell with the realtime plotter. For each change in parameters I immediately am able to see the result on the plotting screen. Example code of this is located in /RealtimePlotterWithControlPanel.

RealtimePlotterProcessingWithControlPanel

Mina kommentarer

I decided to send and receive the data as ascii characters instead of binaries. The greatest disadvantage is performance and ease of use is the main advantage.

In some sense the realtime data plotter can also be used as a very slow and limited digital oscilloscope. I would not recommend using it for any high frequency applications though.

Some comments about earlier approaches and the used libraries

I have tried many different ways of doing this. My first approach was Matlab but I had problems with it locking the serial port. It was a hassle to get it working and getting everything configured takes to much time. My second approach was Python and graphing libraries but this was still not very satisfactory. The Processing language together with a graph library and ControlP5 made the whole thing much easier.

 

Kategori: Realtime plotter, Timeline
35 Comments »Realtime data plotter
  1. ben skriver:

    The Processing IDE looks very interesting! Kinda looks like a Enthought Chaco alternative!

    Is there anything unique about this Arduino setup that would prevent plotting data using other microcontrollers (stm32, msp430, etc)? In the past, I've mostly seen pyqt and matplotlib used on the pc gui side, and firmata on arduinos, to do real-time graphing.

    I'd like to do an open source version of a uCProbe (Micrium) to do not just graphing but to display the current state of pins, etc. Not sure how different 'RealtimePlotterArduinoCode' is from 'firmata' or which would be best if porting to a stm32. Any suggestions?

    • sebnil skriver:

      It would work on any microcontroller since it is just sending of data over serial. You would also be able to display the current status of pins if you send them as 1 or 0 depending on the state. Or you could modify my code and do something more fancy to display pin states.

  2. Saneesh skriver:

    Excellent work buddy. I was just looking for some app like this to tune a motor parameters using serial port.

  3. Vsevolod skriver:

    It's pretty insane that there were no common tools for that, great work. Could you please tell me if it's able to plot 3 sensor readings 400 times per second update rate (24bits each)? Thanks in advance for any help you are able to provide.

  4. Tobias Rådenholt skriver:

    Nice work! I'm going to use this to visualize data and tune my Arduino autopilot for sailing yachts. Also gonna try to send commands to the autopilot from the command window.

    I have just downloaded and got this running on Ubuntum, but I had to make chnages in the code:

    The path to plotter_config.json

    From
    plotterConfigJSON = loadJSONObject(topSketchPath+"/plotter_config.json");
    to
    plotterConfigJSON = loadJSONObject("/home/USERNAME/Skrivbord/BasicRealtimePlotter/plotter_config.json");

  5. Juan from Brazil skriver:

    Man Nice work!
    meus parabens from Brazil :)!!
    Juancito

  6. Mark skriver:

    Nice work! However we noticed some acculating time lag in the visualization. We tested with 4 signals at 115200 Baud. Do you have any recommandation to avoid this behaviour?

    • sebnil skriver:

      Yes, but I am working on a solution using Python instead but have nto gotten to it just yet. The reason is either processing of the serial or drawing of the graph, and the solution I am working on is puttin geach of these tasks in separate processes instead.

      • Mark skriver:

        Thanks for the reply. Looking forward for the next (Python based?) release of the Real Time Data Plotter. Keep up with the nice work.

  7. Matt skriver:

    I'm sorry I don't fully understand how to get this code working for myself. I am trying to transmit data that I filtered from various sensors. Do I not just use
    Serial.print(data);Serial.print(" ");
    to get it to plot if I choose the proper COM port and baud rate? I am using an arduino UNO if it matters...

    Thanks!

    • Sebastian Nilsson skriver:

      Yes, that should be about it. And then add a new row of data with println. There is an Arduino example in the github code I think. Good luck!

  8. Jan skriver:

    Hello Sebastian,

    Thanks for sharing a great real-time plotting tool. I would really like to use it for MCU debugging and testing, but I am getting an error.

    I am trying to get your RealTimePlotter up and running. I have installed Processing, the controlP5 library and opened the sketch "BasicRealTimePlotter", but I get the error "PApplet.sketchPath is not visible" when I try to run the sketch. It refers to the following code line in BasicRealtimePlotter:

    // settings save file
    topSketchPath = sketchPath;

    Do you have any suggestions to what causes this error?

    • sebnil skriver:

      I believe you are running on a new Processing version. This is old code and it works better on the old processing. But Tobias Rådenholt in a few comments above you seem to have a solution.

      Please make a pull request to the github repo if you fix any issues. That is the only way of keeping this project alive.

      /Sebastian

  9. Gabriel skriver:

    Hello Sebastian

    Very interesting and Great project,I was try your RealtimePlotterWithControlPanel for my self-balance robot,I upload the example code (RealtimePlotterArduinoCode) to the Arduino and I run sketch RealtimePlotterWithControlPanel when realtime plotter run the graph work fine but the panel robot tuner not visible , i don't know what the problem, i use processing 2.2.1, whether I should change your code (RealtimePlotterArduinoCode) but what the code I should change? or whether i should add (RealtimePlotterArduinoCode) to your ardino code (selfbalancing_robot_arduino_due) so that RealtimePlotterWithControlPanel work fine

    Thank you Sebastian

    • sebnil skriver:

      Unfortunatly I do not know why the code for processing does not work. I wrote it a long time ago and I think I wrote it for an older Processing version. Read the error messages, try and figure it out and make a pull request to the Github page with a solution.

      Good luck!
      /Sebastian

      • Gabriel skriver:

        Thanks for the reply, in processing 2.2.1 no error messages, real time plotter work fine ,but the robot tuner panel not visible, ok i will try in processing 1.5.1

        Thank you Sebastian

        Regards,
        Gabriel

        • Gabriel skriver:

          In processing 1.5.1 it not compatible for your code because no java mode in processing 1.5.1, but your code (BasicRealtimePlotter) compatible in processing 2.2.1 and 3.0, if use processing 2.2.1 use the code // settings save file
          topSketchPath = sketchPath;
          and if use processing 3.0 use the code
          // settings save file
          topSketchPath = sketchPath();

          Your code (RealtimePlotterWithControlPanel) just compatible in processing 2.2.1

          • Gabriel skriver:

            I have question how your self-balance ARM robot connection your Realtime plotter such as your video on youtube? just upload the example code (RealtimePlotterArduinoCode) to the Arduino and run sketch RealtimePlotterWithControlPanel/ BasicRealtimePlotter , whether I should change your code (RealtimePlotterArduinoCode) but what the code I should change? or whether i should add (RealtimePlotterArduinoCode) to your arduino code (selfbalancing_robot_arduino_due) so that RealtimePlotterWithControlPanel/ BasicRealtimePlotter work fine?

            Thank you Sebastian
            Regards,
            Gabriel

          • sebnil skriver:

            If I remember correctly the robot code already outputs the right data to the plotter. But if not, it is just print statements. Good luck! /seb

          • sebnil skriver:

            Please make a pull request on github to help people out who are struggeling with the same problem. And thank you for sharing your fix.
            /seb

          • Gabriel skriver:

            I dont' have account github

            I have one question in your arduinocode(selfbalancing_robot_arduino_due) no code already outputs the right data to the plotter,But if not, it is just print statements ,Can you give example the print statements self-balance ARM robot connection your Realtime plotter such as your video on youtube? And in your github selfbalancing-robot-v2 no code vReadIMUTask, i compile in arduino code 'vReadIMUTask' was not declared in this scope in arduino, i think the code outputs the right data to the plotter it in the vReadIMUTask

            ,Please help me, I confuse

            Thank you Sebastian
            Regards,
            Gabriel

  10. ICY skriver:

    Hello, thanks for your info. I just got some errors because of Processing Version (I am using Processing 3.1.1).
    Errors are like " The method add(Component) in the type Container is not applicable ....".
    Is there any site that I can refer in order to fix your code for Processing 3.1.1.
    Thanks.~

  11. Robert skriver:

    Hello Sebastian,
    I'm working on a project were I use dual channel PID to balance a ball on a surface with 2 degrees of freedom. The project cant be seen here: https://www.youtube.com/watch?v=0MD_lD6VtoU
    The ball sits on a resitive touch screen that sends X and Y location of the ball and then 2 servo motors (one in X direction and another in the Y) actuate the system.

    I was able to successfully plot the X and Y values using your BasicRealtimePlotter. However I'd like to have two separate real-time line graphs. One to plot the X direction and the other for the Y direction.
    I tried modifying your code to remove the bar graph and instead replace it with a line graph. However I ended up with one graph drawing all the axis and labels with no lines plotting and another with the lines plotting but no axis or labels drawn.

    Is there anyway you could help me with this or point me towards some source to allow me to plot two separate real-time plots?

    Thanks in advance,
    Robert

  12. Simon skriver:

    Thank you so much! This is perfect... I'm building an LED display connected to an Arduino with an MSGEQ7 chip, for live guitar performances... I was opening Putty logs in excel and graphing... over and over and over again lol This is so useful to be able to visualise live, to help me work out how I can translate the spectrum info and design some funky drawing routines back on the Arduino 🙂 Thanks again!!

  13. Felix skriver:

    Is there anyway to increase graph plotting location and size ?

  14. Riya Shah skriver:

    it is not compatible with arduino on windows 10 ?
    Because while unzip step, it shows error.

  15. Erik Resch skriver:

    Hi!
    I found the graph class through your link and I would like to change the amount of values i put out to the graph. so i can see more values at once.
    What code do I need to change?

  16. Derek Covill skriver:

    this really is a great programme that will be very useful to me (I hope!) so firstly, thanks!! I have this running now, but I can't for the life of me figure out how to specify which channels it is reading (ie which pins it is reading on the microcontroller). Any guidance with this would be very welcome. Also, I would like to plot an entire set of data so that the data set grows from the time the programme is run (t=0) rather than having realtime data over writing every step, is there a way this can be done?

  17. Amaresh skriver:

    Can this software work for a baud rate of 921600 bps?

  18. Hakan Oren skriver:

    hi, great job! I'm trying to make a ground control station software for my rocket, but I'm new to this, how do I plot the data I get from the accelerometer. And I also need to add a few more line charts. Can you help me in an explanatory way?

  19. Edvinas skriver:

    hello, nice work, I tried reading the code and couldn't understand is it possible to slow down the plotting?

  20. Douglas Santana da Silva skriver:

    Hello guys.

    I come here to present my software and firmware that I developed for my monograph. The system consists of acquiring data from an Arduino and the possibility of recording them in .TXT or .CSV files. The system can acquire signals from analog ports, interrupt port for speed counting if an encoder is inserted, control digital ports and other things.

    The software was developed for industrial automation, focusing on the management of a pilot plant for the chemical industry, but as the probe inputs are renameable and the parameters can be changed, there are countless possibilities for use.

    The software development was generated by the Processing platform

    The system is entirely in English, and I have created a manual for use, there is also information on the connection diagram.

    The available firmware is for recording on an Arduino Uno.
    When starting the software, the Login and Password will be required, in the manual there is this information. Enter each information in the corresponding field and press enter, at the end, click on “OK”.

    Here is the download link:

    https://discourse.processing.org/t/software-for-industrial-automation-using-arduino/39786

2 Pings/Trackbacks for "Realtime data plotter"

Lämna ett svar

Din e-postadress kommer inte publiceras. Obligatoriska fält är märkta *

*